Communicating multiple Arduinos through I2C

I2C is great communication protocol allowing to interface multiple devices to only two signal wires. Using it is simple, because I2C peripheral is already included in most microcontrollers. Atmega micros on Arduino also have this peripheral sometimes called TWI (Two Wire Interface). I2C communication is normally single master and one or multiple slaves. Berryjam couldn’t find decent example where multiple slave Arduino could accept multiple tasks from master. So he wrote his own tutorial on this. He wrote programs for master and slave(s) allowing to send any number of commands. Master sends code number to slave which its hand executes function with assigned code and returns results to master. This way he was able to interface separate arduinos to master where one is responsible for reading sensors and controlling motor, another outputs information to display and so on. In his recent code master is able to send command but also passes up to 5 arguments of data to be passed in to slave function. If you are setting project like modular home automation system, this example may be a good… Continue reading

Arduino I2C expansion I/O

Did you have a situation when you ran out of microcontroller pins. Especially when you do lots of interfacing, adding many buttons or LEDs then you definitely need many I.O pins. Sometimes you can use more advanced microcontrollers, but this isn’t best solution especially when you don’t need much processing power. Why not to use I/O port expansion? Keith decided to experiment with I2C port expanders connected to Arduino board. He used Texas Instruments PCA9535 and PCA9555 16-bit I/O port expanders – one for inputs and another for outputs. This way he managed to add 16 additional I/O pins by scarifying 2 MCU pins. Author has provided a generous description about whole process and even gives us a program code for trying. Continue reading