I understand that the serial communication is 'slowish'. But the telegrams are sent in 3500ms intervals.
I had bad experience with EventTriggers (which are also not recommended in the article). The other examples focus on handling the received data.
Letting the loop run until Serial becomes available again results again only in one character '120'. The else-path is never triggered.
unsigned int pos = 0;
void loop() {
bool newData = false;
while(Serial.available() > 0 && newData == false) {
// Serial.print ("T "); // test if loop is triggered
byte r = Serial.read();
if(r != '\n') {
data[pos] = r;
pos++;
} else {
Serial.println("N"); // test path is triggered
data[pos] = '\0';
newData = true;
}
}
if(newData) {
Serial.println(data);
pos = 0;
}
}
Either the other characters are flushed somehow or never sent (doubtful since the sniffer reads 'x12').
Maybe I am searching on the wrong side of the code. Since I am using two RS485 modules for the transmissions: Do I need to LOW\HIGh the external trigger after each character or can I send them all at once?