Page 1 of 1

I2C Slave on ESP32 Returns 'endTransmission: 4'

Posted: Mon Dec 09, 2024 4:20 pm
by Nandhini
I am working on an ESP32-based I2C Slave that communicates with a ESP32 Master device. The system involves receiving commands from the Master (e.g., "ON" or "OFF") to control an LED and sending back responses such as "LED ON" or "LED OFF" i.e., current status of LED. The functionality works, but the I2C communication intermittently reports an error:
endTransmission: 4

This is my current output from the Slave:

17:06:28.410 -> Received command: OFF
17:06:28.410 -> LED turned OFF
17:06:31.402 -> Sent response: LED OFF
17:06:31.402 -> endTransmission: 4
17:07:01.441 -> Received command: ON
17:07:01.441 -> LED turned ON
17:07:04.441 -> Sent response: LED ON
17:07:04.441 -> endTransmission: 4

The Slave successfully receives commands from the Master and executes them (e.g., turning the LED ON or OFF).
But, it sends responses back to the Master, but the error persists intermittently. How can I debug or eliminate the endTransmission: 4 error in this setup?

Re: I2C Slave on ESP32 Returns 'endTransmission: 4'

Posted: Tue Dec 10, 2024 8:40 am
by lbernstone
Turn up your log level. It will probably give you some additional info about the error. I am not an I2C expert, but it looks like you don't need to call endTransmission as slave. The master will be managing the bus, the slave should just send a response and go back to low state.