Overview#

These are the key components of the WiFi co-processor:

  • Software on ESP32: MicroPython. No need to reinvent the wheel. And it’s guaranteed MicroPython compatible.

  • Communication: We’ll use remote procedure calls (RPC) to invoke functions on the ESP32 (server) from the client.

  • Data Encoding: MessagePack is used to encode Python objects sent between the ESP32 and the target.

  • Bus: We use a UART to send data between the processors. It’s widely available on virtually all microcontrollers, requires only two wires, and is symmetrical: both endpoints can communicate at any time without complex handshaking. Most microcontrollers support baud rates up to and in excess of 1Mbps, sufficient for communication not to be the bottleneck in this application.

The examples use an STM32 with an ESP32, specifically an Adafruit STM32F40F Feather and an Adafruit HUZZAH32 – ESP32 Feather Board stacked on top. I keep all connections except the 3V and LED outputs. Other board combinations work also, of course.

Device configuration:

%%writefile $IOT_PROJECTS/devices/wifi-cop.yaml

wifi-server:  # esp32
    uid: 30:ae:a4:30:80:14
    path: wifi-cop/code
    resources:
        - secrets.py:
            path: libs
        - server

wifi-client:  # stm32, ...
    uid: 2d:00:49:00:09:50:52:42:4e:30:39:20
    install-dir: /flash
    path: wifi-cop/code
    resources:
        - secrets.py:
            path: libs
        - client