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

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.

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) 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.

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".

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