I2C Slave Mode

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

I2C Slave Mode

Post by devnull » Thu Sep 14, 2017 1:04 pm

I need to emulate an (small) I2C slave device that is no longer manufactured.

Is it possible to use the esp8266 in slave rather than master mode ??

Otherwise, is there an alternative or work-around ??

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: I2C Slave Mode

Post by deshipu » Thu Sep 14, 2017 3:45 pm

The ESP8266 doesn't have any I2C peripheral by itself. The I2C that is available in MicroPython is implemented in software. Slave mode is not currently implemented in MicroPython in software.

What you could do is program your ESP8266 in Arduino, or port the Arduino I2C slave code to MicroPython...

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: I2C Slave Mode

Post by pythoncoder » Fri Sep 15, 2017 7:30 am

I doubt slave mode can be made to work at any reasonable speed on the ESP8266 as I2C needs a realtime response to incoming signals. If you use interrupts to achieve this you are hamstrung by the large and variable interrupt latency of the chip. A polled solution would be likely to suffer from latency caused both by the underlying RTOS and by garbage collection.

A polled solution is also likely to lead to difficult synchronisation problems with the master - the I2C protocol assumes that the slave is always ready for data.
Peter Hinch
Index to my micropython libraries.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: I2C Slave Mode

Post by devnull » Sun Sep 17, 2017 2:13 pm

Thanks, I kind of thought that would be the answer.

I have reverted to the trusty Microchip PICs and have achieved what I wanted to do.

Post Reply