In my project, I have to send a string from one arduino to a second arduino, and make it send the same string to a third arduino. I used UART and SoftwareSerial library, and connected the arduinos like that:
In all the arduinos: Pin 10 - RX port, pin 11 - TX port Arduino 1 pin 11 ----> Arduino 2 pin 10 Arduino 2 pin 11 ----> Arduino 3 pin 10 Arduino 3 ----> PC (by hardware Serial)
By theory, Arduino 1 sends string "CA" to arduino 2, which resends that same string to arduino 3, that prints it back on Serial.
The problem is that I get the string "C�" instead of "CA" (that weird "C�" is equal to "067 255" on ASCII). Does anyone knows why it happens? Maybe there's something wrong with my code?
Here's the code for all the three Arduinos:
Arduino No. 1:
#include <SoftwareSerial.h>
#define ADDR "CA"
SoftwareSerial tiny(10, 11); //TBD
void setup() {
Serial.begin(9600); //debug only
tiny.begin(9600);
delay(2000);
tiny.write(ADDR);
}
void loop() {
//nothing here
}
Arduino No. 2:
#include <SoftwareSerial.h>
SoftwareSerial tiny(10, 11); //TBD
void setup() {
Serial.begin(9600); //debug only
tiny.begin(9600);
}
void loop() {
if(tiny.available() > 0) {
tiny.write(tiny.read());
}
}
Arduino No. 3:
#include <SoftwareSerial.h>
SoftwareSerial tiny(10, 11); //TBD
void setup() {
Serial.begin(9600); //debug only
tiny.begin(9600);
}
void loop() {
if(tiny.available() > 0) {
Serial.write(tiny.read());
}
}
Any idea on what went wrong?