I am trying to send data from a PIC processor to ESP32. I started sending out data from the PIC. In ESP32 i run i2c.scan, but it returns a number of i2c addresses. How do i know i2c address of ESP32? Is there a low level example on how to read data from external processor to ESP32 in Micropython?
So, you want to set the ESP32 as an I2C slave device, right?
According to this discussion, there isn’t I2C slave support on the official micropython distribution. But there is support in the loboris fork: https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/i2c
When creating an I2C instance, you can set the slave address.
Let me know it helps.
Thanks for the directions. Would ARDUINO allow setting ESP32 or ESP8266 as a slave?
I don’t think it is implemented in Arduino IDE for the ESP32. At least I haven’t found any information about that.
You can set it as I2C slave using IDF: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/i2c.html
For the ESP8266, I’ve found this library: https://github.com/suculent/esp8266-I2C-slave
You can also consider using Serial communication instead, it is better documented (if it suits your project).
Still struggling with i2c :). i decided to use ESP32 as a master and use PIC as a slave. Your examples in Micropython course kind of hide the low level i2c stuff. And the BME280 and OLED programs are too complicated to learn from. Is there some low level MicroPython example of how to setup i2c to read data from a slave device? For example, if i have:
i2c = I2C(-1, scl=Pin(22), sda=Pin(21),freq=100000)
do i still need to run “i2c.start()”?
or when i run “i2c.readfrom(0x2c,1, True)”, i get an error:
OSError: [Errno 110] ETIMEDOUT
I would like to be able to constantly read from a slave even when it is not ready.
I’ve found this Adafruit tutorial on how to use I2C with MicroPython:
I think this may contain the information that you need.
To avoid that error, I think you need to use that I2C command inside a try and except statement, so that you keep trying to read I2C even when it is not ready.
I hope this helps.