Recently a rather complicated I2C-Project crashed.
During debugging i found, that not event the most simple I2C-configuration between two arduino does work anymore.
I EXACTLY recreated this tutorial: https://www.arduino.cc/en/Tutorial/LibraryExamples/MasterWriter
But once i actually connect the two Unos, the master freezes during the sending process.
When I remove the cables while running, the program continues.
With only two participants on the bus and builtin pullups on the Uunos i figured it must be a software thing somehow????
I even tried another available uno board and different IDE versions out of desparation without any effect.....
Thanks for the nice tutorial.
Same issue though. When using your 1st tutorial the master stops sending as soon as I connect any slave device.
Any ideas?
You wrote the word "cables". Tell us about your cable.
What kind of cable is it, how are the signals connected, how long is it, and so on.
Is it possible that a Slave has no power ?
When a sensor or an Arduino or anything else is connected to the I2C bus without power, then the I2C bus stops working.
You need pullup resistors. For example 4k7 pullup resistors at the Master.
The MasterWriter/SlaveReceiver example is sadly not a good example. The Slave uses "loop through all but the last" which is very confusing and no one uses that, and the Slave uses Serial functions in a interrupt routine.
We use packets of binary data of a certain length, as you can see in the tutorial of Robin2.
boredengineer:
Same issue though. When using your 1st tutorial the master stops sending as soon as I connect any slave device.
Any ideas?
You need to provide a lot more information.
At the most basic, how can you tell that the master is sending if there is no slave connected?
Please post a photo of a simple pencil drawing showing how you have connected things.
Just in case you are using twisted-pair cable, one of the pair must be connected to GND and the other to the SCL or SDA pin. It will not work if you use the two wires of a twisted pair for SCL and SDA.
I'm using the most basic wiring possible with ordinary jumper cables (15cm length or so):
The example program includes a print after the send command of the master. With no slave connected, the messages get displayed correctly. If I connect a slave, the message does not even get printed once.
If start the master without the slave, the messages stop as soon as i connect the SDA.
I power both the master and slave via USB at the moment.
It should work, so you have to check all the hardware.
It seems that your SDA is shortcut to GND.
Can you measure that ? Or check the board with a magnifier.
Do you have a third Arduino board ? To be able to determine the bad one.
The Wire.endTransmission() will halt the sketch when:
SDA is shortcut to GND
SCL is shortcut to GND
SDA is shortcut to SCL
Are your USB cables okay ? Can you measure the voltage of the 5V pins. I prefer a voltage above 4.5V, but the Arduino Uno will still run with 3.5V.
Can you check the jumper wires ? Some are so cheap that they are broken.
Do the jumper wire actually make contact ? Can you try other jumper wires ?
Is a Arduino board broken ?
It is possible that something is damaged making it seem to work good at one time and bad at another time.
Found it guys!
Apparently one of the unos had a shortcut between SCL and GND with only 100 Ohms in between.
Switched it against a new one without any shortcuts, now the example works just fine.
Thanks so much for spending time on issues like this. You guys are my real heroes!