Page 1 of 1

Resilient MQTT for the Pico

Posted: Thu Feb 11, 2021 2:35 pm
by pythoncoder
The most obvious limitation of the Pico is the absence of WiFi.

Long before the Pyboard D I developed a means of bringing MQTT to the Pyboard 1.1. This has now been updated and ported to the Pico.

The concept is an ESP8266 running a fixed firmware build and linked to the Pico via five GPIO lines, which may be chosen at will. A binary is provided for generic ESP8266's for those not wishing to build firmware.

The user application on the Pico can log onto a local or remote broker and publish and subscribe as required. The system is designed to be resilient: WiFi or broker outages and even ESP8266 crashes are handled transparently. Data transfer is (obviously) delayed for the duration of the problem, but when the outage is cleared it resumes.

Code is asynchronous and updated for the new uasyncio V3.

See this doc. There are some limitations discussed in the doc: in particular it is not especially fast, and the ESP8266 firmware still seems unable to handle TLS on nonblocking sockets. Hopefully it will get well soon, but then I've been hoping for four years...