Ping i2c device and reset bus ?

Hello everyone,

Last year I created from scratch a new control panel for my camper, based on an ESP32:

I may need to go further into the details to get an answer, but I'm basically having issues on the i2c bus due to interferences caused by fans, heater, etc.
It may have been a mistake to go with i2c, I did not expect this behavior initially. Cables guilty for this are probably not shielded.

Anyways, when such a problem occurs, it looks like the ESP is losing communication with i2c devices (at least the LCD screen becomes empty/blank). Is there a way to detect such a thing? Like ping devices ?

Could something as simple as the following do the trick to detect this?

Wire.beginTransmission (<device_id>);
if (Wire.endTransmission () != 0) {
}

Any help or hint will be appreciated!

Thank you

That's the way an I2C scanner is detecting devices on the bus.

You will detect a completely failed bus but given your description above your bus is not completely failing but wrong transmissions based on electrical noise.
Seems to be caused by too long I2C bus wires and noisy devices nearby. Try to put the complete I2C bus into a metal casing.
It may also help reducing the I2C speed if the problem is more the bus length than the noisy environment.

1 Like

Can you show a photo of the wiring ?

I was able to narrow down the problem to a solenoid valve used to flush the toilets. Fixed this by adding a diode (1N4007 that's all I had around) very close to the solenoid.

I'm not sure it's the only problem but I tried everything, and both ESP and LCD keep running without any issue!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.