RAK4631: Corrupt data over Serial (UART) comms

Strange data over UART.

platformio.ini

[platformio]
default_envs = trans

[env]
platform = [email protected]
board = wiscore_rak4631
framework = arduino
upload_speed = 115200
monitor_speed=9600

[env:trans]
build_flags=
    -D TRANSMITTER
    
[env:rec]
build_flags=
    -D RECEIVER

[env:both]
build_flags=
    -D RECEIVER	
    -D TRANSMITTER

main.cpp

#include <Arduino.h>

void setup() {
  time_t timeout = millis();
  Serial.begin(115200);
  while (!Serial)
  {
    if ((millis() - timeout) < 5000) { delay(100); }
    else { break; }
  }

  Serial1.begin(9600);
  while (!Serial1)
  {
    if ((millis() - timeout) < 5000) { delay(100); }
    else { break; }
  }
}

void loop() {
#if defined(TRANSMITTER)  
  Serial1.print("Hello Serial comms");
#endif // defined(TRANSMITTER)  

#if defined(RECEIVER)  
  while(Serial1.available() > 0)
  {
    char c;
    Serial1.readBytes(&c, sizeof(c));
    Serial.print(c);
  }
  Serial.println();
#endif // defined(RECEIVER)  

  vTaskDelay(50);
}

Pretty simple, right?

If both RECEIVER and TRANSMITTER are defined and the board has Tx1 connected directly to Rx1 then the expected data are received and sent to Serial (verified by connecting Serial to a monitor)

If however one board is loaded with RECEIVER and another with TRANSMITTER and the TRANSMITTER’s Tx1 is connected to the RECEIVER’s Rx1, then the data are corrupt

image

Does anyone have any idea of what the cause is for this?

How are the two connected?
Should be:

Board 1 Board 2
TX1 RX1
RX1 TX1
GND GND

damn!, of course they need a common ground!

:wink:
Not the first time it happened.

yes, but you’d have thought that I’d remember that by now :rofl: :sob:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.