Temperature in Node red

Hi . Trying to get some help

I have the following setup
Rapsberry pi
Relays
Temperature sensor ds18d20
So what I'm trying to do is setup the temperature with a slider . Then if the temp from the sensor is below the temp set in the slider, then the relay some switch on or off if temp is above the set temp.

Hi Warren, welcome to the forum!

It sounds like you have made a stab at creating your flow. If so, providing a copy of the flow would be helpful if you are having problems.

Also letting us know what 'extra' nodes (i.e. node-red-contrib-???) you are using will help and what version of Node-RED and node,js and the dashboare are you using. You can find all three in the startup log for node-red.

What have you tried so far?

Hi Zenofmud

Thank you for the replay

The following is install
node-red-dashboard 2.29.0
node-red-contrib-ds18b20-sensor
node-red-contrib-sensor-ds18b20
node-red-contrib-ui-digital-display
Node red v1.3.4 on raspberry pi

I have it working with the slider or the senor but with both of them at the some time.

Here is the flow .

[{"id":"8af81048.8fd3","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"dfc4d3fa.da9c3","type":"change","z":"8af81048.8fd3","name":"","rules":[{"t":"set","p":"router","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":260,"wires":[["e9f22e.53019dd","6a3cb876.bda2c8"]]},{"id":"e8c699c1.7bd3d","type":"inject","z":"8af81048.8fd3","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":400,"wires":[["f57f5c83.093b4"]]},{"id":"f57f5c83.093b4","type":"switch","z":"8af81048.8fd3","name":"","property":"router","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"lte","v":"25","vt":"str"},{"t":"gte","v":"25","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":310,"y":400,"wires":[["6eea1b84.8be9ac"],["a2c95c56.ee0cd","c6075a73.eb74c8"],["cc7a93bb.557c4","7a36d7b.28cc328"]]},{"id":"6eea1b84.8be9ac","type":"debug","z":"8af81048.8fd3","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1150,"y":340,"wires":[]},{"id":"a2c95c56.ee0cd","type":"debug","z":"8af81048.8fd3","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1110,"y":500,"wires":[]},{"id":"e9f22e.53019dd","type":"debug","z":"8af81048.8fd3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":860,"y":240,"wires":[]},{"id":"fe56a2a0.62a95","type":"ui_slider","z":"8af81048.8fd3","name":"","label":"slider","tooltip":"","group":"415ff655.a1d8f8","order":4,"width":0,"height":0,"passthru":true,"outs":"all","topic":"topic","topicType":"msg","min":"1","max":"60","step":"2","x":340,"y":120,"wires":[["dfc4d3fa.da9c3"]]},{"id":"6a3cb876.bda2c8","type":"ui_digital_display","z":"8af81048.8fd3","name":"","group":"415ff655.a1d8f8","order":5,"width":0,"height":0,"digits":5,"decimals":1,"x":770,"y":180,"wires":[]},{"id":"cc7a93bb.557c4","type":"debug","z":"8af81048.8fd3","name":"25","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1060,"y":640,"wires":[]},{"id":"9d708e6d.a4fdf","type":"sensor-ds18b20","z":"8af81048.8fd3","name":"Temp","topic":"","sensorid":"28-3c01d607c958","timer":"1","repeat":true,"x":450,"y":60,"wires":[["bee69718.fd14c8"]]},{"id":"4b7d05ce.27cf1c","type":"inject","z":"8af81048.8fd3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":80,"wires":[["9d708e6d.a4fdf"]]},{"id":"65fe6f63.dfffa","type":"rpi-gpio out","z":"8af81048.8fd3","name":"","pin":"40","set":"","level":"0","freq":"","out":"out","x":810,"y":660,"wires":[]},{"id":"c6075a73.eb74c8","type":"change","z":"8af81048.8fd3","name":"on","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":600,"wires":[["65fe6f63.dfffa"]]},{"id":"7a36d7b.28cc328","type":"change","z":"8af81048.8fd3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":760,"wires":[["735602e3.93ca1c"]]},{"id":"735602e3.93ca1c","type":"rpi-gpio out","z":"8af81048.8fd3","name":"","pin":"40","set":"","level":"0","freq":"","out":"out","x":890,"y":780,"wires":[]},{"id":"bee69718.fd14c8","type":"debug","z":"8af81048.8fd3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1010,"y":60,"wires":[]},{"id":"415ff655.a1d8f8","type":"ui_group","name":"Test","tab":"622a3108.4411e","order":1,"disp":true,"width":"6","collapse":false},{"id":"622a3108.4411e","type":"ui_tab","name":"Test machine","icon":"dashboard","disabled":false,"hidden":false}]

post editied to add ``` before and after code paste to make it importable

Are you doing something for aquariums?

Yes basically the same principle.

Why have you got both of these installed?

sorry I'm using rpi-ds18b20

ok, looking at your flow, you need to compare the incoming temperature from the sensor to the value you have stored in the flow variable and have that result control the relays

you are using node-red-contrib-sensor-ds18b20 so you should get rid of the other one to keep from confusing your self (and others :grin:)

I dont know if I got you right, but here is what you can do:

you can store the value from the sensor into context with flow.set into e.g. sensorTemp and the value of slider: setupTemp.

then you create a function where you compare this both values triggered with an interval.

[{"id":"1c42a283.991b2d","type":"ui_slider","z":"8af81048.8fd3","name":"","label":"slider","tooltip":"","group":"415ff655.a1d8f8","order":4,"width":0,"height":0,"passthru":true,"outs":"all","topic":"topic","topicType":"msg","min":"1","max":"60","step":"2","x":170,"y":680,"wires":[["c6a4cb7.69a5d38"]]},{"id":"c6a4cb7.69a5d38","type":"change","z":"8af81048.8fd3","name":"","rules":[{"t":"set","p":"setupTemp","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":680,"wires":[[]]},{"id":"f0814783.f25ae8","type":"sensor-ds18b20","z":"8af81048.8fd3","name":"Temp","topic":"","sensorid":"28-3c01d607c958","timer":"1","repeat":true,"x":230,"y":760,"wires":[["355ac5d4.71a31a"]]},{"id":"355ac5d4.71a31a","type":"change","z":"8af81048.8fd3","name":"","rules":[{"t":"set","p":"sensorTemp","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":760,"wires":[[]]},{"id":"812dd060.a385c","type":"inject","z":"8af81048.8fd3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":860,"wires":[["59225cb3.f2b664"]]},{"id":"59225cb3.f2b664","type":"function","z":"8af81048.8fd3","name":"","func":"if (flow.get(\"setupTemp\")>flow.get(\"sensorTemp\")){\n    msg.payload = true;\n}else if (flow.get(\"setupTemp\")<flow.get(\"sensorTemp\")){\n    msg.payload = false;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":860,"wires":[["428a56cd.031548"]]},{"id":"428a56cd.031548","type":"rpi-gpio out","z":"8af81048.8fd3","name":"","pin":"40","set":"","level":"0","freq":"","out":"out","x":600,"y":860,"wires":[]},{"id":"415ff655.a1d8f8","type":"ui_group","name":"Test","tab":"622a3108.4411e","order":1,"disp":true,"width":"6","collapse":false},{"id":"622a3108.4411e","type":"ui_tab","name":"Test machine","icon":"dashboard","disabled":false,"hidden":false}]

or you can compare your output of the sensor directly with your stored value from the slider. In this case you need to change the function like this:

if (msg.payload < flow.get("sliderValue")){
msg.payload=true;
}else if (msg.payload > flow.get("sliderValue")){
msg.payload=false;
}
return msg;

Hi @Warren, you could store the value from the sensor into context with flow.set, you can use "Change node":

Captura de pantalla 2021-05-21 a la(s) 11.26.02 a. m.

Captura de pantalla 2021-05-21 a la(s) 11.26.12 a. m.

and then with a "switch node" compare your output of the slider, with your stored value from sensor, "flow.temperature":

Captura de pantalla 2021-05-21 a la(s) 11.33.51 a. m.
Captura de pantalla 2021-05-21 a la(s) 11.34.09 a. m.

Hi All . Thank you for the information . It's helped alot

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.