Don't connect the TX pins together. When one slave arduino is driving its TX to logic high and the other arduino is driving its TX to logic low, the resulting voltage is not a valid logic level -- this is why you're getting invalid characters.
Insted, buy a prebuilt RS-485 arduino shield
for each of your devices. Details below...
The TX/RX isn't designed to support multiple slave devices; it's just a connection between two points. The TX output is always driven, and there can be only one driver.
To properly connect multiple slave devices, you need an interface that's actually designed to support multiple drivers.
The Arduino TX/RX pins that you're using, are commonly called RS-232
, although that's not quite accurate. RS-232 is a very simple kind of network that connects two devices. One device is called the DCE
and the other device is called the DTE
. Don't worry about what those names mean; they used to mean something back in the dark ages when people connected wired telephone handsets into acoustic telephone modems (http://en.wikipedia.org/wiki/Acoustic_coupler) The only thing is that one device transmits on the TXD
wire and listens on the RXD
wire, while the other device transmits on RXD
and listens on TXD
. This gets confusing, since we like to connect wires that have similar names, so we often use a type of connection called a Null Modem
-- the TX output of one device drives the RX input of the other device, and vice versa.
(I'm skipping over some details about how RS-232 signals use higher voltages than the CMOS logic levels -- it's not just a direct logic connection.)
But the limitation of a null modem is that it only connects two devices. It can't support a network of three devices, because the cable connection can't know which device is signalling valid data and which device is idle. That requires a newer kind of serial network called `RS-485'.
The RS-485
standard requires using a special type of level translator, you don't just connect the logic level TX/RX signals. This RS-485 level translator takes care of driving the interconnect in such a way that it allows sharing the connection between multiple devices. You still have to be careful about not allowing devices to transmit at the same time (called a Collision
), but since you've designated one device as the master and the other devices as slaves, that shouldn't be a problem. The master device decides which device gets to talk on the bus.
Since you're an Arduino user and not very experienced with electronics, the simplest way for you will be to purchase a prebuilt RS-485 arduino shield
.
You mentioned I2C
(also less commonly abbreviated as IIC
), which is a 2-wire open-drain interface standard originally defined by Philips corporation. Google i2c bus specification
for details. You could probably accomplish what you're trying to do with either RS-485 or I2C, but RS-485 is closer to what you're using now.
You mentioned that you want to power the slave devices from the same power supply that powers the master device. (They should already be using the same ground return connection in any case.) If the master arduino is being powered from USB, that should be OK as long as the total supply current drawn by all three boards does not exceed the rated load current. If that happens, you'll know because your windows PC will shut off the USB port.