Re-send serial data from USB to few Arduinos?

Hello guys,

I´m going to try explain the problem that I have with my project.

I try to send data from USB to some Arduinos at the same time via serial port with 2 wire cables (RX + GND) using an Arduino MEGA the intermediate to re-send this data to these Arduinos . But nothing works…

How can I do this? (USB data → Arduino MEGA re-send data → Arduinos Slaves)

This is the code for the “Arduino Slave”. This code works great if I connect this Arduino Slave directly to USB (some digitalWrite for LEDs on the setSlat and setCue are not declare now, just for save space), but I want to use 30+ arduinos that recive this data from the Arduino MEGA via 2 long wire cable (RX + GND) o something similar.

This are the bytes send from the USB to understand a little more the code (it is not my code):

Byte 1: startbyte (255)
Byte 2: ID Slat (1-30)
Byte 3: Cue Nº (1-99)
Byte 4: Checksum (Crc8) check ID Slat & Cue Nº

Thank you in advance.

Greetings.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

You could easily extend the 2nd or 3rd example to send the received data on a different Serial port like this

if (newData == true) {
  Serial1.print(receivedChars);
  Serial2.print(receivedChars);
}

...R

but I want to use 30+ arduinos that recive this data from the Arduino

Consider RS-485 on the hardware side. It is meant for multi-drop serial over long wires.

Robin2:
Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

You could easily extend the 2nd or 3rd example to send the received data on a different Serial port like this

if (newData == true) {

Serial1.print(receivedChars);
  Serial2.print(receivedChars);
}




...R

Hi Robin2,

No, I don't see this examples but are so great, I will test this. Thank you.

groundFungus:
Consider RS-485 on the hardware side. It is meant for multi-drop serial over long wires.

I don't considerer RS485 because I don't have idea of it. The RS485 is amazing! I bought one USB to RS485 and one MAX485 to make some test with the Arduino.

I will post the result of the test. Thank you so much.

RS485 is the way to go. If interested, there's a small sketch at GitHub - DKWatson/P2P485: Peer to peer communications for RS485 networks just for that.