problem with mqtt

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Posts: 2
Joined: Fri Mar 06, 2020 8:38 pm

problem with mqtt

Post by llucaa » Fri Mar 06, 2020 9:04 pm

Hello to everyone
i have a problem with this program regarding the mqtt in fact it gives me this error message: ImportError: no module named 'umqtt' i don't know how to solve
thank you

P.S. forgive english but it is not my language :D :D

this is the program

import machine
import time
import dht
import network
from umqtt.simple import MQTTClient

def do_connect():
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print("connecting to network.....")
sta_if.connect(SSID, PASSWD)
while not sta_if.isconnected():
print("network config:",sta_if.ifconfig())


SERVER = "192.168.1."
TOPIC = "t_h"


d = dht.DHT22(machine.Pin(14))

while True:
t = d.temperature()
h = d.humidity()
msg = str(t) + "," + str(h)
except OSError:

User avatar
Posts: 1889
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: problem with mqtt

Post by Roberthh » Fri Mar 06, 2020 9:17 pm

These files arfe not always included in the build. You can find them in the micropython-lib: ... / ... /

You have to create a directory name umqtt on you board and copy these files to that directory. I do not know, which board you are using, so the method for copying varies.

Posts: 648
Joined: Sat Feb 03, 2018 7:02 pm

Re: problem with mqtt

Post by kevinkk525 » Fri Mar 06, 2020 9:43 pm

you also need to create a in that umqtt folder (an empty file).
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration):

Posts: 2
Joined: Fri Mar 06, 2020 8:38 pm

Re: problem with mqtt

Post by llucaa » Sat Mar 07, 2020 2:56 pm

I created the mqtt folder inside the esp8266 in the folder I inserted the empty file but after doing this it is as if the card had stopped working to connect to the card I use the picocom command from the mac terminal but doing so now gives me terminal ready but no I can write nothing and if I press the reset button on the board it does not reset correctly because it no longer executes the two files and if I did it before the creation of everything worked correctly I already tried to clear the memory of the card and reinstall micropython but nothing has changed what could have happened?

Post Reply