umqtt not being built locally for esp32
I am building micropython master locally and then flashing it to my esp32, however no umqtt module exists.
ImportError: no module named 'umqtt'
Build Command
cd ports/esp32
. ~/Documents/code/esp-idf/export.sh
https://github.com/micropython/micropython/issues/7185 seems to address the issue for the pre-built binaries but I am looking to make sure it is included in locally built binaries.
umqtt cannot import MQTTClient
Using the latest esp32 micropython build. Dowloaded the latest umqtt with these commands:
upip.install('micropython-umqtt.simple')
upip.install('micropython-umqtt.robust')
But as soon as i want to follow even the simplest of examples and try this:
from umqtt.simple import MQTTClient
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name MQTTClient
but if i put the umqtt.simple lib just onto the main memomry of the esp32
ampy --port COM6 put C:\Users\xxxx\Downloads\simple.py
and use simple.py import MQTTClient it works.
so somehow something seems broken.
I had exactly the same problem.
Digging around a little bit I found out that
lib/umqtt/simple.pywas simply empty:Probably the installation silently failed in any strange way...
Repeating
upip.install('micropython-umqtt.simple')fixed the problem.Came across this issue today while using f/w esp32-20180511-v1.9.4.bin.
The contents of file simple.py in lib/umqtt was empty. I downloaded another copy of simple.py and used ampy put to re-install it - 'ampy --port COM7 put simple.py 'lib/umqtt/simple.pyuse'
This solved the problem. So I thought I had stuffed up the firmware or mqtt install but went through the
exercise a second & third time with the same result.
Solution....Use ampy to copy a version of simple.py from the micropython-lib - and continue with installation.
ampy --port COM7 put simple.py 'lib/umqtt/simple.py
"import network
import upip
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect("Wifi SSID", "Wifi password")
upip.install('micropython-umqtt.simple')
upip.install('micropython-umqtt.robust')"
PS - Followed this procedure to install BME280 and mqtt on esp32.
https://github.com/gloveboxes/ESP32-MicroPython-BME280-MQTT-Sample
I am Using NodeMCU esp board with newest version of micropython firmware and my solution to this problem is to load
simple.pywith WEBREPL and then useand
to put this file to
lib/umqtt.