# Using exec node to graph real time data obtained from python script

**URL:** https://discourse.nodered.org/t/using-exec-node-to-graph-real-time-data-obtained-from-python-script/9617
**Category:** General
**Created:** [30 March 2019 18:24 UTC](https://discourse.nodered.org/t/using-exec-node-to-graph-real-time-data-obtained-from-python-script/9617 "2019-03-30T18:24:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![climatedeniers](https://avatars.discourse-cdn.com/v4/letter/c/f4b2a3/32.png) [@climatedeniers](https://discourse.nodered.org/u/climatedeniers)
#### Post date: [30 March 2019 18:24 UTC](https://discourse.nodered.org/t/using-exec-node-to-graph-real-time-data-obtained-from-python-script/9617/1 "2019-03-30T18:24:29Z")

</div>

I have been attempting to graph data obtained from a python script using Node-RED. Whenever I attempt to deploy the nodes and inject the timestamp, I lose connection with Node-RED. Below is the python code:

* * *

import RPi.GPIO as GPIO  
import time

import Adafruit\_MAX31855.MAX31855 as MAX31855

CLK1 = 16  
DO1 = 20  
CS1 = 21  
sensor1 = MAX31855.MAX31855(CLK1, CS1, DO1)

CLK2 = 13  
DO2 = 19  
CS2 = 26  
sensor2 = MAX31855.MAX31855(CLK2, CS2, DO2)

CLK3 = 23  
DO3 = 24  
CS3 = 25  
sensor3 = MAX31855.MAX31855(CLK3, CS3, DO3)

CLK4 = 17  
DO4 = 27  
CS4 = 22  
sensor4 = MAX31855.MAX31855(CLK4, CS4, DO4)

while True:  
temp1 = sensor1.readTempC() - 1.25  
temp2 = sensor2.readTempC()  
temp3 = sensor3.readTempC()  
temp4 = sensor4.readTempC()

```
print ('Thermocouple 1 Temperature: {0:0.3F}*C'.format(temp1))

time.sleep(2.0)

```

* * *

I am attempting to graph the variables temp1, temp2, temp3, and temp4 together on a real-time plot, but so far I have only tested trying to plot temp1.

My python file is saved in /home/pi/noderedthermocouple.py, and this is the exact line that I am inputting into the command blank in the properties of the exec node.

Also, if anyone has a better solution to graph the data from this python script using Node-RED, that would be greatly appreciated.

Thanks for your help.

---

<div class="post-metadata">

### Author: ![bohtho](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bohtho/32/6153_2.png) [@bohtho](https://discourse.nodered.org/u/bohtho)
#### Post date: [30 March 2019 19:45 UTC](https://discourse.nodered.org/t/using-exec-node-to-graph-real-time-data-obtained-from-python-script/9617/2 "2019-03-30T19:45:23Z")

</div>

I am not familiar with Python or if there’s a problem with the script but I use the daemon node ([node-red-node-daemon (node) - Node-RED](https://flows.nodered.org/node/node-red-node-daemon)) instead of the exec node for a long-running commandline java program. This node has some more options and its readme also has this tip:

> Some applications will automatically buffer lines of output. It is advisable to turn off this behaviour. For example, if running a Python app, the `-u` parameter will stop the output being buffered.

---

<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: [30 March 2019 20:30 UTC](https://discourse.nodered.org/t/using-exec-node-to-graph-real-time-data-obtained-from-python-script/9617/3 "2019-03-30T20:30:46Z")

</div>

Restart node-red and show us the log (starting from the welcome message) up to the point where it fails.  
Also tell us exactly what happens when you "lose connection with node-RED".

---

<div class="post-metadata">

### Author: ![climatedeniers](https://avatars.discourse-cdn.com/v4/letter/c/f4b2a3/32.png) [@climatedeniers](https://discourse.nodered.org/u/climatedeniers)
#### Post date: [30 March 2019 20:44 UTC](https://discourse.nodered.org/t/using-exec-node-to-graph-real-time-data-obtained-from-python-script/9617/4 "2019-03-30T20:44:19Z")

</div>

Thank you both for replying, I decided to go a different route and use the pythonshell node and so far things are working.
