I have connected a CCS811 sensor with Raspberry PI and I have written a python script to output/print the sensor values. It works fine in the linux terminal.
What are the methods to read the sensor data in Node-red and export it to a MQTT broker?
PS: I am a bit new to Node-red programming and Raspberry Pi
You can use an exec node to run your python script. Alternatively you may be able to do it directly in node-red but I am not an I2C expert so I don't know about that.
If you do it in an exec node use the full path to the script. You may need the full path to python itself too.
Show us the error and show us how you have configured the exec node (you can paste a screenshot here). If you are sending parameters to it in the message feed it into a debug node and paste that too.
Does it reconnect after a while?
How did you install node-red?
In a terminal run
node-red-stop
node-red-start
which will start node red showing the log in the terminal. Leave that open and click your inject node and see what it shows in the terminal. If you don't understand it then copy/paste the complete output from the start here. Use the </> button when pasting it in. I suspect node-red is crashing for some reason, but that may be wrong.
I am surprised that not having the python command (or perhaps it was the payload append) crashed node-red, if that is what was happening. I would have expected an error from the exec node, but not a crash. Perhaps there was a bug in the version of node-red or nodejs that you currently have.
Node red was crashing and restarting as there was no python command...
A rookie mistake from my side but @Colin@krambriw thank you very much for your support and immediate replies.
That shouldn't happen, it should not crash node red, just generate an error in the debug output. Have you still got the log? On the other hand if you plan to do the upgrade by running the script then do that first and then take the python command out again and see if it still crashes.