• 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

Micropython MQTT Not Connecting

Q&A Forum › Category: Raspberry Pi › Micropython MQTT Not Connecting
0 Vote Up Vote Down
krunal patel asked 2 years ago

Hello.  I am following one of your tutorials on your blog called, “MicroPython – Getting Started with MQTT on ESP32/ESP8266.  I uploaded the code for the first ESP32/ESP8266 and it is connecting to the WiFi network but I can’t connect to the MQTT raspberry pi broker.  I double-checked the IP address with the ‘hostname -I” command and reuploaded the code a few times but it still isn’t working.   Is there a way to fix this?
Thanks in advance.

Question Tags: MQTT Not Connecting
6 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
How did you install the Mosquitto broker?
Did you set permissions so that it is able to accept connections from outside the Raspberry Pi?
Regards,
Sara

0 Vote Up Vote Down
krunal patel answered 2 years ago

Thank you.  I didn’t know that you had to install permissions.  I just used these commands

pi@raspberry:~ $ sudo apt update 
pi@raspberry:~ $ sudo apt install -y mosquitto mosquitto-clients
pi@raspberry:~ $ sudo systemctl enable mosquitto.service
pi@raspberry:~ $ hostname -I

What is the command to access permissions
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
Check this tutorial: https://randomnerdtutorials.com/how-to-install-mosquitto-broker-on-raspberry-pi/
Scroll down to the section “Enable Remote Access/ Authentication”. Then, follow one of those two options.
Note that if you enable the option with username and password, then you need to pass the username and password on the code you upload to your board.
I hope this helps.
Regards
Sara

0 Vote Up Vote Down
krunal patel answered 2 years ago

I helps but I am getting a lot of junk.
I don’t get the success message but when I subscribed to hello using the OS console, it says that it is receiving the message.  I will count that as a success.         
Thanks for you help

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

What junk are you referring to?
Can you be a little more specific?
Regards,
Sara

1 Vote Up Vote Down
krunal patel answered 2 years ago

Sorry about the delay; here is what it says:
MICROPY_PY_BBUILTINS_STR_UNICODE
sz=1
out_sz=MP_STREAM_ERROR
out_sz=0
error=11
error!=0
n_args=2
That’s it. Thanks in advance

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

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 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.