Hello,
I'm working on a simple arduino project which generate square electrical signal.
Actually all is working well, except the i2c communication which sometime disconnect. But as the project must to be autonomous, I need an auto-reconnect i2c communication, but I'm not really sure how to do that.. wire.begin into the loop section ?? create an exception ?
Thank you for advicing me.
What is going on with your I2C bus ? it is not a fault tolerant bus.
Can you tell more about: length, wires, cables, pullup resistors, other I2C devices, grounding.
The sender is a RAspberry ( SDA / SCL )
The receiver is an Arduino ( SDA / SCL )
Raspberry and ARduino share the same ground.
All wires are well connected. Raspberry send data, and Arduino receives correctly data, but at one moment Arduino stop to receive data. It is not at the same time. Sometime the system works correctly during 1 minute, sometime the system stop at 10 seconds... I have no resistors, no other i2c devices.
The Arduino Mega has onboard pullup resistors of 10k to 5V. In the green circle:
The Raspberry Pi has no 5V tolerant pins. Since the SDA and SCL are lifted to 5V (via the 10k onboard pullup resistor) a current leaks into the Raspberry Pi pins. A I2C level shifter prevents that.
In your picture, there are only the SDA and SCL lines, but the GND wire is the most important wire of the I2C bus (it really is).
If you connect a USB cable from the Mega board into the USB connector of the Raspberry Pi, then you can use the Serial bus and there are no problems by the I2C bus.
Yes maybe it is too speed. However I didn't have problem when I use Arduino + Arduino with Serial.begin(2000000).
But maybe it's too speed for Arduino + Raspberry.
I will test with lower speed..
Hello, with a 9600 bds speed, result was the same..
So what I understand is i2c communication between arduino and arduino is very good.
I2C communication between raspberry and arduino isn't very reliable... So I test the UART communication between raspberry and arduino and result is very good, and programming easy