ESP8266 - Pyboard communications channel

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
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

ESP8266 - Pyboard communications channel

Post by pythoncoder » Tue Jul 19, 2016 9:22 am

I don't know if this library is of any interest - my needs may be rather unusual - but it offers a channel with the following features:
  • It provides a bidirectional full-duplex communications link between an ESP8266 and a Pyboard.
  • It leaves free the ESP8266's only bidirectional UART.
  • It works with asynchronous code on the Pyboard and on the ESP8266.
  • The unit of transmission is an arbitrary Python object.
It's intended to be hardware-independent and capable of linking any two hardware devices running MicroPython. Devices must be directly linked and share a common power supply.

https://github.com/peterhinch/Micropyth ... ter/syncom
Peter Hinch
Index to my micropython libraries.

torwag
Posts: 220
Joined: Fri Dec 13, 2013 9:25 am

Re: ESP8266 - Pyboard communications channel

Post by torwag » Mon Aug 15, 2016 8:53 am

Hi,

I find this interesting esp. to see the asynchronous implementation. I just wonder about the amount of GPIOs. I guess if someone needs a wire-based link, and not be able to use SPI or I2C, he might be also short in usable GPIOs. Thus a "bit-banged" one wire implementation might be nice. Since you stated about a common power supply, it would really just take a single wire to connect two units. Albeit, I see that this way might be completely different to what you did (not full-duplex, etc.).
That said, if the module even would allow to reroute the standard REPL via this connection, and enable the "host" to echo this rerouted REPL and allow to send input to it, we would have an very easy way to check on units which does not or does not longer have a UART/USB connection for debugging (e.g. because they are integrated in a final application already). I guess, it would be something like the ssh of micropython (possibly just by using a single wire). Could be something placed later on top of your lib.

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

Re: ESP8266 - Pyboard communications channel

Post by pythoncoder » Sat Aug 20, 2016 7:35 am

That's an interesting idea. I appreciate that my solution uses an apparently unreasonable number of GPIO pins (4). I considered a 3-pin solution with a bidirectional data link, but concluded that the impact on speed would be too great. My own intended application is to use an ESP8266 as a means of bringing MQTT to the Pyboard. The latter has plenty of I/O so the fact that it monopolises 4 pins on the ESP is of little consequence.

The design intentionally avoids timing dependence, which a one-wire solution cannot. This is for portability: it's supposed to run on any MicroPython hardware regardless of speed.

For asynchronous programming it's important to avoid blocking reads - which is why I didn't use I2C or SPI slave mode. A one-wire implementation would need a way for the slave respond promptly to a state change initiated by the master. This would involve interrupts, introducing some hardware dependence. And, as you say, one-wire removes the full duplex capability. It also introduces master/slave asymmetry whereas my design is symmetrical.

In my application full duplex and symmetry are crucial as either end can send unsolicited messages at any time. So I have no plans for a one wire implementation, but if you feel inclined do feel free ;)
Peter Hinch
Index to my micropython libraries.

Post Reply