Two arduinos on distance

Hi to all,

I would like to build a project that I can have on one place 12 or more switches on/off and on another site I have 12 or more relays to switch some consumers.

Bettwen switches and relays Will be long distance 10meters or more and I would not like to have allot of cables bettwen.

I would use First arduino for switches - digital inputs and Second ona for digital outputs and bettwen arduinos for comunication I would use smaller number of wires.

Is it possible to solve that problem with two arduinos and 2 wires like CAN bus Hi,Lo, or something easier ?

Thanke you in advance for your answers.

RS-232 has been doing that for over 50 years. You can use that or RS422/RS485.

So I connect throo RS-232 and one is master and second slave?

What is more reliable RS-232 or RS422/RS485 and are there any restrictions on the length of cable?

What is the maximum distance?

Cheap nRF24L01+ 2.4GHz wireless transceivers should work at 10 metres and would avoid the cost and complexity of cabling. There are also higher power versions for longer distances.


It Will be max. 20meters and for this project I wont use wireless because I dont know how to programe it.

In attachment is picture what I have in minde.

at low speed 1200-2400bps rs232 should cover 25m without problem

Perfect thanke you. So to connect 2 arduino I need only 2 wires RX and TX right, of course and supply.


Yes right gnd to.

I found this example:

But I dont understand if i would like to add switchPin = 6; on first arduino and ledPin = 12; on second arduino how Will know arduino to work? Address is allways 4

why not use plain Serial / rs232 ? I2c still needs 4 wires, more complex and probably less range

O sorry i didnt saw that is i2c example :confused:

You could do better ! You could use a 433 MHz RF module to transmit data between the 2 arduinos or more How_to_do ! Or you may can use the APC220 modules that works right the way with Serial port!

433 mhz RF module is not secured so I think I wont use it for now. 3 wire connection between 2 arduinos mega 2560 Will be perfect for me.

I don't know if this is worth considering, but you can also encode switch status with resistors, then each analog input of the arduino could read status from at least four or five switches.

The 4 pairs in a cat5 ethernet cable are enough to feed 0-5V voltage range in the 6 analog inputs of a UNO. That makes it able to read 6x4 = 24 switches at the end of the 20m ethernet cable, without the need of a second arduino.

You should not connect Arduino pins directly to wires that cover that kind of distance. RS-xxx serial has driver/translator IC's that has proper line drivers and receivers. You can get them cheap on Ebay.

(I was kind of expecting you to go look up the protocols).

If I understan right the is not possible to connect 2 arduinos directly between Rx,Tx and GND? Only for testing and programming is it possible for distanje 30cm max.?