MicroPython uMQTT - gangely/espp GitHub Wiki
Table of Contents
source on GitHub micropython-lib or PyPi.org
-
download the zipped files ''micropython-umqtt.robust-1.0.tar.gz'' and ''micropython-umqtt.simple-1.3.4.tar.gz'' from the former location in a local ''umqtt'' folder
-
unzip the files ''simple.py'' and ''robust.py''
-
copy ''simple.py'' and ''robust.py'' in a ''/umqtt'' folder on the ESP32
cp umqtt/*.py /pyboard/umqtt
DO NOT use this method: there is a problem with the SSL certificate not being validated
>>> upip.install('micropython-umqtt.robust') Installing to: /lib/ Warning: pypi.python.org SSL certificate is not validated Error installing 'micropython-umqtt.robust': Package not found, packages may be partially installed
packages can be installed directly on the ESP32 with the upip
module, providing the ESP32 is connected to the LAN and has access to Internet
run on ESP32:
>>> import upip >>> upip.install('micropython-umqtt.robust')
files installed on the ESP32:
/lib/umqtt/robust.py /lib/umqtt/simple.py
>>> import umqtt.simple >>> dir(umqtt.simple) ['__class__', '__file__', '__name__', 'hexlify', 'socket', 'struct', 'MQTTException', 'MQTTClient'] >>> dir(MQTTClient) ['__class__', '__init__', '__module__', '__name__', '__qualname__', 'connect', 'disconnect', '_send_str', '_recv_len', 'set_callback', 'set_last_will', 'ping', 'publish', 'wait_msg', 'subscribe', 'check_msg']
>>> import umqtt.robust >>> dir(umqtt.robust) ['__class__', '__file__', '__name__', 'utime', 'simple', 'MQTTClient'] >>> dir(MQTTClient) ['__class__', '__init__', '__module__', '__name__', '__qualname__', 'DEBUG', 'connect', 'disconnect', 'log', '_send_str', '_recv_len', 'set_callback', 'set_last_will', 'ping', 'publish', 'wait_msg', 'subscribe', 'check_msg', 'DELAY', 'delay', 'reconnect']
see note: What does it mean to be "robust" ?