“Your personal universal electronics kit. More I/O pins. More devices. More distances. Remote wireless control. No bunch wires.
The system of several Arduino interconnected by an I2C bus is not new. But many people are not aware of this possibility and the advantages of such a joint connections between several Arduino. There are also difficulties in understanding the interaction of sketches on multiple devices.
My version of such connections – the project of the URB (Universal Railway Bus) was designed for railway modellers. But its capabilities can be applied anywhere. First of all, I will give a simple example that will show you the main advantage of such a system.
This two pictures with doors only shows the concept. When you press corresponding buttons, the DC motor rotate in different directions and, according to commands from the sensors, reduce the speed, and then stop.
In the upper picture, the sketch must process the commands of the buttons and send control signals to the motor driver. When signals are received from the sensors, the sketch should change the rotational speed from maximum to zero over a certain time interval in order to ensure a smooth closing of the door. Also, the sketch must lock the rotation of the motor in the wrong direction, for example, if you press the button to close the door when it is in the closed position. After that, you also need to add a similar algorithm for the second door. Obviously, the code of this sketch will be large.
If you use local Arduino (#2 and #3) controlling each of its motor and receiving commands from its sensors, then the Arduino #1 sketch is reduced to a few lines. Just Now you need three sketches. The sketches of Arduino #2 and #3 are the same, and also simpler than the sketch on first picture. In addition, the number of wires is significantly go down.
Again, this is a fictional example. It will work in reality, but at large distances you need to use another version of the I2C bus - RS485. Nevertheless, you can see on the video how I2C bus works with railway barriers.
Conclusion: Combining multiple Arduino simplifies programming and reduces the number of wires, it also allows you to locally configure your devices and quickly find faults. By dividing the system into functional blocks and checking them separately. Also, the problem of insufficient number of I/O pins is solved – just add one more Arduino! Arduino NANO is very cheap a board!
For railway modellers
Any modeller encountereddifficulties in creating electronics for a railway layout. This is a lot of wires, thecomplexity of connecting devices and their compatibility among themselves, andmost importantly the inability to add or change something in the finishedlayout without dramatic changes in the wiring. These shortcomings are absent in the URB concept. All wiring between the blocks is made up of four wires. For example, if you need to put a few new turnouts, or signals, or sensors, or streetlights on the layout, you just cut the four-wire bus in the nearest place and insert another a URB unit. It remains only to upload the sketch, and your newly installed pieces are immediately integrated into the layout. At any time you can reprogram already installed URBs directly at your’s layout, you just need to leave the opportunity to reach it with a mini-USB cable. This way you can change the control or setting of any layout’s devices, and replace it if necessary. Another plus is theability to experiment with each URB independently of others, and solve problem to look for possible malfunctions in electrical parts on layout. It isalso possible to assemble URBs with peripheral modules separately on the table.You’ll tune the prototype and then will transfer it to the layout. This allows you to realize your ideas much faster.”