1

I have two Arduino UNO connected with two wires, and ground, that exchange informations through serial data. The communication is working with INT, but I am having troubles to receive correct characters. Instead of characters I'm only receiving numbers.

I tried every possible combination of Serial.write() or Serial.println(), with HEX and ascii, but it wouldn't work.

I do not know what I am doing wrong, if anyone could help me, I will appreciate.

Transmitter :

#include <SoftwareSerial.h>
#define TX 2
#define RX 3
#define ask 3
#define ER_LED 12
String dataline = "605030";
const byte code = 60;
SoftwareSerial syserial(RX, TX); // RX, TX
void setup() {
 // put your setup code here, to run once:
 syserial.begin(57600);
 Serial.begin(57600);
}
void loop() {
 // put your main code here, to run repeatedly:
 //syserial.println(dataline); //NO
 //syserial.println(28, DEC); //ok for numbers
 
 Serial.println(dataline.length());
 for (int i = 0; i < dataline.length(); i++)
 {
 syserial.print((char)dataline[i]);
 }
 syserial.println();
 //syserial.write(234);
 //syserial.print('<');
 delay(4000);
}

Receiver :

#include <SoftwareSerial.h>
#define TX 2
#define RX 3
const byte ask = 3;
bool com_end;
#define ER_LED 7
#define AC_LED 5
SoftwareSerial syserial(RX, TX); // RX, TX
void setup() {
 // put your setup code here, to run once:
 syserial.begin(57600);
 Serial.begin(57600);
}
void loop() {
 // put your main code here, to run repeatedly:
 while (syserial.available())
 {
 Serial.println(syserial.read());
 }
 delay(100);
}

Serial monitor on whatev b/s:

21:19:36.408 -> 253
21:19:36.408 -> 255
21:19:40.421 -> 253
21:19:40.421 -> 255
21:19:44.495 -> 253
21:19:44.495 -> 255

Monitor with SySerial on 57600 b/s:

21:23:29.317 -> 241
21:23:33.308 -> 241
21:23:37.338 -> 241
21:23:41.328 -> 241

Monitor with SySerial on 300 b/s:

21:27:03.444 -> 255
21:27:07.731 -> 255
21:27:12.095 -> 255
21:27:16.335 -> 255
21:27:20.635 -> 255

Update :

I changed the pins on the UNO (TX ->2)(RX -> 3), and now i'm getting different numbers again. I must be doing something bad, but I can't understand what.

asked Mar 28, 2023 at 16:11
15
  • I get different numbers, instead of characters Commented Mar 28, 2023 at 16:36
  • please open the content of the serial monitor window and paste it into your post ... format as code ... please no pictures Commented Mar 28, 2023 at 16:51
  • Yes, but they do not appear as characters Commented Mar 28, 2023 at 16:52
  • What numbers do you get at 9600 b/s? Commented Mar 28, 2023 at 18:49
  • Updated code with monitor output Commented Mar 28, 2023 at 19:28

1 Answer 1

0

The communication is working with INT, but I am having troubles to receive correct characters. Instead of characters I'm only receiving numbers.

Suggest you take a step back because you have code that has not been updated with what you have stated in subsequent comments and it is quickly becoming less clear what is going on.

On each UNO Use pins 2,3 and GND. Don't connect anything else to either UNO.

UNO ONE pin 2 connects to UNO TWO pin 3

UNO ONE pin 3 connects to UNO TWO pin 2

UNO ONE GND to UNO TWO GND

on UNO ONE run this code:

// RECEIVER
#include <SoftwareSerial.h>
SoftwareSerial SSerial(2,3); // RX, TX
void setup() { 
 Serial.begin(9600); // Arduino monitor hardware Serial
 SSerial.begin(9600);
}
void loop() { 
 // display whatever comes in on the software serial to the Arduino monitor (the hardware serial)
 if (SSerial.available()) {
 Serial.write(SSerial.read());
 }
}

on UNO TWO run this code

// SENDER
 #include <SoftwareSerial.h>
 SoftwareSerial SSerial(2, 3); // RX, TX
 void setup() {
 SSerial.begin(9600);
 }
 void loop() {
 SSerial.println("Simple Arduino SoftwareSerial Test");
 delay(1000);
 }

Open the serial monitor on UNO ONE and you will see "Simple Arduino SoftwareSerial Test" printed every second.

If you can't get that far, you have some other problem.

Are you using two UNOs on two different computers? Are you using two UNOs on one computer, that is; running two instances of the IDE (may depend on OS - I do that all the time on Win 7 but I don't know about other OSs)?

See if you can get this far first and I think it will be easier to get the rest fixed.

answered Mar 29, 2023 at 16:06
1
  • Thanks for answering, the setup you gave seems to be working, I will try to understand what was wrong in my previous code... Commented Mar 30, 2023 at 17:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.