# How to send data from python console to Node-Red on raspberry pi

**URL:** <https://discourse.nodered.org/t/how-to-send-data-from-python-console-to-node-red-on-raspberry-pi/40739>\
**Category:** General\
**Created:** [10 February 2021 10:58 UTC](https://discourse.nodered.org/t/how-to-send-data-from-python-console-to-node-red-on-raspberry-pi/40739 "2021-02-10T10:58:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![saeed1](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@saeed1](https://discourse.nodered.org/u/saeed1)\
**Post date:** [10 February 2021 10:58 UTC](https://discourse.nodered.org/t/how-to-send-data-from-python-console-to-node-red-on-raspberry-pi/40739/1 "2021-02-10T10:58:47Z")

</div>

Hello Guys,

I am reading the data of some temperature sensors using python on Raspberry pi. Now i want to send that data to node red application running on the same Raspberry pi. Does node-red has some built in node to receive this data on node-red?

How can i easily do it?

Thank you!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [10 February 2021 11:07 UTC](https://discourse.nodered.org/t/how-to-send-data-from-python-console-to-node-red-on-raspberry-pi/40739/2 "2021-02-10T11:07:21Z")

</div>

Depends - if it is a one time request then use the exec node to call your program - If it supplies data continuously then use the node-red-node-daemon node to call it.

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [10 February 2021 19:43 UTC](https://discourse.nodered.org/t/how-to-send-data-from-python-console-to-node-red-on-raspberry-pi/40739/3 "2021-02-10T19:43:26Z")

</div>

I've found MQTT perfect for this. My Python code "publishes" the data and node-red "subscribes" and reads it with an MQTT input node. I usually use a local mosquitto "broker" running on the Pi to do this "interprocess communication".

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [10 February 2021 21:28 UTC](https://discourse.nodered.org/t/how-to-send-data-from-python-console-to-node-red-on-raspberry-pi/40739/4 "2021-02-10T21:28:41Z")

</div>

Node-RED has lots of ways:

- exec node
- MQTT
- TCP
- UDP
- HTTP
- Websockets

For example, I use some BASH scripts that end with a call to a web page that Node-RED hosts with suitable data POSTed.

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [10 February 2021 21:58 UTC](https://discourse.nodered.org/t/how-to-send-data-from-python-console-to-node-red-on-raspberry-pi/40739/5 "2021-02-10T21:58:06Z")

</div>

I use python scripts to send MQTT to MQTT Node Red all the time. Easy to do, and keeps loading on sending device light. I even have a python based systemd service that accepts MQTT directives from NR via MQTT and then return data via MQTT to NR. In my case, I use a dedicated MQTT broker, to keep broker loading off front end device, and off NR device as well.

---

<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:** [11 April 2021 21:58 UTC](https://discourse.nodered.org/t/how-to-send-data-from-python-console-to-node-red-on-raspberry-pi/40739/6 "2021-04-11T21:58:25Z")

</div>

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