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.