• 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 QoS and last_will  umqtt.simple library

Q&A Forum › MicroPython mqtt QoS and last_will  umqtt.simple library
0 Vote Up Vote Down
Peter Ashford asked 5 years ago

I’ve been using the micropython mqtt examples in the tutorial book and they work really well, I’ve been able to send messages and receive messages and even control devices flashed with tasmota.

I’ve also used the excellent introduction to node red to checkout messages and alter messages.

Can you give me an example of using ‘QoS’ and  ‘last_will’ from micropython ?

Can you also tell me what is the best way of checking that they have been set on the server ?

(I’m using  mosquitto on the raspberry pi ?)

Peter

Question Tags: MicroPython, MQTT, nodemcu
2 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Peter
When publishing messages, you can pass the QoS as an argument.
For example:

client.publish(topic_pub, msg, qos=1)

The QoS can be 0, 1, or 2. When you don’t set the QoS, it is set to 0, by default.
I’ve never used the last_will method. But accordingly to the library, it should be used liked this:

client.set_last_will(topic, msg, qos=0)

What do you mean by “checking that they have been set on the server?” You mean you want to be sure that the last_will is working?
For that, you need to disconnect the publisher and see if the subscribers get the last will message.
I hope this helps.
Regards,
Sara
 
 

0 Vote Up Vote Down
Peter Ashford answered 5 years ago

Thank you

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.