Implementing network support for the RP2040 and an ESP8266

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Implementing network support for the RP2040 and an ESP8266

Post by bitninja » Tue Aug 23, 2022 6:57 pm

With the release of the Raspberry Pi Pico W, I have begun to wonder what it would take to do something similar with an ESP8266 chip instead of the CYW43439. Putting the hardware interfacing aside, what kind of changes would be required to MicroPython to make it code-compatible with the Pico W and other boards that support networking?

I imagine what I am alluding to is creating a "home-brew" board definition that would interface an an older RP2040 Raspberry Pi Pico to a simple ESP-01, ESP-12F, etc... Then access the networking through normal MicroPython network/socket syntax.

Just wondering...

Jibun no kage
Posts: 144
Joined: Mon Jul 25, 2022 9:45 pm

Re: Implementing network support for the RP2040 and an ESP8266

Post by Jibun no kage » Wed Aug 24, 2022 12:44 am

Are you asking if you can integrate an ESP module to a Pico with no WiFi for example? Well, if so, it takes a few things:

1) ESP, depending on the how much memory it has, with an Arduino sketch or customized micropython image that is lean and mean enough to support the code.

2) You can use the UART to communicate to/from ESP module to/from the Pico H, i.e. non-WiFi pico.

3) UART to UART you invert the TX and RX connections and a common ground.

4) Because the micropython ESP image may be using the default console configuration, REPL configuration, you will need to write the ESP micropython code to deal with that specific issue.

5) There are limits to how much the ESP module, if ESP01 with 1MB RAM for example can handle, such as using MQTT, you can flood the ESP01 when messages are received faster than 1/second. Using the Arduino sketch can do slightly better.

If you are wondering, how i know all this, it is because I am actually working on it, using ESP01s that are limited to 1MB, not easy.

If you have newer ESPs that have say 4MB, much easier, you can use asyncio oriented scripting to improve the overall responsiveness and performance.

There are other methods to communicate, you could bit-bang over SPI on a ESP12 or better, even ESP32, or even I2C in theory, since the ESP01 in theory supports I2C. But if you have an ESP32 you already have something that competes with a Pico H already.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Implementing network support for the RP2040 and an ESP8266

Post by Roberthh » Wed Aug 24, 2022 6:17 am

With the RP2040, you can use any ESP32 module like a low cost generic one as WIFI/Bluetooth adapter using the NINA-W10 firmware for the ESP32 and the Arduino-Nano connect firmware for the RP2040. Connections:

Code: Select all

Connection for an ESP32 based NINA module.
List of GPIO Numbers

Signal    ESP32       ESP32       RPi Pico
        Arduino FW  Adafruit FW  
CS          5           5             9
MOSI       12          14            11
MISO       23          23             8
SCK        18          18            14
Busy       33          33            10
Reset      EN          EN             3
-----------
GPIO0       0           0             2
RTS        33          33            10
TX          1           1             0 (1)
RX          3           3             1 (0)

Only the first group of connections is required for WiFi.
If the connections do not suit you well, you can change them in the respective firmware.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Implementing network support for the RP2040 and an ESP8266

Post by jimmo » Sat Aug 27, 2022 11:15 am

The ESP8266 has a "AT firmware" available from Espressif that provides a socket-like API over the UART. I used this to add WiFi to projects back before I got involved in MicroPython.

At this stage, it's not worth the effort to build this into MicroPython (i.e. integrate it with the built-in socket module) but it could be done.

It seems that people have implemented Python-level APIs for it though, e.g. viewtopic.php?t=551 (it was seven years ago so the code might not work exactly, but should be possible to update).

I've also seen a few places where people run MicroPython on the ESP8266 and implement their own communication protocol over uart or i2c to the hosting pyboard. This is a great example: https://github.com/peterhinch/micropython-iot
Although this won't work on the Pico because it doesn't have i2c peripheral mode (the pyboard does).

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: Implementing network support for the RP2040 and an ESP8266

Post by bitninja » Sat Aug 27, 2022 10:57 pm

Thanks everyone!

I guess the improving availability of the new Raspberry Pi Pico W is soothing my desire to add WiFi to the original Pico. :D

Post Reply