# Umqtt.simple python Node-Red example

**URL:** <https://discourse.nodered.org/t/umqtt-simple-python-node-red-example/74261>\
**Category:** General\
**Created:** [27 January 2023 14:26 UTC](https://discourse.nodered.org/t/umqtt-simple-python-node-red-example/74261 "2023-01-27T14:26:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![beg1nner](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@beg1nner](https://discourse.nodered.org/u/beg1nner)\
**Post date:** [27 January 2023 14:26 UTC](https://discourse.nodered.org/t/umqtt-simple-python-node-red-example/74261/1 "2023-01-27T14:26:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [27 January 2023 14:38 UTC](https://discourse.nodered.org/t/umqtt-simple-python-node-red-example/74261/2 "2023-01-27T14:38:38Z")

</div>

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

```auto
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)](https://github.com/fizista/micropython-umqtt.simple2/blob/master/example_sub_led.py)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 March 2023 14:38 UTC](https://discourse.nodered.org/t/umqtt-simple-python-node-red-example/74261/3 "2023-03-28T14:38:56Z")

</div>

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