I have created an i2c bus for one Arduino Uno R3 master to communicate with two Colorduino slaves. Most of the time the communication is fine, however occasionally I lose a packet. The timing appears to be random. My i2c bus is at 400khz and my pull-up resistors are currently 10k, I have also tried 4.7k and 2.2k. Power is supplied by a 5V, 1200mAh power supply.
I have no idea what the problem could be, does anyone have any idea where to start looking?
I added a diagram (i2c_bus.png) of my current setup. In this diagram the two Uno’s on the right are actually Colorduino’s.
The master has the following code: master.c · GitHub
The slaves have the following code (one of them has i2c address 2, the other 3):
The master receives commands from a PC via the Serial port, SERIAL_RGB_COMMAND, the master will reply with a SERIAL_ACK_COMMAND when it receives a SERIAL_RGB_COMMAND from the PC. This way I can check if the commands are received and processed by the master, in all cases they are, therefore it seems to me that the problem is not in the serial communication between master and PC.
Upon receiving SERIAL_RGB_COMMAND (with including 8x8 array of RGB LED data) the master sends three packets over i2c, one 8x8 red packet, one 8x8 green packet and one 8x8 blue packet. I have set up a Serial connection between the slave and PC to check if all packets arrive (by Serial.println upon receiving a R, G or B packet). And I notice that sometimes one of these R, G, or B packets is not received (it is not printed to the Serial port).
Upon receiving a Serial SERIAL_RGB_COMMAND packet from the PC, the master generates 3 i2c packets, but occasionally one of these i2c packets is lost. Most of the time it works, the failures seem very much random.
I hope I included everything, if there is some information missing please let me know!