I have even succeeded in loading the current python code from nod red to deebug.
I can do this by entering a command in the Raspberry Pi cmd command window.
However, I am not sure what to do next in node red.
As you can see, I have to give a command, but I don't know what function to add after the exec function.
Juno, Welcome to the forum!
What is the sensor you are using? can you provide a link to it?
So you have an exec
node running a pyton progran and it has returned a reply. It looks like it returned the help
message for the program. You will have to know what the program expects in order to get something back.
Depending on the sensor, you might be able to use an existing node,. Have you searched the flow tab to see if there is anything you can use?
You might check some of the I2C nodes.
I am using a temperature sensor. And I did a search, but it's only in i2c mode, so I leave a post. I'm using Python code provided by Atlas Scientific
This link sample code
After a quick look, that did not tell me what the sensor is. There are many temperature sensors, which do you have?
It is an ezo rtd sensor. The problem is with the python file. However, it is only possible by entering Python commands. It's easy in the cmd window in Raspberry Pi, but it's difficult in node red, so I leave a post.
This sensor spec
So how are you wiring it to the Pi?
If looks like if you are wiring it as an I2C device, you should be able to use the node-red-contrib-i2c node instead of the exec
node running the python code. Have you given it a try?
Rather than exec maybe use the node-red-node-daemon node. It is similar to exec but allows commands to be sent to a long running process. So the node starts your program but then you can send extra commands to control it if that is the way the python alllows.
I haven’t read the documentation of the EZO RTD in a couple weeks, but it can either be connected through UART or through I2C. So that’s what you should check first, which is yours currently set up for. If indeed i2c, you can follow the options given above. If UART, start with the RTD manual.
Yes I already checked. The problem is that the i2c scan is in atlas scientific ASCII code.
So I'm going to proceed with Python code.
When you run a separate command that executes a Python file, debug tries to check it.
I did as you said. But strangely, when I run it as a daemon, the python file does not run.
For exec, it comes directly from the deebug window.
I don't know what the difference is, but the test result turned out to be disabled.
I have already switched from uart to i2c mode.
I have already checked in the command window.
Thank you for caring me.
As a test, can you run outside of Node-RED
echo poll | python i2c.py
And see if that starts polling the device
The thing is that that python code looks to be interactive. If you don't pass it a command, it returns the help
list. While you might be able to use it, the commands will have to be sent as a paramater in the exec node.
Currently in the exec node, you have the append
msg.payload checked off. That means whatever is passed in to the exec
node gets sent to the python progran as a parameter. Currently you are sending in a timestamp and the python rogram doesn't know what to do with it so it returns the Help
.
It's possible that you could send in a valid command to get some data back, but you should run the python code in a cli and learn what you have to send.
Earlier you said
The problem is that the i2c scan is in atlas scientific ASCII code.
can you explain this and show a debug of what the output is?
Yes the python takes a command - which is why I was suggesting trying to pipe said command directly into it.
Not sure why daemon didn't work - the setup of the node is slightly different in that only the command goes into the command field then any parameters in the extra parameters field. - You may also may need -u in order to stop python buffering any output - which I suspect is what was happening.
so something like
then use an inject to send commands like
poll
etc
It is possible to check. thank you for telling me.
Strangely, it wasn't just the daemon. I don't know what the problem is.
It is like this. It is said to be structured in i2c mode.
I would like to support a node-red atlas scientific sensor.
Would you be willing to add the node-red-contrib-I2C and connect it to a debug
node (set to display the Complete msg object) to see if it returns something. It is quite possible that the data that comes back can be converted to the temperature.
@zenofmud there are known issues with the default install of that i2c node - so I would not go there just yet in case it starts another can of worms.
Hi, did you manage to make it work?