# Send data from C Program to Node-Red

**URL:** <https://discourse.nodered.org/t/send-data-from-c-program-to-node-red/5471>\
**Category:** General\
**Created:** [4 December 2018 10:27 UTC](https://discourse.nodered.org/t/send-data-from-c-program-to-node-red/5471 "2018-12-04T10:27:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![PhilGood](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@PhilGood](https://discourse.nodered.org/u/PhilGood)\
**Post date:** [4 December 2018 10:27 UTC](https://discourse.nodered.org/t/send-data-from-c-program-to-node-red/5471/1 "2018-12-04T10:27:31Z")

</div>

Hi,  
I'm newbie to Node-Red.  
I work on a Raspberry Pi3.  
I developed a C program that runs on the Raspberry. I want to periodically send data to Node-Red.  
What is the best way.  
Thank you for your comeback.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 December 2018 11:31 UTC](https://discourse.nodered.org/t/send-data-from-c-program-to-node-red/5471/2 "2018-12-04T11:31:16Z")

</div>

I would look at using MQTT. I am sure there must be an MQTT library for C.

---

<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:** [4 December 2018 12:36 UTC](https://discourse.nodered.org/t/send-data-from-c-program-to-node-red/5471/3 "2018-12-04T12:36:23Z")

</div>

Lots of ways to do this. I suggest expanding your requirements which might help us give more focused help.

---

<div class="post-metadata">

**Author:** ![PhilGood](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@PhilGood](https://discourse.nodered.org/u/PhilGood)\
**Post date:** [4 December 2018 13:22 UTC](https://discourse.nodered.org/t/send-data-from-c-program-to-node-red/5471/4 "2018-12-04T13:22:32Z")

</div>

Thank you Colin and Julian.  
I am rather electronic.  
I made an embedded device and I want to make a graphical interface (web server) to view 2 parameters, every 500 ms. These 2 parameters are the result of a calculation from my C program. The C program and the web server (with Node-RED) runs on the same Raspberry.  
I think that eventually I will also use the web server to pass parameter to my embedded device, for its configuration.

---

<div class="post-metadata">

**Author:** ![PhilGood](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@PhilGood](https://discourse.nodered.org/u/PhilGood)\
**Post date:** [4 December 2018 20:28 UTC](https://discourse.nodered.org/t/send-data-from-c-program-to-node-red/5471/5 "2018-12-04T20:28:33Z")

</div>

For my need, described above:  
Are websockets adapted?  
Is it better to investigate MQTT or another technology?  
Nobody to help me?

---

<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:** [4 December 2018 20:40 UTC](https://discourse.nodered.org/t/send-data-from-c-program-to-node-red/5471/6 "2018-12-04T20:40:35Z")

</div>

You could use web sockets if you are happy to code them on C. Or just a local udp connection. Or tcp. Up to you.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [4 December 2018 20:55 UTC](https://discourse.nodered.org/t/send-data-from-c-program-to-node-red/5471/7 "2018-12-04T20:55:17Z")

</div>

There are many ways it could be done, it is likely to be a case of picking an approach you're most comfortable with.

One option that hasn't been suggested yet is to run your C program using the Node-RED Exec node, and capture whatever it prints to stdout in your node-red flow. We have a number of nodes that use that technique under the covers; they invoke a python script to interface with particular bits of hardware and use stdin/out to communicate with it.
