Arduino uno R1, UART, rx-tx pins cnfusion, SoftwareSerial()

Dear forum.
Im trying to setup a old arduino uno r1 as a sensor board collecting data and send sensor data over UART to a uno wifi R4. If I understod correct the Arduino uno r1 serial is shared with pc usb port and rx/tx pins 0 and 1 (?).

So I have the hypothesis the command SoftwareSerial sUART (2, 3); might work together with library #include <SoftwareSerial.h>. It all compiles and uploads to board but I receive no sign of communication between the boards. Baud rate is correct (9600) and i tried switching over rx-tx on gpio pins 2,3...many times. Im too stupid searching this forum for wildcards with "uno r1 uart" but Im sure this problem is described how to solve in several posts. Please be patient and kindly advice as Im stuck.

Code snippet :

  if (sUART.available() > 0) {

    char inputChar = sUART.read();

    if (inputChar == '\n') {
      sendMessage = "1";
      sUART.println(sendMessage);  // Send the message through Serial1 with a newline character

      //sendMessage = "";  // Reset the message

    } else {

      sendMessage += inputChar;  // Append characters to the message

    }

I have never user an R1 (how comes you have such kind of old board?), so I don't know if this is the prblem but AFAIK SoftwareSerial should work even with that pretty old board.

First, I think you should post the entire code, not just a snippet to let us better understand the environment you plan to use it. And please post both sides code, sender and receiver and a description of the connections.
Then, you don't need to "juggle" with TX and Rx pins, you always need to just cross RX and TX (i.e. TX of one board to RX of the other, and vice versa RX to TX) and, I hope you already did it. but remember also to connect both GND together...

PS: why do you need to use SoftwareSerial instead of the physical UART, aka D0 and D1?

1 Like

Out of interest, which pins are you connecting to on the R4 and how are you reading the data ?

Are you by any chance using pins 0 and 1 on the R4 and using the Serial interface ? I ask because the Serial interface on the R4 does not use pins 0 and 1, rather they are used by the Serial1 interface

Please post the full sketches used by both boards, using code tags when you do

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