text:
Multiple RGB led strips with Uno - options?
I know there's quite a few threads with similar answers already, but I hope you won't mind me asking anyways. One thread has what looks like a good solution but it's old and thought it may be better to ask fresh.
I have ten 12v rgb strips with 4 wires each, a 12v power supply and 30 mosfets. I want to control them individually with an Uno.
I'd like to make a wave effect where the strips increase and decrease in brightness at separate times. It's fine if they are all the same color during a wave. Then a wave of a different color.
(1) I'm thinking of trying the approach in this thread where AMADANON suggests using 3 pins for the color and then each strip gets its own common pin, 13 pins in my case. If I go this route, will I be able to set a color for all strips and a brightness for individual strips? This would let me make the wave effect I'd like.
(2) Alternately I'm thinking of upgrading to a Mega with 54 pins. I assume I could then control each strip individually using 3x10 = 30 pins?
(3) I've read lots of advice on chips to control the strips, but I'm a newbie and would like to keep it as simple as possible (plus delivery to my country takes 3 weeks or more, and I'd like to get started now)
Thanks for any advice!
EDIT:
(I replied to answers in comments, and I now see I should just instead edit this question. Thanks for your patience with a newbie!)
The mosfets are N-Channel MOSFET 60V 30A.
The led strips are rgb non-addressable with 4 wires, wired on both ends so they can be easily daisy-chained. But in my project the strips are snaking around some tracks and connected them in serial poses a problem. I'd prefer to wire each from only one end.
I think I'll try Gerben's and Andrew's advice about a chip and check out PCA9685 chip module as per Andrew's suggestion. Sounds inexpensive!
chrisl's suggestion for using WS2811 chips sounds easy too and maybe less wiring. In the same vein was an idea from this thread from gre_gor:
Setting 10 RGB Strips Independently from Single Arduino
... which talks about chainable STM32 rgb chips, only about 2 bucks on ebay, no mosfets, and pretty efficient.
Thanks for all the advice guys! I'm finishing the box and strips placement now and waiting for my Arduino to arrive which should be any day. This is my first venture into this domain (though I've done plenty of coding and have some experience with electronics).

which LED strips? Many can be daisy chained into longer strips controlled by the same 4 wires.

you should get addressable LEDs; not only could you hook them all up with one pin, you don't have to have the whole strip the same color, which makes for MUCH nicer effects, speaking from experience.

Sounds like you need 30 PWM pins. No Arduino has that. So either get one/multiple external chips that do that for you. Or do PWM in software. Or do multiplexing and software PWM, to require fewer pins (13), like you said in option 2. This will reduce the maximum brightness. It's also not the easiest to write. There might be a library for it.

Hi gre_gor -- I'm really interested in your idea with the STM32 rgb drivers. Will these plug into a breadboard for daisychaining, or are there connector plugs in that size, or will I need to fire up a soldering iron? Thank you.

@Abacaba No you can't put them on the breadboard. You need 4 female dupont wires to daisy chain them.

I know what you mean - LED strips with all the same colour at the same time. I've used these and I assume you can wire up the MOSFETs ok. If you don't need individually-addressable LEDs they can still produce some effects.
To control 30 PWM lines, at first I thought using the Mega would solve it, but as someone else reminded us, only 15 are full (hardware) PWM and some would have to be software PWM. This may be good enough, I don't know. More expensively, you could use two MEGAs with one acting as a slave to get 30 full PWM pins.
Another idea would be to use a PCA9685 chip module. I got a couple of these on ebay some while ago (dirt cheap, under £2/$2 ) and each board provides 16 PWM outputs, all controlled from I2C input. They aren't hard to use and have library code for Arduino. Two of these and an UNO would do it or one and a MEGA.

Thanks! Two megas is definitely a possibility (they're only $11 at kumantech.com) but that PCA9685 module sounds very promising. I'll check that out!

It sounds to me that you have this kind of tape leds.
If I'm right then your led strip has 4 pins:
1- Blue
2- Green
3- Red
4- GND
With this you can create up to (2^8)(2^8)(2^8) = 16,777,216 colors (using PWM or any other dimming technique with the Arduino), BUT ALWAYS having the same color in all the led strip. So, at least as far as I know, you can not do the effects you want with that strip.
What do you need? You need a "smart" tape, one like this
As you will see in the name says addressable, this means that, for example, you can put the green color on led No1 and the red color on led No2 and so on, and you can move those LEDs making very interesting and cute effects!
Hope you can find this fast explanation helpfull.

The OP doesn't want to control the LEDs individually, but only the ten strips he has. The effect would be visible in the difference between the stripes. But yes, if he actually had individually controllable LEDs, this would be way easier, because there would be no need to handle PWM with the Arduino

Sorry about the (perhaps) obvious question: what means "OP"? I see very often when people talk about newbies(?)... And so... yes, it's what you say about the question of the "OP" :D

OP means Original Poster. In this case I mean the user, that asked the question :D

Thanks for the answer! Yes, those are the same kind of strips I have (well, mine are shorter and more expensive!) I think you're right that addressable is probably the best route - and now that I'm thinking about it there could be some very cool effects. But I've already bought the strips and am going to try to use these first 'cause another 100 bucks into the project would be getting spendy!

As stated before by other users, there are multiple ways to go, but you will have to make compromises.

When using an Arduino Mega, you will have to bitbang the PWM signal (directly or by using some timer interrupts), because only 15 of it's pins can be used as native PWM pins.
In my opinion it would be the cleanest solution, to use a single driver chip for each LED strip. You can use the WS2811 chip, which is used in most LED strips with individually addressable LEDs. It outputs 3 PWM signals (for red, green and blue) and gets controlled by shifting bits through it's input. Also these chips can be daisy-chained; meaning, that only the first is hooked up to the Arduino and all other chips will be chained together (serial output to serial input). In this solution each chip would controll one of the ten LED stripes (note, that you still have to use a capable MOSFET between WS2811 and strip, since the chip cannot provide enough power for a whole strip), and they would be chained together, effectively only using 1 pin on the Arduino. You can then use librarys like the Adafruit_Neopixel to control the strips. Each of your strips then corresponds to 1 LED in the library. You can buy the WS2811 chips at various sources. When googling I found them for 5$ at Adafruit, but you may find them somewhere else for less (This was simply the first shop, where I found them. Didn't searched long). The datasheet (for example here) contains example applications, which show, how the chips have to be connected. For this solution, you would have to replace the depicted LEDs with MOSFETs, that drive the strips PWM lines.

Thanks so much! I appreciate the links. It would tricky with my project to chain the strips without drilling holes in my case (which I suppose I could). Is there a way to chain them all from one end with the other ends of strips terminating? I'll look at the examples and see if there's clues there.

I don't understand, what you mean. The driver chips have to be chained together, not the strips. And you can put the chips, where you need them. Either directly with your Arduino or where the strips are.

I have ten 12v rgb strips with 4 wires each, a 12v power supply and 30 mosfets. I want to control them individually with an Uno.

These sound like non-smart LED strips, where you supply 12V on one pin and then there is a control line for each color. Three resistors for each 3 LEDs, with the groups of 3 wired in parallel on the strip. In which case, 3 MOSFETs per strip to sink current to Gnd sounds good, and you can likely one MOSFET control the same color on multiple strips. Thus you can use the 18 IO of an UNO, leaving D0/D1 free for serial comms with your PC.
Uno has 6 hardware PWM pins for 256 levels of brightness via analogWrite(), and you can create software PWM for the other pins as well.
Which MOSFET do you have?

Thanks for the answer! I've got N-Channel MOSFET 60V 30A, from here: https://www.sparkfun.com/products/10213.


text:
LCDs interfere with Adafruit datalogger SD card function
I am using the Adafruit datalogger shield (Rev B) and a pair of cheap 20x4 LCD I2C displays. The displays have a small I2C I/O expansion module board on the back. The LCDs I am using are these;
https://www.amazon.ca/gp/product/B01GPUMP9C/ref=oh_aui_detailpage_o09_s00?ie=UTF8&psc=1
I'm using the NewLiquidCrystal 1.3.4 I2C library. My UNO clone is the iteaduino-BT https://www.itead.cc/iteaduino-bt.html, which is a board I really like.
I am getting interference between the LCD displays and the SD card function. Sometimes I can write to the SD card, and sometimes I can't. I have tried several SD cards. After a lot of experimenting, I think I have identified the problem. The LCDs are interfering somehow with the SD card functions. The LCD objects are created with the following statements;

    // set the lcd1 address to 0x26
    // Set the pins on the I2C chip used for lcd1 connections:
    // addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
    LiquidCrystal_I2C lcd1(0x26, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// set the lcd2 address to 0x27
LiquidCrystal_I2C lcd2(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

If I comment out the LCD lines, the SD problem goes away. My thinking is that the four data lines used by the LCDs (4,5,6,7) may be overlapping with the datalogger card, but after looking at the datalogger schematic, I can't see the problem. I found a couple of websites suggesting mapping the LCDs to use different data lines, but I'm not sure if that is the problem.
I also ran a program to scan the I2C bus and it showed that the LCDs were at 26 and 27 and the Adafruit datalogger at 68. No interference with addresses at least.
I really need this working yesterday. Creating datalogging projects is nothing new and I can't believe that there is no solution for including I2C LCD displays. Should I experiment with different LCD libraries or try mapping the pins differently during the creation of the LCD objects? I also am wondering if I can simply shut off the LCDs when writing to the SD card and then turn them back on after. I plan on taking measurements and writing the results every 5 minutes for several days, so high speed anything is not a requirement.
The code sample below is part of my program. I use the while(1) line as a hard break for debugging purposes.
#include <OneWire.h>              // library for DS18B20 thermocouple
#include <DallasTemperature.h>    // library for DS18B20 thermocouple
#include <Wire.h>                 // used for rtc
#include <SD.h>                   // library for SD card
#include <SPI.h>                  // library used for SD card
#include <RTClib.h>               // library for real time clock
#include <LiquidCrystal_I2C.h>    // library for lcd displays
#define ONE_WIRE_BUS 8            // Data wire for thermocouple is plugged into pin 8 on the Arduino
#define SYNC_INTERVAL 1000        // mills between calls to flush() - to write data to the card

RTC_PCF8523 rtc;                  // define the Real Time Clock object

String datetimestamp;
uint8_t MM;
uint8_t DD;
uint8_t mm;
uint8_t hh;
File logfile;                     // create file object to save results on SD card
const int chipSelect = 10;        // for the data logging shield, we use digital pin 10 for the SD cs line
OneWire oneWire(ONE_WIRE_BUS);        // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire);  // Pass our oneWire reference to Dallas Temperature.

// set the lcd1 address to 0x26
// Set the pins on the I2C chip used for lcd1 connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd1(0x26, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

// set the lcd2 address to 0x27
LiquidCrystal_I2C lcd2(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

String inputString = "";         // a string to hold incoming data
String ackString = "ack";        // acknowledgement string from terminal
String temperature;              // temperature
boolean stringComplete = false;  // whether the incoming string from serial port is complete with /n
int interval = 60000;            // interval between measurements
long previousMillis;
int cycle = 1;                   // cycle number
int heartbeat = 30000;           // ping teminal to prevent bluetooth from shutting down
String dim_length;
String dim_width;
String dim_height;
String measurements;              // string containing measurements for inclusion in SD file
int firstcomma;
int secondcomma;
int thirdcomma;
String logEntry;
char filename[] = "logdata.txt";

void setup(void) {
  Serial.begin(9600);
  inputString.reserve(20);               // reserve space for the inputString
  pinMode(10, OUTPUT);
  pinMode(ONE_WIRE_BUS, INPUT);          // used for thermocouple

  WaitFor(2000);

  lcd1.begin(20, 4);        // initialize the first lcd for 20 chars 4 lines
  lcd1.backlight();         // turn on backlight
  lcd1.clear();             // clear lcd11

  lcd2.begin(20, 4);        // initialize the second lcd for 20 chars 4 lines
  lcd2.backlight();         // turn on backlight
  lcd2.clear();             // clear lcd11

  //These routines update rows on the LCDs
  Row1("DATE: ");
  Row2("TEST CYCLE: ");
  Row3(" ");
  Row4(" ");

  // check for working real time clock
  if (! rtc.begin()) {
    Row4("RTC failed");
    WaitFor(500);
    while (1);
  }
  else {
    Row4("RTC found");
    WaitFor(500);
  }

  if (! rtc.initialized()) {
    Row4("RTC failed");
    WaitFor(500);
    while (1);
  } else {
    Row4("RTC initialized");
    WaitFor(500);
  }

  UpdateRow1(GetTimestamp());      // display current date and time
  UpdateRow2(cycle);               // display current test cycle

  // initialize SD card
  if (!SD.begin(10)) {
    Row4("SD init failed");
    WaitFor(500);
    while (1);
  } else {
    Row4("SD card initialized");
    WaitFor(500);
  }

  //log file setup
  if (SD.exists(filename)) {
    Row4("log file exists");
    WaitFor(500);
  } else {
    Row4("log doesn't exist");
    WaitFor(500);
  }

  // sample write to SD card
  Row4("opening log file");
  logfile = SD.open(filename, FILE_WRITE);
  Row4("writing log file");
  WaitFor(500);
  logfile.println("DateTime,Temperature");
  WaitFor(500);
  for (int x = 1; x < 6; x++) {
    logfile.print("Test # ");
    logfile.println(x);
    delay(1000);
  }
  logfile.flush();
  WaitFor(500);
  Row4("flushed log file");
  WaitFor(1000);

  while (1);  //temporary stop for debugging

I think your problem is with the way you create the LCD instants.
I've always used LiquidCrystal_I2C lcd(0x27, 20, 4); LiquidCrystal_I2C lcd(address, row, col); when I'm using the I2C modules.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Interfacing Uno to Logitech Attack3 Joystick
I bought a Logitech Attack3 joystick at a garage sale for a couple of bucks and now I want to use it for something useful, like controlling a car or my small robotic arm. This joystick has 11 buttons and three sliders. I plugged it into a Sparkfun USB shield on top of an Arduino UNO and found some code online to get it up and running. It outputs hex values that tell me the slider values and the states of all the buttons. Where I am having difficulty is that I don't know C++ at all and the event handler and serial output commands are coming from the cpp file. I think that if I can get the output from the cpp file into the main loop in the ino file, I'll be able to do what I want with the data more easily. I plan to use a radio like XBee or Bluetooth to send commands based on the joystick output.
I cut down the code as much as I thought I could get away with. I'm hoping that someone can show me how to organize the code to allow me to do all my logic in the ino file.
Here is the INO file.

#include <usbhid.h>
#include <hiduniversal.h>
#include <usbhub.h>
#include <SPI.h>
#include "hidjoystickrptparser.h"

USB Usb;
USBHub Hub(&Usb);
HIDUniversal Hid(&Usb);
JoystickEvents JoyEvents;
JoystickReportParser Joy(&JoyEvents);

void setup() {
  Serial.begin(115200);
  pinMode(7, OUTPUT);
  digitalWrite(7, HIGH);
  if (Usb.Init() == -1)
    Serial.println("OSC did not start.");
  delay(200);
  if (!Hid.SetReportParser(0, &Joy))
    ErrorMessage<uint8_t > (PSTR("SetReportParser"), 1);
}

void loop() {
  Usb.Task();
  delay(10);
}

and the cpp file
#include "hidjoystickrptparser.h"

JoystickReportParser::JoystickReportParser(JoystickEvents *evt) :
joyEvents(evt),
oldButtons(0) {
        for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++)
                oldPad[i] = 0xD;
}

void JoystickReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
        bool match = true;

        // Checking if there are changes in report since the method was last called
        for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++)
                if (buf[i] != oldPad[i]) {
                        match = false;
                        break;
                }

        // Calling Game Pad event handler
        if (!match && joyEvents) {
                joyEvents->OnGamePadChanged((const GamePadEventData*)buf);
                for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) oldPad[i] = buf[i];
        }

        uint16_t buttons = (0x0000 | buf[6]);
        buttons <<= 4;
        buttons |= (buf[5] >> 4);
        uint16_t changes = (buttons ^ oldButtons);

}

void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) {
        Serial.print("Joystick X: ");
        PrintHex<uint8_t > (evt->X, 0x80);
        Serial.print("\tJoystick Y: ");
        PrintHex<uint8_t > (evt->Y, 0x80);
        Serial.print("\tTrim: ");
        PrintHex<uint8_t > (evt->Z1, 0x80);
        Serial.print("\tSW1-8: ");
        PrintHex<uint8_t > (evt->Z2, 0x80);
        Serial.print("  SW9-11: ");
        PrintHex<uint8_t > (evt->Rz, 0x80);
        Serial.println("\t");

and the header file
#if !defined(__HIDJOYSTICKRPTPARSER_H__)
#define __HIDJOYSTICKRPTPARSER_H__

#include <usbhid.h>

struct GamePadEventData {
        uint8_t X, Y, Z1, Z2, Rz;
};

class JoystickEvents {
public:
        virtual void OnGamePadChanged(const GamePadEventData *evt);
};

#define RPT_GEMEPAD_LEN     5

class JoystickReportParser : public HIDReportParser {
        JoystickEvents *joyEvents;

        uint8_t oldPad[RPT_GEMEPAD_LEN];
        uint8_t oldHat;
        uint16_t oldButtons;

public:
        JoystickReportParser(JoystickEvents *evt);

        virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
};

#endif

Here is what the output looks like in the serial monitor
Joystick X: 80  Joystick Y: 82  Trim: 7A    SW1-8: 00  SW9-11: 00
Joystick X: 7B  Joystick Y: 80  Trim: 7A    SW1-8: 00  SW9-11: 00
Joystick X: 7B  Joystick Y: 7F  Trim: 7A    SW1-8: 00  SW9-11: 00
Joystick X: 7B  Joystick Y: 7F  Trim: 7A    SW1-8: 00  SW9-11: 01
Joystick X: 7B  Joystick Y: 7F  Trim: 7A    SW1-8: 00  SW9-11: 00

An Arduino Sketch's .ino is C++ code. It just doesn't define or use any C++ classes by default. It's vanilla C, which is a subset of C++. It isn't clear to me what your Usb.Task(); line does, or how that invokes code in the joystick C++ file you posted. Is there documentation on the joystick library you're using?

The sample I'm showing is exactly as I found online, except that I took out unneeded some code and tweaked the Serial.print lines in the cpp file. I also don't know exactly what routine Usb.Task() does. I'll get back to you with more information.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Cant open serial monitor on linux
I have a pro micro and I'm running the IDE on linux.
The IDE easily recognises that my board is on /dev/ttyACM0 so i can flash programs on to it.
I am testing the following code

void setup()
{
  Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
}

void loop()
{
  Serial.print("Hello universe ");
}

After I upload the code if I try to bring up the serial monitor I get this error message

Error opening serial port '/dev/ttyACM0'. (Port busy)

tried resetting the pro micro, rebooting the computer, tried the code

sudo usermod -a -G dialout yourUserName as suggested here

But the problem still didn't solve. Any idea what went wrong.
Edit1:
I noticed that when the arduino is in the bootloader mode (i.e when I press reset) lsusb shows

Bus 004 Device 055: ID 2341:0037 Arduino SA

however, when it starts to execute the program from its memory, lsusb doesn't show that entry. but instead, shows

Bus 004 Device 054: ID 1b4f:9206

Modem manager. Every time.

I tried changing the USB cable. IT doesn't seem to be the cause . also check out the edit1.

To expand on Majenko's comment, try sudo apt-get purge modemmanager.

Thankyou Edgar Bonet your solution worked. Will you please write it as a solution, also please explain why modemmanager gave the problem. wouldnt uninstalling modemmanager trouble other apps that use it?

This solution worked for me too. I could upload sketches to my arduino via a sparkfun FTDI connector (FT231X) but could not use the serial monitor.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
NodeMCU stops responding after several hours
I'm controlling some devices through a relay and a NodeMCU, it works fine and reconnects without problem in the meantime I'm testing it, but after I leave it like for 3 or more hours, it stops responding. I need this system to always be working without sleeping or anything. Here is my code:

#include <ESP8266WiFi.h>

const char* ssid = "wifi_Guerrero ";
const char* password = "3245968530";

int ledPin = 13; // GPIO13
int ledPin2 = 12; // GPIO13
int desconectado = 5;
int conectado = 4;
WiFiServer server(80);
WiFiClient client;

int counter = 0;

void setup() {
  Serial.begin(9600);
  delay(10);

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);

  pinMode(ledPin2, OUTPUT);
  digitalWrite(ledPin2, LOW);

  pinMode(conectado, OUTPUT);
  pinMode(desconectado, OUTPUT);
  digitalWrite(desconectado, HIGH);

  connectWifi();

  Serial.print(F("Setting static ip to : "));
  Serial.println(WiFi.localIP());

  // Start the server
  server.begin();
  Serial.println("Server started");

}

void loop() {

  delay(200);

  if (WiFi.status() != WL_CONNECTED) {
    delay(100);
    digitalWrite(conectado, LOW);
    digitalWrite(desconectado, HIGH);
   connectWifi();
  }

  // Check if a client has connected
  client = server.available();
  if (!client) {
    return;
  }

  // Wait until the client sends some data
  Serial.println("new client");
  int t = millis();
  while(!client.available()){
  delay(1);
  if (millis()-t>130) return;
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();

  // Match the request
  if (request.indexOf("/switch") != -1)  {
    digitalWrite(ledPin, !digitalRead(ledPin));
    digitalWrite(ledPin2, !digitalRead(ledPin2));
    printSwitch();
  }else if (request.indexOf("/uno") != -1) {
    client.print("Canal 1 apagagado | Canal 2 encendido");
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin2, LOW);
  }else if (request.indexOf("/dos") != -1){
    client.print("Canal 1 encendido | Canal 2 apagado");
    digitalWrite(ledPin, LOW);
    digitalWrite(ledPin2, HIGH);
  }else if (request.indexOf("/tres") != -1){
    client.print("Canal 1 apagado | Canal 2 apagado");
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin2, HIGH);
  }else if (request.indexOf("/cuatro") != -1){
    client.print("Canal 1 encendido | Canal 2 encendido");
    digitalWrite(ledPin, LOW);
    digitalWrite(ledPin2, LOW);
  }else if (request.indexOf("/cinco") != -1){
    printIP();
  }else if (request.indexOf("/apagaruno") != -1){
    client.print("Canal 1 apagado");
    digitalWrite(ledPin, HIGH);
  }else if (request.indexOf("/apagardos") != -1){
    client.print("Canal 2 apagado");
    digitalWrite(ledPin2, HIGH);
  }else if (request.indexOf("/prenderuno") != -1){
    client.print("Canal 1 encendido");
    digitalWrite(ledPin, LOW);
  }else if (request.indexOf("/prenderdos") != -1){
    client.print("Canal 2 encendido");
    digitalWrite(ledPin2, LOW);
  }else if (request.indexOf("/canaluno") != -1){

    if(digitalRead(ledPin) == HIGH) {
      client.print("Off");
  } else {
    client.print("On");
  }

  }else if (request.indexOf("/canaldos") != -1){

    if(digitalRead(ledPin2) == HIGH) {
    client.print("Off");
  } else {
    client.print("On");
  }

  }

// Set ledPin according to the request
//digitalWrite(ledPin, value);

  // Return the response

  delay(1);
  Serial.println("Client disonnected");
  Serial.println("");

}

void printSwitch(){
  if(digitalRead(ledPin) == LOW) {
    client.print("Canal 1 Encendido");
  } else {
    client.print("Canal 1 Apagado");
  }
  Serial.println("");
  if(digitalRead(ledPin2) == LOW) {
    client.print("Canal 2 Encendido");
  } else {
    client.print("Canal 2 Apagado");
  }
}

void printIP(){
  delay(100);
  client.print(WiFi.localIP());
}

void connectWifi()
{
  Serial.print("Connecting to "+*ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
  delay(500);
  Serial.print(".");
  }

  // config static IP
  IPAddress ip(192, 168, 0, 8);
  IPAddress gateway(192, 168, 0, 1);
  IPAddress subnet(255, 255, 255, 0);
  WiFi.config(ip, gateway, subnet);
  digitalWrite(conectado, HIGH);
  digitalWrite(desconectado, LOW);
  Serial.println("");
  Serial.println("Connected");
  Serial.println("");

  // Print the IP address
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");
}//end connect

You need to understand why it is stopping.  Start with something like printing serial log messages and capturing them to a log file that you can examine after failure.  Preferably do this over a pure UART connection (to a distinct USB to logic-level-serial) without using the on-board USB converter, unless you plan to have the USB connected to a PC in operation.  Though you can of course start with the on-board USB and see if you learn something, it's just that there's a risk that having that plugged in could hide power-related failure causes.

You should also consider if there are design errors in your unspecified electrical circuit.  Particularly things like insufficient input voltage to a regulator, relay coils without catch diodes, or any sharing of the logic and load power supplies.

I think the problem is not about the circuit or power supply, because I also left it on AP mode and when the static ip I assigned to it stopped responding, I connected directly to it's AP with 192.168.4.1 and it responded, after trying that, I tried again with static IP and worked fine, it seems like it sleeps or something programatically

The answer here might help you: https://arduino.stackexchange.com/questions/75494/esp8266-not-responding-after-random-intervals-of-time

I think thatthe problem lies with this definition
String request = client.readStringUntil('\r');

which you define dynamically in loop this leads possibly to heap fragmentation, causing resets after sometime
Define a global char array
char request [256] ={'\0'};
char c;
uint cc = 0;

and work instead the String functions with
while(client.available()){
c = client.read();
if (c != '\r'){
  request[cc] = c;
   cc++;
 }
 else return;
}

then handle the filled request buffer like
if (strcmp(request,"/switch") != 0)  {
  ....
 }

This should keep you esp running

That doesn't compile. You need a closing round bracket in your while loop. I also get:
error: empty character constant
char c = '';

You need to add a line where you’re reading into that buffer to make sure you don’t overrun.  Make sure cc doesn’t go over 255.


text:
Connect Arduino to LiDAR via RS-232
Edit: We're so close! Update at bottom!
I'm not sure if this is the right place to ask, but since you helped my so much in the past, I thought it's worth a try.
So as I stated in my last question, I'm using my Arduino Leonardo to simulate a GPS Receiver.
The Arduino is now connected to a Velodyne VLP-16 LiDAR
Here's what the Lidar needs:

I wired it like this:

And wrote the following code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 6); //232_TX,232_

int triggerFreq = 1;
unsigned long timestamp;
unsigned long triggerStartTime;
const unsigned long dt = 1000000/triggerFreq; //micros

unsigned long i;

float gprmc = 181721.000;

void setup() {
  pinMode(11, OUTPUT); // PPS
  pinMode(12, OUTPUT); // Indicator of msg_sent
  Serial.begin(9600);
  mySerial.begin(9600);
  triggerStartTime = micros();
}

void loop() {
  timestamp = micros()-triggerStartTime;
  if (timestamp>= dt*i+200000)
  {
    digitalWrite(12,HIGH);

    i +=1;
    gprmc += 1;
    mySerial.print("$GPRMC,");
    if (gprmc < 100000) mySerial.print(F("0"));
    mySerial.print(gprmc,3);
    mySerial.println(F(",A,4042.695,N,07400.796,W,,,080120,000.0,W*63"));
    Serial.print("$GPRMC,");
    if (gprmc < 100000) Serial.print(F("0"));
    Serial.print(gprmc,3);
    Serial.println(F(",A,4042.695,N,07400.796,W,,,080120,000.0,W*63"));
    digitalWrite(12,LOW);
  }
  else if (timestamp>=dt*i+100000)
  {
    digitalWrite(11,LOW);
  }
  else if (timestamp>=dt*i)
  {
    digitalWrite(11,HIGH);

  }

}

Here's the situation now:

I'm seeing on the board that the messages are being sent (TX LED flashing)
I'm also seeing that the pulse is sent correctly (flashing LED)
I don't measure any voltage on the TX output pin (RS232 pin3) (I'm just using my multimeter, but normally it reacts to such short voltage pulses by blinking an LED)
I do measure such a pulse on RS232 pin4
The LiDAR doesn't react to my sent messages

Now my question: Do you see an error in my implementation? Is the message sent correctly?
Thank you sooo much for your help! I'm really appreciating it!
Edit: The LiDAR manual says:

The supported NMEA sentence and syntax are exactly the same as on the wired (serial) GPS interface. Supported sentence delimiter sequences include  (HEX 0D0A, the standard),  by itself, and  by itself.

To be honest I'm not very familiar with these kind of problems so I'm not sure if these delimiters are already being sent?
Edit Nr2: Ok the following situation:

I'm actually not sure what changed. The code is still the same as above
The LiDAR now recognizes SOME of the messages (I can only see the position, so I edited the code to change the position a bit every second, and the Lidar updates its position irregularly but approx. all 10 seconds)
If anyone knows an explanation, I would be very happy to know. Otherwise, I just keep on trying an will keep you updated!

So the following code partially works. That means: the LiDAR recognizes certain messages... it seems like those are always the same messages (i incremented the position every second, these are the positions):

3015.2746
3015.2766
3015.2971
3015.3107
3015.3117

I displayed all the times when something was sent, and i could not find any differences between the messages that worked and those that didn't work.
One more followup:
If I try to increment pos+=0.0001, it does not work... it seems like i can only change up to 3 decimals. I don't understand why, since the float uses 4 bytes, so this should be no problem to store?! helpppp
Ok so here is the code for now:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 6); //232_TX,232_

int triggerFreq = 1;
unsigned long timestamp;
unsigned long triggerStartTime;
const unsigned long dt = 1000000/triggerFreq; //micros
unsigned long ts_pps_high;
unsigned long ts_pps_low;
unsigned long ts_msg_high;
unsigned long ts_msg_low;

unsigned long i;

int hh = 04;
int mm = 51;
int ss = 00;
float pos = 3015.2307;
bool msg;

void setup() {
  // put your setup code here, to run once:
  pinMode(11, OUTPUT); // PPS
  pinMode(12, OUTPUT); // Indicator of msg_sent
  Serial.begin(9600);
  mySerial.begin(9600);
  triggerStartTime = micros();
}

void loop() {
  timestamp = micros()-triggerStartTime;
  if (timestamp>= dt*i+350000)
  {
    pos +=0.001;
    digitalWrite(12,HIGH);
    i +=1;
    if (ss == 59)
    {
      ss=0;
      if (mm==59)
      {
        mm=0;
        hh+=1;
      }
      else mm+=1;
    }
    else ss+=1;

    ts_msg_high = micros();
    mySerial.print("$GPRMC,");
    if (hh<10) mySerial.print(F("0"));
    mySerial.print(hh);
    if (mm<10) mySerial.print(F("0"));
    mySerial.print(mm);
    if (ss<10) mySerial.print(F("0"));
    mySerial.print(ss);
    mySerial.print(".000,A,");
    mySerial.print(pos,4);
    mySerial.println(",N,09749.2872,W,0.67,161.46,030913,,,A*7C");

    // Print Debug Messages
    digitalWrite(12,LOW);
    ts_msg_low=micros();
    Serial.print("PPS at: ");
    Serial.print(ts_pps_high);
    Serial.print("\t PPS low after: ");
    Serial.print(ts_pps_low-ts_pps_high);
    Serial.print("\t MSG high after: ");
    Serial.print(ts_msg_high-ts_pps_high);
    Serial.print("\t MSG low after: ");
    Serial.print(ts_msg_low-ts_pps_high);
    Serial.print("$GPRMC,");
    if (hh<10) Serial.print(F("0"));
    Serial.print(hh);
    if (mm<10) Serial.print(F("0"));
    Serial.print(mm);
    if (ss<10) Serial.print(F("0"));
    Serial.print(ss);
    Serial.print(".000,A,");
    Serial.print(pos,4);
    Serial.println(",N,09749.2872,W,0.67,161.46,030913,,,A*7C");
  }
  else if (timestamp>=dt*i+100000)
  {
    digitalWrite(11,LOW);
    if (msg==true)
    {
      msg = false;
      ts_pps_low = micros();
    }

  }
  else if (timestamp>=dt*i)
  {
    digitalWrite(11,HIGH);
    if (msg==false)
    {
      msg = true;
      ts_pps_high = micros();
    }
  }

}

You can see my output as well:
PPS at: 2001060  PPS low after: 100000   MSG high after: 350016  MSG low after: 427132$GPRMC,045103.000,A,3015.2336,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 3001060  PPS low after: 100004   MSG high after: 350004  MSG low after: 427112$GPRMC,045104.000,A,3015.2346,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 4001056  PPS low after: 100000   MSG high after: 350004  MSG low after: 427116$GPRMC,045105.000,A,3015.2355,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 5001060  PPS low after: 100004   MSG high after: 350004  MSG low after: 427112$GPRMC,045106.000,A,3015.2365,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 6001056  PPS low after: 100004   MSG high after: 350004  MSG low after: 427116$GPRMC,045107.000,A,3015.2375,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 7001060  PPS low after: 100004   MSG high after: 350004  MSG low after: 427120$GPRMC,045108.000,A,3015.2385,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 8001056  PPS low after: 100004   MSG high after: 350020  MSG low after: 427132$GPRMC,045109.000,A,3015.2395,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 9001060  PPS low after: 100000   MSG high after: 350016  MSG low after: 427160$GPRMC,045110.000,A,3015.2404,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 10001052     PPS low after: 100008   MSG high after: 350020  MSG low after: 427164$GPRMC,045111.000,A,3015.2414,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 11001064     PPS low after: 100000   MSG high after: 350020  MSG low after: 427164$GPRMC,045112.000,A,3015.2424,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 12001056     PPS low after: 100008   MSG high after: 350004  MSG low after: 427152$GPRMC,045113.000,A,3015.2434,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 13001056     PPS low after: 99996    MSG high after: 350020  MSG low after: 427164$GPRMC,045114.000,A,3015.2443,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 14001056     PPS low after: 100008   MSG high after: 350008  MSG low after: 427156$GPRMC,045115.000,A,3015.2453,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 15001052     PPS low after: 100004   MSG high after: 350020  MSG low after: 427164$GPRMC,045116.000,A,3015.2463,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 16001052     PPS low after: 100000   MSG high after: 350016  MSG low after: 427164$GPRMC,045117.000,A,3015.2473,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 17001056     PPS low after: 100004   MSG high after: 350020  MSG low after: 427164$GPRMC,045118.000,A,3015.2482,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 18001052     PPS low after: 100000   MSG high after: 350016  MSG low after: 427164$GPRMC,045119.000,A,3015.2492,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 19001056     PPS low after: 100004   MSG high after: 350020  MSG low after: 427160$GPRMC,045120.000,A,3015.2502,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 20001060     PPS low after: 100000   MSG high after: 350004  MSG low after: 427148$GPRMC,045121.000,A,3015.2512,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 21001052     PPS low after: 100004   MSG high after: 350020  MSG low after: 427168$GPRMC,045122.000,A,3015.2521,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 22001064     PPS low after: 100004   MSG high after: 350004  MSG low after: 427148$GPRMC,045123.000,A,3015.2531,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 23001052     PPS low after: 100008   MSG high after: 350020  MSG low after: 427172$GPRMC,045124.000,A,3015.2541,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 24001052     PPS low after: 100008   MSG high after: 350024  MSG low after: 427168$GPRMC,045125.000,A,3015.2551,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 25001056     PPS low after: 100000   MSG high after: 350016  MSG low after: 427168$GPRMC,045126.000,A,3015.2561,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 26001052     PPS low after: 100008   MSG high after: 350024  MSG low after: 427160$GPRMC,045127.000,A,3015.2570,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 27001056     PPS low after: 100000   MSG high after: 350020  MSG low after: 427156$GPRMC,045128.000,A,3015.2580,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 28001060     PPS low after: 100008   MSG high after: 350004  MSG low after: 427144$GPRMC,045129.000,A,3015.2590,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 29001056     PPS low after: 100000   MSG high after: 350020  MSG low after: 427156$GPRMC,045130.000,A,3015.2600,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 30001056     PPS low after: 100004   MSG high after: 350020  MSG low after: 427164$GPRMC,045131.000,A,3015.2609,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 31001056     PPS low after: 100008   MSG high after: 350004  MSG low after: 427148$GPRMC,045132.000,A,3015.2619,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 32001056     PPS low after: 99996    MSG high after: 350012  MSG low after: 427164$GPRMC,045133.000,A,3015.2629,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 33001056     PPS low after: 100008   MSG high after: 350020  MSG low after: 427164$GPRMC,045134.000,A,3015.2639,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 34001056     PPS low after: 100000   MSG high after: 350016  MSG low after: 427164$GPRMC,045135.000,A,3015.2648,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 35001060     PPS low after: 100004   MSG high after: 350000  MSG low after: 427144$GPRMC,045136.000,A,3015.2658,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 36001060     PPS low after: 100000   MSG high after: 350004  MSG low after: 427148$GPRMC,045137.000,A,3015.2668,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 37001060     PPS low after: 100004   MSG high after: 350004  MSG low after: 427144$GPRMC,045138.000,A,3015.2678,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 38001064     PPS low after: 100004   MSG high after: 350004  MSG low after: 427144$GPRMC,045139.000,A,3015.2687,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 39001060     PPS low after: 100008   MSG high after: 350004  MSG low after: 427152$GPRMC,045140.000,A,3015.2697,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 40001052     PPS low after: 100008   MSG high after: 350024  MSG low after: 427160$GPRMC,045141.000,A,3015.2707,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 41001052     PPS low after: 100000   MSG high after: 350016  MSG low after: 427168$GPRMC,045142.000,A,3015.2717,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 42001060     PPS low after: 100004   MSG high after: 350004  MSG low after: 427148$GPRMC,045143.000,A,3015.2727,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 43001056     PPS low after: 100000   MSG high after: 350020  MSG low after: 427164$GPRMC,045144.000,A,3015.2736,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 44001052     PPS low after: 100004   MSG high after: 350020  MSG low after: 427164$GPRMC,045145.000,A,3015.2746,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 45001064     PPS low after: 100004   MSG high after: 350004  MSG low after: 427144$GPRMC,045146.000,A,3015.2756,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 46001052     PPS low after: 100004   MSG high after: 350020  MSG low after: 427172$GPRMC,045147.000,A,3015.2766,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 47001056     PPS low after: 100004   MSG high after: 350020  MSG low after: 427164$GPRMC,045148.000,A,3015.2775,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 48001056     PPS low after: 100000   MSG high after: 350016  MSG low after: 427164$GPRMC,045149.000,A,3015.2785,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 49001060     PPS low after: 100004   MSG high after: 350004  MSG low after: 427144$GPRMC,045150.000,A,3015.2795,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 50001052     PPS low after: 100000   MSG high after: 350016  MSG low after: 427160$GPRMC,045151.000,A,3015.2805,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 51001060     PPS low after: 100004   MSG high after: 350004  MSG low after: 427148$GPRMC,045152.000,A,3015.2814,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 52001056     PPS low after: 100000   MSG high after: 350020  MSG low after: 427164$GPRMC,045153.000,A,3015.2824,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 53001064     PPS low after: 100004   MSG high after: 350000  MSG low after: 427144$GPRMC,045154.000,A,3015.2834,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 54001056     PPS low after: 100004   MSG high after: 350020  MSG low after: 427164$GPRMC,045155.000,A,3015.2844,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 55001060     PPS low after: 100004   MSG high after: 350020  MSG low after: 427172$GPRMC,045156.000,A,3015.2854,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 56001068     PPS low after: 100004   MSG high after: 350000  MSG low after: 427144$GPRMC,045157.000,A,3015.2863,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 57001060     PPS low after: 99996    MSG high after: 350012  MSG low after: 427160$GPRMC,045158.000,A,3015.2873,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 58001064     PPS low after: 100004   MSG high after: 350004  MSG low after: 427148$GPRMC,045159.000,A,3015.2883,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 59001056     PPS low after: 100000   MSG high after: 350024  MSG low after: 427132$GPRMC,045200.000,A,3015.2893,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 60001060     PPS low after: 100004   MSG high after: 350020  MSG low after: 427124$GPRMC,045201.000,A,3015.2902,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 61001064     PPS low after: 100008   MSG high after: 350004  MSG low after: 427116$GPRMC,045202.000,A,3015.2912,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 62001060     PPS low after: 100008   MSG high after: 350008  MSG low after: 427124$GPRMC,045203.000,A,3015.2922,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 63001060     PPS low after: 100012   MSG high after: 350008  MSG low after: 427120$GPRMC,045204.000,A,3015.2932,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 64001052     PPS low after: 100000   MSG high after: 350020  MSG low after: 427136$GPRMC,045205.000,A,3015.2941,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 65001060     PPS low after: 100008   MSG high after: 350004  MSG low after: 427120$GPRMC,045206.000,A,3015.2951,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 66001064     PPS low after: 100000   MSG high after: 349996  MSG low after: 427116$GPRMC,045207.000,A,3015.2961,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 67001060     PPS low after: 100004   MSG high after: 350004  MSG low after: 427120$GPRMC,045208.000,A,3015.2971,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 68001060     PPS low after: 100000   MSG high after: 350004  MSG low after: 427112$GPRMC,045209.000,A,3015.2980,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 69001052     PPS low after: 100004   MSG high after: 350020  MSG low after: 427164$GPRMC,045210.000,A,3015.2990,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 70001064     PPS low after: 100004   MSG high after: 350004  MSG low after: 427136$GPRMC,045211.000,A,3015.3000,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 71001060     PPS low after: 100004   MSG high after: 350004  MSG low after: 427148$GPRMC,045212.000,A,3015.3010,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 72001064     PPS low after: 100004   MSG high after: 350004  MSG low after: 427144$GPRMC,045213.000,A,3015.3020,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 73001056     PPS low after: 100000   MSG high after: 350016  MSG low after: 427164$GPRMC,045214.000,A,3015.3029,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 74001064     PPS low after: 99988    MSG high after: 350004  MSG low after: 427148$GPRMC,045215.000,A,3015.3039,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 75001052     PPS low after: 100000   MSG high after: 350020  MSG low after: 427164$GPRMC,045216.000,A,3015.3049,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 76001060     PPS low after: 100004   MSG high after: 350000  MSG low after: 427144$GPRMC,045217.000,A,3015.3059,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 77001056     PPS low after: 100008   MSG high after: 350004  MSG low after: 427148$GPRMC,045218.000,A,3015.3068,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 78001060     PPS low after: 100008   MSG high after: 350004  MSG low after: 427152$GPRMC,045219.000,A,3015.3078,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 79001052     PPS low after: 100008   MSG high after: 350020  MSG low after: 427164$GPRMC,045220.000,A,3015.3088,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 80001052     PPS low after: 100000   MSG high after: 350016  MSG low after: 427164$GPRMC,045221.000,A,3015.3098,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 81001056     PPS low after: 100008   MSG high after: 350020  MSG low after: 427164$GPRMC,045222.000,A,3015.3107,N,09749.2872,W,0.67,161.46,030913,,,A*7C
PPS at: 82001060     PPS low after: 100000   MSG high after: 350016  MSG low after: 427172$GPRMC,045223.000,A,3015.3117,N,09749.2872,W,0.67,161.46,030913,,,A*7C

A number of hints to check, though I can only throw vague observations on the error (EDIT: some hints only make sense with an older version of the question):

You set the SoftwareSerial to pin 7 for RX and pin 6 for TX, but the TX LED of the board is connected to the hardware UART, which is used by Serial. So the TX LED reacts to your debug messages sent via Serial.print() to the PC. The TX and RX pins on your Arduino board are always connected to the hardware UART, which always is managed by Serial and cannot be claimed by SoftwareSerial.
The "SoftwareSerial TX pin" of your Arduino (note: the TX pin you set via SoftwareSerial mySerial(7, 6);) needs to be connected to RX of the GPS module. Remember: If you transmit something via the transmit line of one device, it needs to be received by the receive line of the other device (T stands for transmit, R for receive, and X for that you must cross the lines). (This hint ignores that you've got a RS232 shield, I realized that only later.)
The docs state that your gprmc record is accepted in either hhmmss or hhmmss.s format. Yet you send a string with three places after the dot. I'm not sure whether I misinterpret something here.
If you just add 1 to gprmc every second, you'll end up sending the equivalent of "18 hours, 17 minutes, 61 seconds" after 40 seconds runtime (because the format is expected to be hhmmss), which might or might not confuse the GPS chip.
Is 9600 baud the correct speed for the GPS receiver? Somewhere in the docs should be a hint about that (I'd expect at least 115200 on devices that are less than 20 years old...).
The pulse line might follow negative logic, i.e. it normally is HIGH and need to be pulled LOW for the pulse. Check the data sheet whether a LOW pulse is needed, in which case you need to swap HIGH and LOW on the pulse line.
What is pin 12 (msg_sent) and why do you need it? Its not mentioned in the schematics. I can only glean that it might signal your RS232 shield that the message has been sent to the RS232 shield and the RS232 UART now may empty its buffer, i.e. actually send the message over the wire to the GPS chip. If this is indeed the case, you signal the RS232 shield that the message has been sent before you actually send the message.
Try it without the RS232 shield? RS232 is just a specification of "serial protocol" that allows for voltage levels of up to 25V plus a few extra signal lines. By the schematic and wiring, I see that the GPS chip does not use any extra lines and expects a signal level of 5V. With SoftwareSerial, you already output "serial protocol" at 5V signal level from your GPIO pins. From afar, it looks like the RS232 shield inserts more potential points of failure into the communication. Have you got a Serial-to-USB converter to actually check the output of your RS232 shield?
Your delimiters are not sent. Hex 0D0A is simply CRLF, or "carriage return, line feed" or "the standard line break characters in plain text files on DOS and Windows". Which means: The last mySerial.print() would need to be changed to mySerial.println(), which is just like mySerial.print(), only that it adds a line break at the end.
Maybe it works if you connect the pin labeled GPS_RXD_CNT in the schematics with pin 6 of your Arduino while removing any own wiring from TX and RX of your Arduino.
Floats do not "store 3 decimal places after the decimal point", they store the significant binary places plus the position of the point. This means: if the number of significant places is big, you lose precision at the end. Converted to decimal, a 32-bit float only has a precision of 6-7 decimal places. A number like (decimal) 100000.01 would lose its last 1, yielding 100000.0; this also is true for 1000000.1 (=1000000.0), 10000001000.0 (=10000000000.0) and 0.000010000001 (=0.00001). So if you add 0.1 to 1234567.0, you'll end up with 1234567.0 -- or in the extreme: 1234567000000.0 + 11111.0 = 1234567000000.0. (Numbers off the top of my head, reality might introduce some rounding between decimal and binary representation, this is just to get the point across -- also, your decimal output will not show this exactly, because a binary representation only is precise for fractions of powers of two after the point).

Also, you might want to add some Serial.println() calls for each of your digitalWrite() calls, outputting something like "pin 11 (PPS) is now HIGH". Then use the Serial Monitor of Arduino IDE (don't forget to set its baud rate to 9600) to check whether the protocol looks right.

Thanks for your hints. I'm trying to answer them:

Indeed i set the softwareSerial to Pin7 & 6. This is because I have the RS-232 shield mounted on top of the Arduino, which executes the communication. It has it's own TX LED that's flasching, when data is sent via RS-232. So this should be right

Maybe my schematic was a bit confusing. i connected the Arduino Tx to the Lidar RX, so this should also work (i tested the connection). I will update my  schematic.

You are right. However, in an other part of the document, the say

"The GPRMC record may be configured for HHMMSS, HHMMSS.s, HHMMSS.ss, and HHMMSS.sss formats." So this should be right as well...

Yess nice input! I changed this and will edit my question. However, it still doesnt work :S

@MarayJay "may be configured for" may mean that you'll have to tell the GPS chip the exact format before using it. Also, I'm not sure whether you actually need the RS232 shield. Maybe you can just directly wire the Arduino pin 6 to the GPS board.

The manual of the LiDAR says that it expects RS-232 communication (Higher voltage). But honestly, at this point I'm not sure anymore. I just need it to work

@MarayJay Added more hints to check ^^

@MarayJay Have you been successful yet? :)

thank you for all your hints and support! :O Unfortunately I ran out of time...I had to present a working system today, and had to invest my time in other things, since this is only a very small part of my project. now the deadline is over and after several night shifts, I honestly don't have the energy to persue this any further. But if I or anyone from our lab finds a way, I will let you know! :)


text:
HTTP parsing with authentication in Arduino + ethernet shield
i am trying to parse a page from the route by using Arduino + Ethernet shield. before Arduino testing. I tested my code via python as it shows below. from this code i can get the data as i wish where we need authenticate user name and pass word to access to the router, as you see, here ( admin , admin) in the same time i have to used output variable to get only the data required. Python code is does it.
Python code:
My_url = "http://192.168.8.1/update.cgi"
r = requests.post (My_url, auth=('admin', 'admin'),data = 'output=netdev' )
print(r.status_code)
print(r.headers['content-type'])
print(r.encoding)
print(r.text)

The output is:
200
text/javascript
ISO-8859-1
netdev = {
 'WIRED':{rx:0x84154,tx:0x5a0cba}
,'BRIDGE':{rx:0x7e680,tx:0x59d98a}
,'WIRELESS0':{rx:0x0,tx:0x0}
,'WIRELESS1':{rx:0x0,tx:0x0}
}

Now i am trying to do that by using Arduino + Ethernet shield and i would like print the output on the serial port as it is showing below. Here the router is server and the Arduino is client.
My problem is the POST request with the authentication, How I can do it ( POST with authentication + 'output=netdev' like in python code ). Please any idea .. Many thanks in advanced
Arduino code :
#include <Ethernet.h>
#include <SPI.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
IPAddress server(192,168,8,1);  // numeric IP for Google (no DNS)
//char server[] = "jsonplaceholder.typicode.com";    // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 8, 100);
IPAddress myDns(   8, 8, 8, 8);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
      while (true) {
        delay(1); // do nothing, no point running without Ethernet hardware
      }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip, myDns);
  } else {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  }
  delay(1000);
  Serial.println("connecting...");

  if (client.connect(server, 80)) {
    Serial.print("connected to ");
    Serial.println(client.remoteIP());
    // Make a HTTP request:

    client.println("POST /update.cgi HTTP/1.0");
    client.println("Host: 192.168.8.1");
    client.println("Connection: close");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  //if (client.available()) {
  while (client.available()) {
    char c = client.read();
    Serial.print(c);

  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }

}

Arduino output
Initialize Ethernet with DHCP:
  DHCP assigned IP 192.168.8.107
connecting...
connected to 192.168.8.1
HTTP/1.0 401 Unauthorized
Server: httpd
Date: Sat, 01 Jan 2011 00:27:00 GMT
WWW-Authenticate: Basic realm="DR3800"
Content-Type: text/html
Connection: close

<TITLE>401 Unauthorized</TITLE>

401 Unauthorized

Authorization required.

disconnecting.

Thank you Dougie for your anser. I used it , please you can see it in my code below where i used this library it gives no error for GET request , but when i use it ti POST request it gives same authentication problem as you see . where the POST request is important to get the data from .cgi page . Maybe i use that in wrong way .. any advice ? thanks
void loop() {
  Serial.println("making GET request with HTTP basic authentication");
  String contentType = "update.cgi";
  String postData = "output=netdev";

  client.beginRequest();
  client.get("/"+contentType);
  client.sendBasicAuth("admin", "admin"); // send the username and password for authentication
  client.endRequest();

   // read the status code and body of the response
  int statusCode = client.responseStatusCode();
  String response = client.responseBody();

  Serial.print("Status code: ");
  Serial.println(statusCode);
  Serial.print("Response: ");
  Serial.println(response);

  Serial.println("Wait five seconds");
  delay(5000);
}

The output is ok
making GET request with HTTP basic authentication
Status code: 200
Response:
Wait five seconds

But for POST as follows :
void loop() {
  Serial.println("making GET request with HTTP basic authentication");
  String contentType = "update.cgi";
  String postData = "output=netdev";

  client.beginRequest();
  client.post("/",contentType , postData);
  client.sendBasicAuth("admin", "admin"); // send the username and password for authentication
  client.endRequest();

   // read the status code and body of the response
  int statusCode = client.responseStatusCode();
  String response = client.responseBody();

  Serial.print("Status code: ");
  Serial.println(statusCode);
  Serial.print("Response: ");
  Serial.println(response);

  Serial.println("Wait five seconds");
  delay(5000);
}

the output is :
making GET request with HTTP basic authentication
Status code: 401
Response: <TITLE>401 Unauthorized</TITLE>

401 Unauthorized

Authorization required.

Wait five seconds

Rather than trying to send your own GET/POST request by hand coding it, use https://github.com/arduino-libraries/ArduinoHttpClient which does it all for you.

Use the sendBasicAuth method to send auth. data.

Thank you for your answer. I used it , please you can see it in my code [    String contentType = "update.cgi";
String postData = "output=netdev";
client.beginRequest();
client.post("/",contentType , postData);
client.sendBasicAuth("admin", "admin"); // send the username and password for authentication
client.endRequest(); ] and stil i have problem with POST methode. any idea

Please vote up my answer and mark it as accepted.


text:
Using millis() to create a timed sequence of events
I was hoping anyone could help me with my problem.
I am trying to play a sequence of tones without using delay. So I am relying on millis(). However I have not been successful yet and after reading multiple tutorials about using millis(), I could not find one that covers sequencies of events.
What I am trying to do is the following:

Play a tone1 for 1 s
After 1 second (duration which tone 1 is played) play tone 2
After 1 second (duration which tone 2 is played) play tone 3
After 1 second (duration which tone 3 is played) play tone 4

With the current code I have, everything seems to be played at the same time and not really considering my IF statements.
Code:

#include "pitches.h"

int notes[]={
NOTE_B1,
NOTE_C2,
NOTE_CS2,
NOTE_D2,
NOTE_DS2,
NOTE_E2,
NOTE_F2,
NOTE_FS2,
NOTE_G2,
NOTE_GS2,
NOTE_A2,
NOTE_AS2,
NOTE_B2,
NOTE_C3,
NOTE_CS3,
NOTE_D3,
NOTE_DS3,
NOTE_E3,
NOTE_F3,
NOTE_FS3,
NOTE_G3,
NOTE_GS3,
NOTE_A3,
NOTE_AS3,
NOTE_B3,
NOTE_C4,
NOTE_CS4,
NOTE_D4,
NOTE_DS4,
NOTE_E4,
NOTE_F4,
NOTE_FS4,
NOTE_G4,
NOTE_GS4,
NOTE_A4,
NOTE_AS4,
NOTE_B4,
NOTE_C5,
NOTE_CS5,
NOTE_D5,
NOTE_DS5,
NOTE_E5,
NOTE_F5,
NOTE_FS5,
NOTE_G5,
NOTE_GS5,
NOTE_A5,
NOTE_AS5,
NOTE_B5,
NOTE_C6,
NOTE_CS6,
NOTE_D6,
NOTE_DS6,
NOTE_E6,
NOTE_F6,
NOTE_FS6,
NOTE_G6,
NOTE_GS6,
NOTE_A6,
NOTE_AS6,
NOTE_B6,
NOTE_C7,
NOTE_CS7,
NOTE_D7,
NOTE_DS7,
NOTE_E7,
NOTE_F7,
NOTE_FS7,
NOTE_G7,
NOTE_GS7,
NOTE_A7,
NOTE_AS7,
NOTE_B7,
NOTE_C8,
NOTE_CS8,
NOTE_D8,
NOTE_DS8
};

int speakerPin = 3;

 #define N_BUTTONS 8

int button_pins[N_BUTTONS] = {6, 7, 8, 9, 10, 11, 12, 13}; // Putting button_pins into an array

int Pitches[N_BUTTONS] = {0}; // Define array to hold the pitch. Setting it to 0.

long Durations[N_BUTTONS]; // Define array to hold the duration of the note. Setting it to 500.

unsigned long startMillis;
unsigned long startMillis_2;
unsigned long startMillis_3;
unsigned long startMillis_4;
unsigned long currentMillis;
unsigned long period = 1000;

void setup() {

Serial.begin(9600);

for(int pin : button_pins) pinMode(pin, INPUT); // Define the input pins for button_pins

startMillis = millis();

}

void loop() {

for (int button=0; button<N_BUTTONS ; button++){
  if(digitalRead(button_pins[button])){
    Pitches[button] = analogRead(A0)/13;   // As we have 77 pitches we divide the max Potentiometer value by 77. This equals 13.
    Durations[button] = analogRead(A1)*4;
   }
  }
////////////////////OUTPUT CODE////////////////////Sound generation code /////////////////////////////////

unsigned long currentMillis = millis(); // Gets the current time

if (currentMillis - startMillis >= period)  // Start event after 1 second
  {
  tone(speakerPin, notes[Pitches[0]], period);
  Serial.print("pitch1= ");
  Serial.println(Pitches[0]);
  Serial.print("duration1= ");
  Serial.println(period);
  Serial.print("millis = ");
  Serial.println(currentMillis);
  startMillis_2 = currentMillis;   // Saves the current time into the variable
  Serial.print("startMillis_2 = ");
  Serial.println(startMillis_2);
  }

if (currentMillis - startMillis_2 >= period)
  {
  tone(speakerPin, notes[Pitches[1]], period);
  Serial.print("pitch2= ");
  Serial.println(Pitches[1]);
  Serial.print("duration2= ");
  Serial.println(period);
  startMillis_3 = currentMillis;
  Serial.print("millis = ");
  Serial.println(currentMillis);
  Serial.print("startMillis_3 = ");
  Serial.println(startMillis_3);
  }

if (currentMillis - startMillis_3>= period)
  {
  tone(speakerPin, notes[Pitches[2]], period);
  Serial.print("pitch3= ");
  Serial.println(Pitches[2]);
  Serial.print("duration3= ");
  Serial.println(period);
  startMillis_4 = currentMillis;
  Serial.print("millis = ");
  Serial.println(currentMillis);
  Serial.print("startMillis_4 = ");
  Serial.println(startMillis_4);
  }

unsigned long startMillis_4;

if (currentMillis - startMillis_4 >= period)
  {
  tone(speakerPin, notes[Pitches[3]], period);
  Serial.print("pitch4= ");
  Serial.println(Pitches[3]);
  Serial.print("duration4= ");
  Serial.println(period);
  startMillis = currentMillis;
  Serial.print("millis = ");
  Serial.println(currentMillis);
  Serial.print("startMillis = ");
  Serial.println(startMillis);
  }

}

I have managed to get my code running on delay. It is working but I am very limited on what I can accomplish if I want more.
I have read through all answers and comments but was still unable to get a millis() solution since my main problem was how to get tone 2 started and so on. I can get the first tone to play on a loop and correct intervals, but I am not understanding how to trigger the start of tone 2.
Here is my code with delay. If anyone has can guide me to use millis() specially to trigger the start the tone 2, it would be very helpful.
EDIT. New Code:
#include "pitches.h"

int notes[]={
0,
NOTE_B1,
NOTE_C2,
NOTE_CS2,
NOTE_D2,
NOTE_DS2,
NOTE_E2,
NOTE_F2,
NOTE_FS2,
NOTE_G2,
NOTE_GS2,
NOTE_A2,
NOTE_AS2,
NOTE_B2,
NOTE_C3,
NOTE_CS3,
NOTE_D3,
NOTE_DS3,
NOTE_E3,
NOTE_F3,
NOTE_FS3,
NOTE_G3,
NOTE_GS3,
NOTE_A3,
NOTE_AS3,
NOTE_B3,
NOTE_C4,
NOTE_CS4,
NOTE_D4,
NOTE_DS4,
NOTE_E4,
NOTE_F4,
NOTE_FS4,
NOTE_G4,
NOTE_GS4,
NOTE_A4,
NOTE_AS4,
NOTE_B4,
NOTE_C5,
NOTE_CS5,
NOTE_D5,
NOTE_DS5,
NOTE_E5,
NOTE_F5,
NOTE_FS5,
NOTE_G5,
NOTE_GS5,
NOTE_A5,
NOTE_AS5,
NOTE_B5,
NOTE_C6,
NOTE_CS6,
NOTE_D6,
NOTE_DS6,
NOTE_E6,
NOTE_F6,
NOTE_FS6,
NOTE_G6,
NOTE_GS6,
NOTE_A6,
NOTE_AS6,
NOTE_B6,
NOTE_C7,
NOTE_CS7,
NOTE_D7,
NOTE_DS7,
NOTE_E7,
NOTE_F7,
NOTE_FS7,
NOTE_G7,
NOTE_GS7,
NOTE_A7,
NOTE_AS7,
NOTE_B7,
NOTE_C8,
NOTE_CS8,
NOTE_D8,
NOTE_DS8
};

int speakerPin = 3;

#define N_BUTTONS 8

// Input variables definitions

int button_pins[N_BUTTONS] = {6, 7, 8, 9, 10, 11, 12, 13}; // Putting button_pins into an array

int Pitches[N_BUTTONS] = {0}; // Define array to hold the pitch. Setting it to 0.

long Durations[N_BUTTONS]; // Define array to hold the duration of the note. Setting it to 500.

void setup() {

Serial.begin(9600);

for(int pin : button_pins) pinMode(pin, INPUT); // Define the input pins for button_pins

}

void loop() {
int tempo = analogRead(A2);
for (int button=0; button<N_BUTTONS ; button++){
  if(digitalRead(button_pins[button])){
    Pitches[button] = analogRead(A0)/13;   // As we have 78 pitches we divide the max Potentiometer value by 77. This equals 13.
    Durations[button] = (analogRead(A1)*4) + tempo;
   }
  }
////////////////////OUTPUT CODE////////////////////Sound generation code /////////////////////////////////
  for (int button=0; button <N_BUTTONS ; button++){
  tone(speakerPin, notes[Pitches[button]], Durations[button]);
  delay(tempo);
  Serial.print("Pitch");
  Serial.print(button);
  Serial.print(" = ");
  Serial.println(Pitches[button]);
  Serial.print("Duration");
  Serial.print(button);
  Serial.print(" = ");
  Serial.println(Durations[button]);
  Serial.println(tempo);
  }
}

take a close look at the if statements

your description of sequence of events is convoluted ... it is simply Play a tone1 for 1 s,  Play a tone2 for 1 s, Play a tone3 for 1 s, Play a tone4 for 1 s

I am still very new at this. It would be easier to explain what I want like this: Play tone1 for 1s, after finishing playing start play tone 2 for 1s.... and so on. I still don't fully know how to use if statements.

the if statement is fairly simple ... look at the expression inside the brackets () ... if that expresdion is true, then execute the commands that are inside the curly braces {}

You are overcomplicating the program. There is no point in remembering
when each of the notes started. You just have to remember:

what note is currently playing
when you started playing this note

Then the logic of loop() becomes simply: “if we are done with the
current note, then start playing the next one.” In code:
Edit: Changed the code to include your button-scanning loop.
int current_button;
uint32_t note_started;

void loop() {
    // Adjust the notes on button presses.
    for (int button = 0; button < N_BUTTONS; button++) {
        if (digitalRead(button_pins[button])) {
            // As we have 78 pitches we divide the max Potentiometer
            // value by 77. This equals 13.
            Pitches[button] = analogRead(A0)/13;
            Durations[button] = analogRead(A1)*4;
        }
    }

    // Are we done with the current note?
    uint32_t now = millis();
    int tempo = analogRead(A2);
    if (now - note_started >= Durations[current_button] + tempo) {

        // Then move to the next note.
        ++current_button;

        // Finished the tune?
        if (current_button == N_BUTTONS) {
            current_button = 0;  // then restart from the beginning
        }

        // Play the note.
        tone(speakerPin,
                Pitches[current_button], Durations[current_button]);

        // Take note of when this started.
        note_started = now;
    }
}

Thank you for your comment. I have taken some time to understand your code but I cannot understand how to adapt to my code. My pitches array is a variable dependent on a button and potentiometer. Each pitch played is selected my user input. Note duration also is an input variable with potentiometer and button. Take a look at my code below. I have provided the one using delays. Thank you.

Thank you. Your code works as intended. although I would need to adjust some things like how to control the tempo, but overall this is a great solution.

Your code falls through (skips over) the first “if” statement in the output code because its time period has not yet passed.
It then starts to use startMillis_2, which is not yet initialized (and may be any value), in the next “if”.
Initialization of startMillis_2 only happens inside the first “if” statement but that code has not yet been executed.
The same goes for startMillis_3 and 4.
But I think there’s something more fundamentally wrong with your code. You execute all “if” statements inside of a loop that is continuously repeated. There is no sequence. You have to make sure that tone 2 can only be started after tone 1, etcetera.

That is the point I am not able. How to make sure tone 2 only starts after tone1 finishes. I can achieve this goal with delay, but I will be very limited on my code. Right now my code is doing exactly what I wanted except the delays interfere with my potentiometers inputs. I have updated my code on my post.


text:
Problem connecting Arduino and ADC AD7606
Question is about using ADC AD7606 paired with Arduino (Arduino Mega).
I can’t reach the stated speed of this bundle, the question is also whether it is possible or not. ADC output mode is 16-bit parallel. The physical connection corresponds to that in the examples using Mitov's Visuino. The sensor that sends data to the ADC is AC102-1a, connected via the recommended power supply circuit.
Compiled program code (provided below) that outputs the result of receiving data from one ADC port to the serial port monitor (disabled during speed testing, so as not to slow down the speed of output to the port). Also it has the ability to estimate the speed of the program, as a number of passes of the loop cycle per second.
There were some ways to increase the speed of the Arduino, replacing the standard functions digitalRead, digitalWrite, etc.
The speed of the program, without taking into account the full connection with the ADC (when disabling the waiting BUSY) reaches 150,000+ iterations per second, but if we providing full communication with the ADC (according to the scheme found in the examples of programs with this ADC – the sequence of setting levels on pins READ, BUSY, RESET, etc.), the speed falls to 1700 iterations per second.
This speed is achieved when over-sampling is enabled. If you turn it off, the speed becomes 40000 iterations per second, while increasing the amount of noise in the received signal.
The question is, where is the error in the binding of the ADC command sequence, why is the speed so low, and whether it is possible to achieve an increase in the speed of work, ideally reaching the stated 200k operations per second for this ADC.

#define RESET_PIN 4
byte pin4mask = (1 << 5);
#define RESET_SET_OUTPUT      DDRG  |=  pin4mask // Pin 4 OUTPUT
#define RESET_SET_INPUT       DDRG  &= ~pin4mask // Pin 4 INPUT
#define RESET_WRITE_HIGH      PORTG |=  pin4mask // Pin 4 to HIGH
#define RESET_WRITE_LOW       PORTG &= ~pin4mask // Pin 4 to LOW

#define CHIP_SELECT_PIN 3
byte pin3mask = (1 << 5);
#define CHIP_SELECT_SET_OUTPUT      DDRE  |=  pin3mask // Pin 3 OUTPUT
#define CHIP_SELECT_SET_INPUT       DDRE  &= ~pin3mask // Pin 3 INPUT
#define CHIP_SELECT_WRITE_HIGH      PORTE |=  pin3mask // Pin 3 to HIGH
#define CHIP_SELECT_WRITE_LOW       PORTE &= ~pin3mask // Pin 3 to LOW

#define READ_PIN 2
byte pin2mask = (1 << 4);
#define READ_SET_OUTPUT      DDRE  |=  pin2mask // Pin 2 OUTPUT
#define READ_SET_INPUT       DDRE  &= ~pin2mask // Pin 2 INPUT
#define READ_WRITE_HIGH      PORTE |=  pin2mask // Pin 2 to HIGH
#define READ_WRITE_LOW       PORTE &= ~pin2mask // Pin 2 to LOW

#define START_PIN 6
byte pin6mask = (1 << 3);
#define START_SET_OUTPUT      DDRH  |=  pin6mask // Pin 6 OUTPUT
#define START_SET_INPUT       DDRH  &= ~pin6mask // Pin 6 INPUT
#define START_WRITE_HIGH      PORTH |=  pin6mask // Pin 6 to HIGH
#define START_WRITE_LOW       PORTH &= ~pin6mask // Pin 6 to LOW

#define BUSY_PIN 7
byte pin7mask = (1 << 4);
#define BUSY_SET_OUTPUT      DDRH  |=  pin7mask // Pin 7 OUTPUT
#define BUSY_SET_INPUT       DDRH  &= ~pin7mask // Pin 7 INPUT
#define BUSY_WRITE_HIGH      PORTH |=  pin7mask // Pin 7 to HIGH
#define BUSY_WRITE_LOW       PORTH &= ~pin7mask // Pin 7 to LOW
#define BUSY_READ            bitRead(PINH, 4)

//PIN 14
byte pin14mask = (1 << 1);
#define DB1_SET_INPUT       DDRJ  &= ~pin14mask // Pin D14 to INPUT
#define DB1_READ            bitRead(PINJ, 1)

//PIN 15
byte pin15mask = (1 << 0);
#define DB2_SET_INPUT       DDRJ  &= ~pin15mask // Pin D15 to INPUT
#define DB2_READ            bitRead(PINJ, 0)

//PIN 16
byte pin16mask = (1 << 1);
#define DB3_SET_INPUT       DDRH  &= ~pin16mask // Pin D16 to INPUT
#define DB3_READ            bitRead(PINH, 1)

//PIN 17
byte pin17mask = (1 << 0);
#define DB4_SET_INPUT       DDRH  &= ~pin17mask // Pin D17 to INPUT
#define DB4_READ            bitRead(PINH, 0)

//PIN 18
byte pin18mask = (1 << 3);
#define DB5_SET_INPUT       DDRD  &= ~pin18mask // Pin D18 to INPUT
#define DB5_READ            bitRead(PIND, 3)

//PIN 19
byte pin19mask = (1 << 2);
#define DB6_SET_INPUT       DDRD  &= ~pin19mask // Pin D19 to INPUT
#define DB6_READ            bitRead(PIND, 2)

//PIN 20
byte pin20mask = (1 << 1);
#define DB7_SET_INPUT       DDRD  &= ~pin20mask // Pin D20 to INPUT
#define DB7_READ            bitRead(PIND, 1)

//PIN 21
byte pin21mask = (1 << 0);
#define DB8_SET_INPUT       DDRD  &= ~pin21mask // Pin D21 to INPUT
#define DB8_READ            bitRead(PIND, 0)

//PIN 22
byte pin22mask = (1 << 0);
#define DB9_SET_INPUT       DDRA  &= ~pin22mask // Pin D22 to INPUT
#define DB9_READ            bitRead(PINA, 0)

//PIN 23
byte pin23mask = (1 << 1);
#define DB10_SET_INPUT       DDRA  &= ~pin23mask // Pin D23 to INPUT
#define DB10_READ            bitRead(PINA, 1)

//PIN 24
byte pin24mask = (1 << 2);
#define DB11_SET_INPUT       DDRA  &= ~pin24mask // Pin D24 to INPUT
#define DB11_READ            bitRead(PINA, 2)

//PIN 25
byte pin25mask = (1 << 3);
#define DB12_SET_INPUT       DDRA  &= ~pin25mask // Pin D25 to INPUT
#define DB12_READ            bitRead(PINA, 3)

//PIN 26
byte pin26mask = (1 << 4);
#define DB13_SET_INPUT       DDRA  &= ~pin26mask // Pin D26 to INPUT
#define DB13_READ            bitRead(PINA, 4)

//PIN 27
byte pin27mask = (1 << 5);
#define DB14_SET_INPUT       DDRA  &= ~pin27mask // Устанавливаем пин D27 в режим INPUT
#define DB14_READ            bitRead(PINA, 5)

//PIN 28
byte pin28mask = (1 << 6);
#define DB15_SET_INPUT       DDRA  &= ~pin28mask // Устанавливаем пин D28 в режим INPUT
#define DB15_READ            bitRead(PINA, 6)

//PIN 29
byte pin29mask = (1 << 7);
#define DB16_SET_INPUT       DDRA  &= ~pin29mask // Устанавливаем пин D29 в режим INPUT
#define DB16_READ            bitRead(PINA, 7)

#define OS2 10
#define OS1 9
#define OS0 8
#define RANGE_PIN 11

const long interval = 1000;

unsigned long previousMillis = 0;
unsigned long counter01 = 0;

void setup() {
  Serial.begin(9600);
  DB1_SET_INPUT;
  DB2_SET_INPUT;
  DB3_SET_INPUT;
  DB4_SET_INPUT;
  DB5_SET_INPUT;
  DB6_SET_INPUT;
  DB7_SET_INPUT;
  DB8_SET_INPUT;
  DB9_SET_INPUT;
  DB10_SET_INPUT;
  DB11_SET_INPUT;
  DB12_SET_INPUT;
  DB13_SET_INPUT;
  DB14_SET_INPUT;
  DB15_SET_INPUT;
  DB16_SET_INPUT;

  RESET_SET_OUTPUT;
  CHIP_SELECT_SET_OUTPUT;
  READ_SET_OUTPUT;
  START_SET_OUTPUT;
  pinMode (RANGE_PIN, OUTPUT);
  BUSY_SET_INPUT;

  RESET_WRITE_HIGH;
  delayMicroseconds(10);
  RESET_WRITE_LOW;

  CHIP_SELECT_WRITE_HIGH;
  READ_WRITE_HIGH;
  START_WRITE_HIGH;

  //Setting Oversampling Pins to Zero.
  digitalWrite(OS2, HIGH);
  digitalWrite(OS1, HIGH);
  digitalWrite(OS0, HIGH);

  digitalWrite(RANGE_PIN, HIGH);
}

void loop() {

  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    Serial.println( counter01 );
    counter01 = 0;
  }
  counter01 = counter01 + 1;

  /////////////////

  RESET_WRITE_HIGH;
  delayMicroseconds(1);
  RESET_WRITE_LOW;
  START_WRITE_LOW;
  START_WRITE_HIGH;

  while (BUSY_READ != LOW);
  CHIP_SELECT_WRITE_LOW;

  for (int AChannel = 0; AChannel < 1; ++AChannel)
  {
    READ_WRITE_LOW;
    uint16_t AResult = 0;
    if(DB1_READ == HIGH)
    { AResult |= ( 1 << 0 );}
    if(DB2_READ == HIGH)
    { AResult |= ( 1 << 1 );}
    if(DB3_READ == HIGH)
    { AResult |= ( 1 << 2 );}
    if(DB4_READ == HIGH)
    { AResult |= ( 1 << 3 );}
    if(DB5_READ == HIGH)
    { AResult |= ( 1 << 4 );}
    if(DB6_READ == HIGH)
    { AResult |= ( 1 << 5 );}
    if(DB7_READ == HIGH)
    { AResult |= ( 1 << 6 );}
    if(DB8_READ == HIGH)
    { AResult |= ( 1 << 7 );}
    if(DB9_READ == HIGH)
    { AResult |= ( 1 << 8 );}
    if(DB10_READ == HIGH)
    { AResult |= ( 1 << 9 );}
    if(DB11_READ == HIGH)
    { AResult |= ( 1 << 10 );}
    if(DB12_READ == HIGH)
    { AResult |= ( 1 << 11 );}
    if(DB13_READ == HIGH)
    { AResult |= ( 1 << 12 );}
    if(DB14_READ == HIGH)
    { AResult |= ( 1 << 13 );}
    if(DB15_READ == HIGH)
    { AResult |= ( 1 << 14 );}
    if(DB16_READ == HIGH)
    { AResult |= ( 1 << 15 );}

    READ_WRITE_HIGH;

    float AValue = float( int16_t( AResult ));
    if ( ! AChannel )
    {
      //Serial.println( AValue );
    }
  }
  CHIP_SELECT_WRITE_HIGH;
}

there is a typo in the #define READ_WRITE_LOW line ... in what universe is your English bad?  certainly not in this one ... upvote

why don't you use PORTA and PORTC for the 16 bit data bus? .... then read bytes, instead of single bits

Your English is fine. upvote.

To debug cases like this, use an oscilloscope and watch the pins. I'm sure you will find that it is your software, the bit-wise reading, not the ADC.

Thank you all for your answers!
@jsotola Can you specify what the typo is? As far as I can see, this entry is made by analogy with other lines. Is there a wrong port or something?
About byte reading. Oh, I see, maybe i'll try to resolder byte pins to PORTA and PORTC. It also will increase the speed but it seems like the main problem is in some other part.

@VE7JRO Thanks :)

@thebusybee Thank you, I hope I'll find the problem in code too, nowadays is rather complicated to reach to a friend with oscilloscope in this quarantine :)

the typo was corrected ... it was a missing comment delimiter


text:
Get accelerometer values from BNO055 using adafruit's Unified Sensor Library
If I understand correctly using the Adafruit_Sensor one can extract information from the sensor specific information. These sensors are currently mentioned in the README. I am using the BNO055 for two things:

Orientation values (Heading, pitch, roll)
Linear Acceleration values

My code is similar to the Example mentioned Adafruit_BNO055's bunny
Code
I tried the following in my loop()
void loop() {
  // put your main code here, to run repeatedly:
  sensors_event_t event;
  bno.getEvent(&event);

  Serial.print(F("Orientation: "));
  Serial.print((float)event.orientation.x);
  Serial.print(F(" "));
  Serial.print((float)event.orientation.y);
  Serial.print(F(" "));
  Serial.print((float)event.orientation.z);
  Serial.println(F(""));

  Serial.print(F("Acceleration: "));
  Serial.print((float)event.acceleration.x);
  Serial.print(F(" "));
  Serial.print((float)event.acceleration.y);
  Serial.print(F(" "));
  Serial.print((float)event.acceleration.z);
  Serial.println(F(""));

  delay(BNO055_SAMPLERATE_DELAY_MS);
}

Created sensors_event_t event and used the orientation and acceleration parameters to obtain the orientation and acceleration values in x, y, z directions.
output
The orientation and accleration values are the same:
Orientation: 105.50 -20.56 -101.00
Acceleration: 105.50 -20.56 -101.00
Orientation: 97.81 -14.69 -119.56
Acceleration: 97.81 -14.69 -119.56
Orientation: 93.81 -10.94 -125.56
Acceleration: 93.81 -10.94 -125.56
Orientation: 94.44 -12.25 -122.56

I tried adding another event event1 in the loop() but I still get the same results
sensors_event_t event;
  bno.getEvent(&event);

  Serial.print(F("Orientation: "));
  Serial.print((float)event.orientation.x);
  Serial.print(F(" "));
  Serial.print((float)event.orientation.y);
  Serial.print(F(" "));
  Serial.print((float)event.orientation.z);
  Serial.println(F(""));

  sensors_event_t event1;
  bno.getEvent(&event1);
  Serial.print(F("Acceleration: "));
  Serial.print((float)event1.acceleration.x);
  Serial.print(F(" "));
  Serial.print((float)event1.acceleration.y);
  Serial.print(F(" "));
  Serial.print((float)event1.acceleration.z);
  Serial.println(F(""));

  delay(BNO055_SAMPLERATE_DELAY_MS);

Can't the BNO055 along with the Adafruit_Sensor library not provide the acceleration and orientation values as events or is the library used only to obtain orientation values from the BNO055?

does I2C scanner find it?

@Juraj yes I get addresses 0x28 and 0x68. Also I have an RTC connected to the I2C bus.

according to bno's datasheet 0x28 is the secondary address and hence it is detected.

Findings
If I use the same sensors_event_t in the code and use event.acceleration and event.orientation within the loop() and they provide me exactly the same values. I in fact get the same values for heading, pitch, roll and acceleration in x, y, z direction.
sensors_event_t event;
  bno.getEvent(&event);

  Serial.print(F("Orientation: "));
  Serial.print((float)event.orientation.heading);
  Serial.print(F(" "));
  Serial.print((float)event.orientation.pitch);
  Serial.print(F(" "));
  Serial.print((float)event.orientation.roll);
  Serial.println(F(""));
 Serial.print((float)event.acceleration.x); // same as roll
 Serial.println(F(""));
 Serial.print((float)event.acceleration.y); // same as pitch
 Serial.println(F(""));
 Serial.print((float)event.acceleration.z); // same as heading
 Serial.println(F(""));

Sensor
I have a Blue Dot BNO055 sensor and it has marking on it for X, Y, Z directions as follows:

I crossed checked with the logic of Euler Angles from Wikipedia
If i rotate along the x Axis, I do in fact get roll (0 to 360) and so on.
Inference
The Adafruit_Sensor library provides only orientation values when used with BNO055 and Linear acceleration values need to be called separately using the Adafruit_BNO055.
code for Linear Acceleration and orientation
  sensors_event_t event;
  bno.getEvent(&event);

  Serial.print(F("Orientation: "));
  Serial.print((float)event.orientation.heading);
  Serial.print(F(" "));
  Serial.print((float)event.orientation.pitch);
  Serial.print(F(" "));
  Serial.print((float)event.orientation.roll);
  Serial.println(F(""));
//  Serial.print((float)event.acceleration.x); // same as roll
//  Serial.println(F(""));
//  Serial.print((float)event.acceleration.y); // same as pitch
//  Serial.println(F(""));
//  Serial.print((float)event.acceleration.z); // same as heading
//  Serial.println(F(""));

  imu::Vector<3> li_ac = bno.getVector(Adafruit_BNO055::VECTOR_ACCELEROMETER);
  Serial.print(F("Li. Acc.: "));
  Serial.print((float)li_ac.x());
  Serial.print(F(" "));

  Serial.print((float)li_ac.y());
  Serial.print(F(" "));

  Serial.print((float)li_ac.z());
  Serial.print(F(" "));
  Serial.println();

  delay(BNO055_SAMPLERATE_DELAY_MS);

You must set the operation mode from adafruit_bno055_opmode_t enum. Use bno.setMode.
For modes see section 3.3 in the datasheet.
The sensors_event_t is an union struct so the same memory is accessed with different member names.

I am not sure which mode to use and I tried setting it to IMUPlus and also tried it with NDOF but I get the same values for event.acceleration and event.orientation

doesn't help much. I referred to the datasheet after you answered and set them in the code's setup() and it provides the same output

as I write the struct is an union. it contains array of 4 floats. this floats are accesible as [0], [1], [2], [3] or over one of sensors_vec_t type aliases named acceleration, magnetic, orientation and gyro. the first float has additional aliases like temperature, distance. The event can return only one reading

read the description of modes "In  the  IMU  mode  the  relative  orientation  of  the  BNO055  in  space  is  calculated  from  the
accel
erometer and gyroscope data. The calculation is fast (i.e. high output data rate)"

So I guess with this library I can only use event.orientation and obtain the roll, pitch and roll and I have to use the Adafruit_BNO055 to obtain the linear acc. value separately

you can read data of the separate sensors or the fusion modes. I don't see how to read data with this library for combined modes like the AMG  mode


text:
Arduino shield bluetooth
I have this arduino motor shield, and I want to connect a Bluetooth module, but don't know how (the tx and rx pins are used by the plate). Tried to sold it but now I don't have the tin to do it. So I want to know if I can use this holes (don't know their names) "the ones encircled in red" to connect the Bluetooth module. Thank you folks.

You are looking at the wrong place. Tx and Rx are at the bottom of you picture (new picture at the bottom to help you). What you need to do is to get a jumper, heat up the Rx pin and put the jumper in the molten solder. That is not the ideal choice but because you don't have enough solder, thats the way to go. To the same to the Tx pin, GND, and VCC.
A more permanent and clean way of doing this will require extra solder (which you dont have at the moment) and some "shield headers" (aka stackable headers). This will let you connect the shield to your Arduino while still leaving you with all of your female headers.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Doubt on Processing Power
The datasheet of arduino mega claimed that the board has 16Mhz processing power. But the question that doubt me is what would happen to the board if the board has no enough processing power.
For example,  if the board is used in an application that involves a lot of calculation in each loop. Would it stall the board?
Personally, i think the board would just give slower response instead of stalling the board. It was due request is done in sequential method in the code. Therefore it would not accumulate up the request until stalling the device like PC and I think it would be just at most an arduino which is always busy.
Is it what would happen if the board has no enough processing power?

The Arduino doesn't multi-task like your PC does. How it behaves is entirely dependent on how you write your sketch. If you write it such that it gets stuck for long periods processing and not responding to input, then that's what it'll do. If you write it to respond to input rapidly and do processing in small chunks in between, it'll do that. Does that answer your question or help understand the situation better?

Processing Power is a bit of a misnomer. Clock Frequency is a better description.
In general one assembly instruction gets executed each clock cycle. That means approximately 16 million instructions per second (there are a couple that take more than 1).
Your C program gets compiled into those instructions and executed at 16 million instructions per second.
If your routine is 16 million instructions long (when loops are unrolled) then it will take 1 second to execute.
Unlike a PC, which is constantly switching between tasks, an Arduino does only one thing, and that is the one thing you programmed it to do. Because of that execution time is predictable. If it took 1 second to execute today it will take 1 second tomorrow,  and 1 second next week.


text:
Is it possible to use Wi-Fi as a wireless connection to my Arduino/Windows PC LAN without using the internet
My Situation and Problem:
I am wanting to put together a system to help monitor the soil moisture content in my garden and a small heated greenhouse I use in the winter. Also, In the near future I would like to build a system to remotely monitor the nutrients in my soil and other grow media, and have it accessible through my computer using a system similar to the one I'll have monitoring the moisture levels. In both situations I am growing nearly all crops hydroponically.
I have found several instances of people doing this by having the information posted to a service provider's website. Then it is possible to access the information by way of email or connecting in some manner to the service provider's site.
I plan to store the data in the cloud, but where I live we get internet access through satellite dish or land based re-transmission sites. So, I am planning to keep all gathered data in "The Cloud" manually, once received when I turn on my computer. I even have to use a booster device in my house to get dependable cell phone service. My land line telephone service provider doesn't offer high speed internet service, so I don't presently use a smart phone. I recently read a news article talking about a similar, though more widespread situation in Australia. In Australia they call it the tyranny of distance.
In addition to my garden and greenhouse, I have several other ideas for using Arduino to gather data using wifi and do any number of other things, and most of these ideas include accessing the gathered data through my computer connected to an Arduino device as required. It would certainly be helpful if anyone would be willing to share any ideas or point me toward inexpensive solutions.
Thanks for your kind consideration.

You mean like running a HTTP server on it like the examples show?

I'm sorry, but which examples are you referencing? I don't quite understand, but appreciate your efforts.

I would expect it could be hypertext transfer protocol, but don't quite understand. Are you referencing the operations I mentioned? If that is the case, sure. It could be readily converted for my purpose into the data I would need.

The library for the chip you're using likely come with some examples.

Sounds quite promising. What would it be called on the UNO R3 or the MKR1000? I have others as well, but are they on these boards and what are they called?

Other than the ones that come with the Wifi101 library?

There is no requirement that your data pass to an external "cloud" server - it could go directly from the network-equipped Arduino to your PC.  However, if your PC will not be always on, then you will either need to hold the data in the Arduino until you can query it, or come up with some small power-efficient local server to collect and store it, perhaps based on a raspberry pi or by extending an OpenWrt-style router linux install, on any of a router chipset used for custom purpose, a Yun-stype device (which is just an Arduino-sized version of that) or else on your router itself.

In my own crude way, that is a major part of what I was trying to explain.I will have other requirements:

I am really flexible on this, and open to any suggestions. I have worked with computers a long while, but "this" is new and different to me.

I know this sounds silly, but how about ESP8266?

dhimaspw, I have done some checking, and the ESP8266 may work very well. I will need something with a dependable wireless range of approx 60 meters. Are you familiar enough with the devices to know if this will work? The information I will be gathering won't change so quickly that it needs to be sent several times a minute, but perhaps every half hour. I might even be able to connect a chip to the sensor array to record the data, and then do a manual call the recorded data? Thanks for your interest and suggestion. Also, I have a few of the larger ESP8266 boards.

Ok, my idea is that you could connect the arduino AND your computer to the same router ( that doesn't need to internet access) to create a simple LAN. Then program the arduino to send every X amount of time data to the computer with a simple protocol like UDP knowing the LAN address of the computer ( example would be 192.168.1.2) and the one of the arduino, you could send UDP packets with IP address of the computer and since the router sees that the IP is in its internal LAN it just sends it straight away. Now there are a few problems to this approach:
1) The arduino needs to have signal to be connected with the router, so the distances need to be reasonable.
2) Both the arduino and the computer needs to be always on. The arduino isn't a big issue, just remember that if for some reason you'll use the millis() or micros() functions eventually they'll reset to 0 and start again. As for the computer instead, this could be a bit expansive, since having a normal pc on for all the time can impact the electricity bill quite a bit. The solution to this would be for example to make the arduino write data on a  SD card and when it sees that the computer is on and that it's able to send it to it, it starts retriving data from the SD, sending it to the PC and then deleting it. The problem with this is that the SD has a limit as well, so just keep this in mind.


text:
Binary message formatter
I am currently developing an IoT device with arduino and i want to minimise the data payload. First i used json which is not very efficent in fixed messages (the format will always be the same). Then i found something like messagepack which also sounds nice but i think you could do even better with just binary. I hope to find something like that:
I have a message for example:
#BOOL#INT#INT#FLOAT#BOOL#STRING#

The position of this variables never change so i could represent the message in binary and i could save a lot of bytes. Is there any library which can de/encode such formats and generate messages from given values?
If not i think it would be very useful in further IoT devices!

Passing messages across computers and/or microcontrollers with different architectures can be a real pain (endianness...). So do not fall into NIH / reinventing the wheel traps but keep standing on the shoulders of giants! Several message serialization protocols exist.

BSON
MessagePack
Protocol Buffers
CBOR (Concise Binary Object Representation)
...

Several implementations of such protocols exist (even for Arduino).
I suggest to have a look in a search engine for such protocols and add Arduino.
I've found:

BSON

ardubson

MessagePack

msgpack-mcu
arduino_msgpack
MsgPacketizer
msgpack-arduino
ArduinoJSON serializeMsgPack / deserializeMsgPack

Protocol Buffers

nanopb

CBOR

Arduino-Cbor

...

PS: You might read https://scottlocklin.wordpress.com/2017/04/02/please-stop-writing-new-serialization-protocols/
and have a look at https://xkcd.com/927/
Just choose a giant compatible with your requirements ;-)
https://en.wikipedia.org/wiki/Comparison_of_data_serialization_formats may help

Brilliant. Maybe add something about how bad sending structs between avr, arm and x86 works?

No such library is needed, since basic C++ can handle this on its own. Create a packed struct with the fields, fill the fields with assignment or memory copying, and cast to a char* in order to send. Reverse the order of operations in order to receive. Beware the string though, since they need to/should specify a length somewhere.

is it also possible to terminate the string instead of using a fixed length?

There is no difference between terminating a string and specifying the length other than the fact that the terminator cannot be used in the string.

A good choice to send sensor data is CayenneLPP. LPP stands for "Low Power Payload". It is a sensor type aware encoding that uses as few bytes as possible.
A key feature is that recipient must not be aware of content as it is encoded into message, so you can build a generic gateway using that.
You can read more about CayenneLPP here: https://developers.mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload
It is recommended for using it on TTN to minimize payload weigth.
There is an Arduino library for enconding and decoding. For decoding it outputs JSON object so it is ready to be used in platforms like NodeRed or any python or web based application.
Check it here: https://github.com/ElectronicCats/CayenneLPP

use a struct organize the data and when transmit the struct, use a char pointer pointing to it so everything is sent in binary format.
you will need to come up with a way to determine when the pointer ends.