Umqtt.simple python Node-Red example

Hi there.
I got my Raspberry Pico W to subscribe to a topic by using umqtt.simple. Now I want the Pico do do something. Therefore I want Node-RED to publish a message that can be read by the Pico.
When a specific message is sent the Pico does a specific action.
How to write the script in Python for the Pico W?
Can you please give me some code-examples?

Best regards,
your Dodo

Hi @beg1nner

On the basis you want Node RED to publish a message to the topic that is subscribed to on the python end, you will simply use the MQTT node to publish such message. The below message addressed to the MQTT OUT node will get you going (sent from a function node)

The MQTT Node will ask for your MQTT broker details

return {
    topic: 'My-Topic',
    payload: 'Some Content'
}

And finally

How to write the script in Python for the Pico W?

micropython-umqtt.simple2/example_sub_led.py at master · fizista/micropython-umqtt.simple2 (github.com)

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.