Serial protocal - How to 2

Hi,

I’ve 2 arduinos. I want to send a serial message from arduino 1 o arduino2

My idea is to send from TX of arduino 1 to RX or arduino 2.

My problem is than when I send Serial.println(“test”) I receive it on the arduino 2 but bith a lot of bad characters lie “tysyest” or even worse.

Any idea ??

Thanks

Seb

Just an initial thought, it looks like you are not reading incoming port correctly and that the software is not waiting until the character has finished being received. However, I am not sure why this would happen without looking at the code, can you post a fragment of the read bit.

From arduino 1(Tx), I use Serial.println(“Test”).

From Arduino 2(Rx) I use

if (Serial.available()) Serial.print((char)Serial.read());

lot of bad characters lie “tysyest” or even worse.

Do you always get the characters from the “test” mixed up with rubbish or does sometimes the characters “t” “e” “s” “t” not get through at all?

sometimes it arrives by block like ‘est’ or ‘tesr’. But I can not find a way to isalote ans to receive a clean message

Just a guess but it might be that the transmit line is being tri-stated at the end of the transmission so try putting 3K (or so) pull up resistors on each one. Also make sure the 0v or ground on both boards is connected.

AAAAAHHHHHHHH

You’re right!! I forgot the ground. So stupid I’m! Thanks for that…

Now I’ve to connect 12 arduinos like that. The goal is that the last one is connected to the computer and send all data to the computer.

What do yo think is the best way :

Either going from one arduino to the other, adding each time one feed
OR
having one cable getting serial from each arduino and connected to the Arduino 12

In case on one pb in an arduino in first case then I’ll miss all data. I prefer second case but i’ not sure it can work…

Whatever thanks for your help the the ground !!

having one cable getting serial from each arduino and connected to the Arduino 12

Do you mean connecting all the serial TX lines into one serial RX, if so that won’t work as each board will drive to different states at different times.
The other solution is a chain, this will work only if information flows in one direction.

One other idea might be to use I2C and make one device an I2C master (the normal state of I2C on this board) and make all the other slaves (you might have to implement this yourself). That way you can have polled two way communications.

Yes, all TX to one RX fails.

I tried the chain but as arduino 2 has to receive from arduino 1 and send, as well has to send its data too…at the end it creates a collusion of data. So the chains seems to be a problem too.

I’ll investgat the I2C one…