• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

MQTT on D1 mini

Q&A Forum › Category: ESP8266 › MQTT on D1 mini
0 Vote Up Vote Down
Gerhard Wrede asked 6 years ago

Hello,

I’v a problem to connect to MQTT with my D1 mini!

Cann you help me?

Failed to connect to MQTT broker. Reconnecting... 
Traceback (most recent call last): 
File "main.py", line 65, in <module> 
File "main.py", line 56, in <module> 
NameError: name 'client' isn't defined
Code:
while True:
try:
client.check_msg()
if (time.time() - last_sensor_reading) > readings_interval:
msg = read_ds_sensor()
client.publish(topic_pub, msg)
last_sensor_reading = time.time()
except onewire.OneWireError:
print('Failed to read/publish sensor readings.')
time.sleep(1)
except OSError as e:
restart_and_reconnect()
3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Hi Gerhard.
I think you’re getting that error because you haven’t installed the umqttsimple library.
Can you double check that you have the library installed and try again_
Regards,
Sara
 

0 Vote Up Vote Down
Gerhard Wrede answered 6 years ago

I found the error, it was the port.

0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Ok. I’m glad it is solved now.
I’ll close this question.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.