Page 1 of 1

mqtt missing from 1.8.7?

Posted: Mon Mar 27, 2017 11:42 pm
by mknoblock
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?

Re: mqtt missing from 1.8.7?

Posted: Tue Mar 28, 2017 10:44 am
by ioukos
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 :

Re: mqtt missing from 1.8.7?

Posted: Tue Mar 28, 2017 4:25 pm
by mknoblock
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!