Closed UmerSoftwares closed 2 months ago
this is expected behavior on ESP32. You need to preload the data. All other ESP32-x chips work as you expect. ESP32 is the only one that needs pre-loading.
I searched about preload but did not find anything. Is there a guide on how to preload the data to solve the issue?
it's done here in the example: https://github.com/espressif/arduino-esp32/blob/master/libraries/Wire/examples/WireSlave/WireSlave.ino#L28-L32
Board
ESP32 Dev Module
Device Description
I am using 2 ESP32 Dev modules and a breadboard. The SDA (GPIO21) and SCL (GPIO22) of both ESP32s are connected together as well as pulled up to 3.3V using 4.7k resistors.
Hardware Configuration
Only the SDA (GPIO21) and SCL (GPIO22) of both ESP32s are connected together and pulled up to 3.3V using 4.7k resistors.
Version
v3.0.4
IDE Name
Arduino IDE
Operating System
Windows 10
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
921600
Description
I programmed an ESP32 as an I2C slave. I was using arduino IDE to program the ESP32 and the version installed in the boards manager is 3.0.4. When I tested it with a master, the data order was incorrect on the received data. To test it at a very basic level, I wrote a piece of code where whatever the master wrote to the slave, the slave would return the double of it on the next data request. The issue is that, the data is delayed by one read. To understand, see the the master and slave output:
Master Output
Slave Output
The slave sends te correct responses but the master receives it the next time.
After working on the issue, I can say that the issue is on the slave side. I uploaded the same slave code to an arduino mega and used it with ESP32 as the master and the response is correct without the data order getting changed.
Following is the master code
The slave code is also attached
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide