mqtt missing from 1.8.7?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
mknoblock
Posts: 2
Joined: Mon Mar 27, 2017 11:39 pm

mqtt missing from 1.8.7?

Post by mknoblock » Mon Mar 27, 2017 11:42 pm

I'm new to ESP8266 and Micropython, but I got an MQTT client from Github that does not work because 1.8.7 seems to be missing the library. I tried loading an older binary (1.8.4) and I can 'import umqtt'. With 1.8.7, it says 'no module named umqtt'.


Did the library change names, or was mqtt dropped?

User avatar
ioukos
Posts: 34
Joined: Wed Oct 19, 2016 11:31 am
Location: Alsace, Europe

Re: mqtt missing from 1.8.7?

Post by ioukos » Tue Mar 28, 2017 10:44 am

Hello,

As far as I know there are now two mqtt libraries :
umqtt.simple
and umqtt.robust

you should chose the one you want to use.
For example for simple :

Code: Select all

from umqtt.simple import MQTTClient

# Test reception e.g. with:
# mosquitto_sub -t foo_topic

def main(server="localhost"):
    c = MQTTClient("umqtt_client", server)
    c.connect()
    c.publish(b"foo_topic", b"hello")
    c.disconnect()

if __name__ == "__main__":
    main()
for more informations :

mknoblock
Posts: 2
Joined: Mon Mar 27, 2017 11:39 pm

Re: mqtt missing from 1.8.7?

Post by mknoblock » Tue Mar 28, 2017 4:25 pm

I re-flashed the 1.8.7 binary and now I can import umqtt from REPL, so not sure what happened earlier. I've been flashing with the windows tool (NODEMCU) and not esptool, if that makes any difference. In any case, thanks!

Post Reply