For testing purposes of my firmware of an ESP32 I would like to simulate the sensor it's communicating with through I2C. Therefore I'm trying to setup my Raspberry Pi 3B+ as an I2C Slave So it could generate the values the ESP32 is reading. I'm using the pigpio library with the bsc_isc/bsc_Xfer function for the handling of the protocol. Basic communication and writing data works great, but I'm running into sync issues while reading data (tested both in C and in Python) It seems like when I add data to the FiFo with the bsc_Xfer function upon the receiving event, I put the data ready for the next message. Basically it's running out of sync by 1 message. A solution that worked was sending the messsage twice from the master and only process the second message, but for final use I'm unable to change any firmware on the master side. Other solutions found online all used changes to the master.

Is it possible to answer a read request with the intended value? or do I always need to have the data ready in the FiFo for when this request turns up (making reading different registers almost impossible)

1 Answer 1


I can't see any way of doing this other than having the data already prepared in the FIFO.

You have of the order of 1-bit time to respond to a register address appearing in the input request. With a 100 kbps clock that is 10 microseconds for Linux to tell you about the register address and for a response to be prepared and written to the FIFO. That is not going to happen.

  • yes that makes sense, I was afraid this was the case. I was hoping I might have missed something. Found a workaround by putting an generic Arduino as 'translator' in between to handle the i2c slave functions.
    – Ron
    Mar 18, 2022 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.