• 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 AND qos 1 or 2

Q&A Forum › Category: ESP32 › MQTT AND qos 1 or 2
0 Vote Up Vote Down
Jader Rosa asked 3 years ago

Hi,
I made some changes on the example code used at ‘MQTT Project – MQTT Client ESP32 #1’
I’m trying to use QOS 1 or 2 to make sure the ESP32 will get the message when it loses connection and comes back online again but it’s not working.
I have Mosquitto installed and working correctly on the Raspberry PI. When I send the command below via SSH it is successfully received on ESP 32:
mosquitto_pub -h 192.168.50.92 -p 1883 -t ‘client0001/machines/dryer004′ -m ’12’ -q 1
If I hold down the ESP32 reset button and send the above command via SSH it is not received when the ESP32 reconnects. What might I be missing? Could be something related with chipID? If yes how to set it?

Question Tags: MQTT ESP32
4 Answers
0 Vote Up Vote Down
Best Answer
Sara Santos Staff answered 3 years ago

Hi.
Is everything solved now?
Regards,
Sara

0 Vote Up Vote Down
Jader Rosa answered 3 years ago

Hi,
I found the solution. You have to add:
mqttClient.setCleanSession(false);
Below mqttClient.setServer(MQTT_HOST, MQTT_PORT); and use qos 1 or 2 to subscribe

0 Vote Up Vote Down
Jader Rosa answered 3 years ago

Hi Sara,
All sorted thanks 🙂
Jader

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

Great!
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
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.