How can I combine two dht11 sensor flow to an average reading

345 views
Skip to first unread message

ivar denstore

unread,
Dec 15, 2017, 5:20:47 AM12/15/17
to Node-RED
hi

I am improving my big terrarium. In the past I have always had just one DHT11 sensor that manages everything with humidity and temperature. but now I have installed one more dht11 sensors now i have one on each side of my terrarium. Both sensors working and I can read from both perfectly with debug node.

 How can I get these two dht11 sensors to combine temperature and humidity from two sensors to an average of temperature and humidity ??

i will post my code here . i just need to combine these two dht11 readings to one humidity and one temp an average reading of them:) 


[{"id":"a7b0a831.841918","type":"rpi-dht22","z":"4251d470.1c915c","name":"","topic":"","dht":"11","pintype":"0","pin":"18","x":100,"y":180,"wires":[["44272692.13bb08","5d669d73.d1caa4"]]},{"id":"44272692.13bb08","type":"function","z":"4251d470.1c915c","name":"temp","func":"msg.payload = parseFloat(msg.payload);\nmsg.topic = \"setCurrent\";\nreturn msg;","outputs":"1","noerr":0,"x":430,"y":240,"wires":[["f5bb641.1885498","97280427.1e4f98"]]},{"id":"5d669d73.d1caa4","type":"function","z":"4251d470.1c915c","name":"humidity","func":"msg.payload = msg.humidity\nreturn msg;","outputs":1,"noerr":0,"x":417,"y":443,"wires":[["5abcc52c.fa196c"]]},{"id":"bac5eb36.3f9708","type":"inject","z":"4251d470.1c915c","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"x":110,"y":420,"wires":[["ce2ea1b.95b446"]]},{"id":"5d7abef9.f5c39","type":"ui_gauge","z":"4251d470.1c915c","name":"himidity right","group":"65a5d52b.64a33c","order":2,"width":"6","height":"6","gtype":"gage","title":"luftfuktighet ","label":"%","format":"{{value}}","min":0,"max":"80","colors":["#0000ff","#00ff00","#ff0000"],"seg1":"54","seg2":"72","x":750,"y":520,"wires":[]},{"id":"e07766b6.bb5338","type":"ui_chart","z":"4251d470.1c915c","name":"luft temprature graf","group":"bd624b81.654bd8","order":1,"width":"4","height":"5","label":"luft temperatur ","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"50","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#008000","#aec7e8","#ff7f0e","#ff0000","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":810,"y":140,"wires":[[],[]]},{"id":"f5bb641.1885498","type":"ramp-thermostat","z":"4251d470.1c915c","name":"","profile":"1611a792.9e3828","hysteresisplus":"0","hysteresisminus":"0","x":600,"y":140,"wires":[["48da2f34.1a431"],["e07766b6.bb5338"],["e07766b6.bb5338"]]},{"id":"48da2f34.1a431","type":"change","z":"4251d470.1c915c","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"1","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":100,"wires":[["53b81b33.989104","1b75c102.44973f","d3ac52d8.3d93d"]]},{"id":"ce2ea1b.95b446","type":"rpi-dht22","z":"4251d470.1c915c","name":"","topic":"","dht":"11","pintype":"0","pin":"27","x":120,"y":580,"wires":[[]]},{"id":"d982108e.b5cee","type":"function","z":"4251d470.1c915c","name":"temp","func":"msg.payload = parseFloat(msg.payload);\nmsg.topic = \"setCurrent\";\nreturn msg;","outputs":"1","noerr":0,"x":790,"y":340,"wires":[["3fbf1af7.a6f4d6","1af90d58.835b53","c3b2a8de.811308"]]},{"id":"3fbf1af7.a6f4d6","type":"ramp-thermostat","z":"4251d470.1c915c","name":"","profile":"2b8f252f.c13d4a","hysteresisplus":"0","hysteresisminus":"0","x":940,"y":520,"wires":[["b88930f.8685ed"],["abfe512c.2f95c"],["abfe512c.2f95c"]]},{"id":"1af90d58.835b53","type":"ramp-thermostat","z":"4251d470.1c915c","name":"","profile":"930ab0cd.06875","hysteresisplus":"0","hysteresisminus":"0","x":940,"y":400,"wires":[["8fc716b7.d7d9a8"],[],[]]},{"id":"97280427.1e4f98","type":"ui_gauge","z":"4251d470.1c915c","name":"air temp right","group":"65a5d52b.64a33c","order":1,"width":"6","height":"6","gtype":"gage","title":"luft temperatur","label":"°C","format":"{{value}}","min":0,"max":"40","colors":["#0000ff","#00ff00","#ff0000"],"seg1":"23","seg2":"26","x":610,"y":220,"wires":[]},{"id":"c3b2a8de.811308","type":"ramp-thermostat","z":"4251d470.1c915c","name":"","profile":"753c6a4c.80e8f4","hysteresisplus":"0","hysteresisminus":"0","x":940,"y":280,"wires":[["d00b6bcc.b65be8"],["e6b2a492.d61268"],["e6b2a492.d61268"]]},{"id":"c185ef70.42e62","type":"inject","z":"4251d470.1c915c","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"x":110,"y":380,"wires":[["a7b0a831.841918"]]},{"id":"5abcc52c.fa196c","type":"change","z":"4251d470.1c915c","name":"","rules":[{"t":"set","p":"humidity","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":613,"y":442,"wires":[["d982108e.b5cee","5d7abef9.f5c39"]]},{"id":"776b0937.0d8cd8","type":"comment","z":"4251d470.1c915c","name":"steg 1 fläkt 5v","info":"","x":930,"y":232,"wires":[]},{"id":"8958cbc7.313ae8","type":"comment","z":"4251d470.1c915c","name":"luftfuktare","info":"","x":920,"y":360,"wires":[]},{"id":"d323b8d9.a10808","type":"comment","z":"4251d470.1c915c","name":"steg 2 fläkt 12v","info":"","x":940,"y":480,"wires":[]},{"id":"44523e81.d8aa2","type":"debug","z":"4251d470.1c915c","name":"","active":false,"console":"false","complete":"true","x":631,"y":383,"wires":[]},{"id":"65a5d52b.64a33c","type":"ui_group","z":"","name":"mätare luftfuktighet","tab":"91e4af9a.f1a05","order":2,"disp":true,"width":"6"},{"id":"bd624b81.654bd8","type":"ui_group","z":"","name":"status luft tempratur/markvärme","tab":"ea8432c0.64854","order":3,"disp":true,"width":"6"},{"id":"1611a792.9e3828","type":"profile","z":"","name":"temp luft","time1":"00:00","temp1":"23.5","time2":"08:00","temp2":"23.5","time3":"08:01","temp3":"26","time4":"20:00","temp4":"26","time5":"20:01","temp5":"23.5","time6":"23:59","temp6":"23.5","time7":"","temp7":"","time8":"","temp8":"","time9":"","temp9":"","time10":"","temp10":""},{"id":"2b8f252f.c13d4a","type":"profile","z":"","name":"fukt 12v","time1":"00:00","temp1":"74","time2":"08:00","temp2":"74","time3":"08:01","temp3":"70","time4":"20:00","temp4":"70","time5":"20:01","temp5":"74","time6":"23:59","temp6":"74","time7":"","temp7":"","time8":"","temp8":"","time9":"","temp9":"","time10":"","temp10":""},{"id":"930ab0cd.06875","type":"profile","z":"","name":"luftfuktare","time1":"00:00","temp1":"70","time2":"08:00","temp2":"70","time3":"08:01","temp3":"63.8","time4":"20:00","temp4":"63.8","time5":"20:01","temp5":"70","time6":"23:59","temp6":"70","time7":"","temp7":"","time8":"","temp8":"","time9":"","temp9":"","time10":"","temp10":""},{"id":"753c6a4c.80e8f4","type":"profile","z":"","name":"fukt 5v fläkt","time1":"00:00","temp1":"71","time2":"08:00","temp2":"71","time3":"08:01","temp3":"64.5","time4":"20:00","temp4":"64.5","time5":"20:01","temp5":"71","time6":"23:59","temp6":"71","time7":"","temp7":"","time8":"","temp8":"","time9":"","temp9":"","time10":"","temp10":""},{"id":"91e4af9a.f1a05","type":"ui_tab","z":"","name":"terrarium","icon":"dashboard","order":1},{"id":"ea8432c0.64854","type":"ui_tab","z":"","name":"grafer över 2 dagar","icon":"dashboard","order":3}]

Colin Law

unread,
Dec 15, 2017, 5:35:40 AM12/15/17
to node...@googlegroups.com
I think this is another case for the use of the Join node to give you a Latest Values output that I have described a couple of times in last few days.
If you feed both values into a Join node, ensuring they have distinct topics (they may already I have not looked at your flow), say topics temp1 and temp2, and configure the Join node to Manual mode, Combine each msg.payload to create a key/value Object using the value of msg.topic as the key, send the message after 2 message parts (if you work through the Join node setup you will see what I mean), then the Join node will wait till values have been received for each topic and thereafter will pass on a message containing a payload consisting of {temp1: temp1value, temp2: temp2value} for each pair of messages received. You can feed that into a simple function node to combine the two values, or could do that in a Change node in fact.

Colin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/47c1d0b5-de9b-4777-aa41-86cdc09a7a10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ivar denstore

unread,
Dec 15, 2017, 7:26:28 AM12/15/17
to Node-RED
ok big thanks :) i'm not very good at this with node red. but thank you for taking the time and explaining :)

I'm looking for this contrib join node but really not much about it. I have read
all that exists about it but does not understand everything. Both my dht11 sensors are called temp1 and temp2 in topic. but I do not know how the contrib join node works would you be able to explain how to get join the node to work in manual mode?

Sincerely
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

Zenofmud

unread,
Dec 15, 2017, 7:49:38 AM12/15/17
to node...@googlegroups.com
this is from a post Colin made the other day:
Fortunately recent enhancements to the Join node allow this type of problem to be solved quite simply. First make sure that the messages from the two sources have different topics, for example "temp" and "manual". Feed these into a Join node configured with Mode manual, Combine Each msg.payload, To Create a Key/Value object, Using msg.topic, Send After set to 2, and the checkbox And Every Subsequent Message ticked.

Then the Join node will wait till it has received messages for both topics and will then pass on a message with msg.payload containing {temp: temperaturevalue, manual: espvalue}. Each time a new message is received (for either topic) it will pass on a new message with the latest values for each topic.

Now you can easily write a function node to determine what to do each time a new message with those latest values is received, combining the values of msg.payload.manual and msg.payload.temp as appropriate.

And here is a sample flow showing an example using a change node at the end instead of a function node.

-Paul

[{"id":"a0c180c4.b72a4","type":"inject","z":"ebeca0f2.8bd04","name":"","topic":"temp1","payload":"45","payloadType":"num","repeat":"","crontab":"","once":false,"x":160,"y":240,"wires":[["993580d.f0b3d"]]},{"id":"3ddc4671.4ab36a","type":"inject","z":"ebeca0f2.8bd04","name":"","topic":"temp2","payload":"48","payloadType":"num","repeat":"","crontab":"","once":false,"x":160,"y":400,"wires":[["993580d.f0b3d"]]},{"id":"993580d.f0b3d","type":"join","z":"ebeca0f2.8bd04","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","x":410,"y":340,"wires":[["524be38f.4dfe84"]]},{"id":"1b936e0f.f8aba2","type":"debug","z":"ebeca0f2.8bd04","name":"","active":true,"console":"false","complete":"payload","x":790,"y":340,"wires":[]},{"id":"3180acfb.93958c","type":"inject","z":"ebeca0f2.8bd04","name":"","topic":"temp2","payload":"85","payloadType":"num","repeat":"","crontab":"","once":false,"x":160,"y":460,"wires":[["993580d.f0b3d"]]},{"id":"e817019f.68314","type":"inject","z":"ebeca0f2.8bd04","name":"","topic":"temp2","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"x":160,"y":520,"wires":[["993580d.f0b3d"]]},{"id":"524be38f.4dfe84","type":"change","z":"ebeca0f2.8bd04","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.((temp1 + temp2)/2) ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":340,"wires":[["1b936e0f.f8aba2"]]}]

Dave C-J

unread,
Dec 15, 2017, 8:38:42 AM12/15/17
to node...@googlegroups.com
The join node is a core node built into Node-RED since version 16 I think

David Caparrós

unread,
Dec 15, 2017, 11:36:42 AM12/15/17
to Node-RED
It's not more easy to use same topic for booth DHT and inject the result on the core "smooth" node which directly allow you to get as result the mean value after specific number of readings?

Regards 

Zenofmud

unread,
Dec 15, 2017, 11:52:45 AM12/15/17
to node...@googlegroups.com
One down side that I can see with using the ‘join’ - in this case - is that you will only get a result if both topics arrive. 

In Ivar’s case he has two DHT11’s sending data. As long as they both send the data at approximately the same time every thing is fine.  But what if something happens...

Lets say at the start of the night they are both sending a temp of about 50 degrees. Both topics come into the join, are sent out as one and averaged and dealt with.

Then something strange happens - At 2:00 AM, the cat knocks over a lamp AND it breaks a window AND yanks out one of the DHT11’s AND it is zero degrees out. The room starts to get cold and the temp in the terrarium starts to go down.

The working DHT11 happily keeps sending the temp readings as they get lower and lower, BUT since the other one is not sending, nothing will come out of the ‘join’ node.

Ivar: You need to add extra checking to make sure the DHT11’s are sending data and somehow flag an alarm if they don’t

Moral of the story: Ivar…if you have a cat get rid of it (GRIN)

ivar denstore

unread,
Dec 15, 2017, 2:06:26 PM12/15/17
to Node-RED
It's no problem I have systems that warn you when the value rises above or below a certain value. then start heatings or fans depending on what is the trigger. that part of the system runs on a separate dht11 system. which only manages problem handling if the value rises too high or too low. the other dht11 manages all other systems as normal operations. :) have no cats haha :P

ivar denstore

unread,
Dec 15, 2017, 4:52:09 PM12/15/17
to Node-RED
Hello again . Now I have watched this all night read and read get everything to work in addition to the last node....

when we use contrib dht we get msg.payload as the temperature and msg payload humidity . I  use a function node and a change node to generate humidity and make it the only msg.payload. then input into join contrib. then on to change node where they will go together to a value but this is where  the problems starts i only get two separate values temp1 and temp 2 humidity . have to do something wrong because i do not get the change node to work :( probably something i do not understand

Here you can see my code how can I move on from this how do I get the last node to work?

[{"id":"a7b0a831.841918","type":"rpi-dht22","z":"4251d470.1c915c","name":"temp1","topic":"temp1","dht":"11","pintype":"0","pin":"18","x":86,"y":176,"wires":[["44272692.13bb08","5d669d73.d1caa4"]]},{"id":"5d669d73.d1caa4","type":"function","z":"4251d470.1c915c","name":"humidity","func":"msg.payload = msg.humidity\nreturn msg;","outputs":1,"noerr":0,"x":255,"y":177,"wires":[["5abcc52c.fa196c"]]},{"id":"5abcc52c.fa196c","type":"change","z":"4251d470.1c915c","name":"","rules":[{"t":"set","p":"humidity","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":318,"y":246,"wires":[["d982108e.b5cee","5d7abef9.f5c39","6e040fff.f351a"]]},{"id":"c305f7e2.43f0f8","type":"change","z":"4251d470.1c915c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.((temp1 + temp2)/2) ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":701,"y":326,"wires":[["ba40b98f.c35a88"]]},{"id":"ba40b98f.c35a88","type":"debug","z":"4251d470.1c915c","name":"","active":true,"console":"false","complete":"true","x":728,"y":416,"wires":[]},{"id":"235347a.b934ab8","type":"change","z":"4251d470.1c915c","name":"","rules":[{"t":"set","p":"humidity","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":312,"y":448,"wires":[["5ef4437a.1c7b1c","6e040fff.f351a"]]},{"id":"d2416026.07c36","type":"function","z":"4251d470.1c915c","name":"humidity","func":"msg.payload = msg.humidity\nreturn msg;","outputs":1,"noerr":0,"x":247,"y":539,"wires":[["235347a.b934ab8"]]},{"id":"ce2ea1b.95b446","type":"rpi-dht22","z":"4251d470.1c915c","name":"temp2","topic":"temp2","dht":"11","pintype":"0","pin":"27","x":108,"y":574,"wires":[["d2416026.07c36"]]},{"id":"bac5eb36.3f9708","type":"inject","z":"4251d470.1c915c","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"x":98,"y":414,"wires":[["ce2ea1b.95b446"]]},{"id":"c185ef70.42e62","type":"inject","z":"4251d470.1c915c","name":"","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":false,"x":98,"y":363,"wires":[["a7b0a831.841918"]]},{"id":"6c5f4671.e8e238","type":"debug","z":"4251d470.1c915c","name":"","active":false,"console":"false","complete":"true","x":733,"y":478,"wires":[]},{"id":"5ef4437a.1c7b1c","type":"debug","z":"4251d470.1c915c","name":"","active":false,"console":"false","complete":"true","x":732,"y":537,"wires":[]},{"id":"6e040fff.f351a","type":"join","z":"4251d470.1c915c","name":"","mode":"custom","build":"object","property":"topic","propertyType":"msg","key":"payload","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","x":510,"y":347,"wires":[["c305f7e2.43f0f8","6c5f4671.e8e238"]]}]

Stephen Mann

unread,
Dec 16, 2017, 12:48:44 AM12/16/17
to Node-RED
I am not familiar with the Node-Red dht nodes, but here's a couple of notes:

The dht11 and dht22 use different libraries, so make sure you are using the correct one.  If you read a dht11 using dht22 libraries, you will get erroneous, if any results.  Also, the dht22 is more accurate better than the DHT11, so if you need accuracy you should buy a few dht22's.

In my case I have dht11 and dht22 sensors on various ESP8266-01 modules around my home, each publishing their values on their own MQTT topics, like room/temperature and attic/temperature.  I have no need to average them in Node-red, so I can't help you with the original question.  I do average the dht11 readings in the ESP8266 code because they tend to fluctuate a lot.

Also, why do you have a function and a switch doing the same thing?  They both change mg.humidity to msg.payload.

ivar denstore

unread,
Dec 16, 2017, 5:50:02 AM12/16/17
to Node-RED
i used dht22 before but they just broken all the time so i'm using dht11 now i have to change the sensor once in the half-year due to the moisture and heat instead of once a week whit the dht22.. therefore i use dht11 :)

i saw it now yes got a little wrong there would not be two of the same thing. 

opened a new flow where I exprement to make this work.
but I have not managed to make it work.

Now I get from the last change node that should merge both msg.payload object to one here is something wrong or if I managed to do something wrong earlier in the flow :(

I'm getting this error "Invalid JSONata expression: The left side of the" + "operator must evaluate two a number"  it work if the payload is a number but i cant get the payload to be just  number :/ 

in the join node gives me a flow with both values in the same object contained in msg.payload: object {"temp1": "63.00", "temp2": "60.00"}

pls take o look at my flow and say if i do somthing wrong here .
'
[{"id":"e086efdc.e570e","type":"inject","z":"9e7cf005.4c99a","name":"","topic":"temp1","payload":"45","payloadType":"num","repeat":"","crontab":"","once":false,"x":106,"y":415,"wires":[["c51cff19.df38b"]]},{"id":"574c70b7.96d57","type":"inject","z":"9e7cf005.4c99a","name":"","topic":"temp2","payload":"48","payloadType":"num","repeat":"","crontab":"","once":false,"x":106,"y":459,"wires":[["c51cff19.df38b"]]},{"id":"c51cff19.df38b","type":"join","z":"9e7cf005.4c99a","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","x":751,"y":242,"wires":[["f1145baf.50dad8","57c93993.6db8c8"]]},{"id":"7ad7ebe6.aca584","type":"debug","z":"9e7cf005.4c99a","name":"","active":false,"console":"false","complete":"true","x":1180,"y":133,"wires":[]},{"id":"f1145baf.50dad8","type":"change","z":"9e7cf005.4c99a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.((temp1 + temp2)/2) ","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":944,"y":163,"wires":[["7ad7ebe6.aca584"]]},{"id":"742df64a.4ea928","type":"rpi-dht22","z":"9e7cf005.4c99a","name":"temp1","topic":"temp1","dht":"11","pintype":"0","pin":"18","x":271,"y":70,"wires":[["4be5aadb.3a11d4","383c2400.db217c"]]},{"id":"9b3f32de.785b1","type":"rpi-dht22","z":"9e7cf005.4c99a","name":"temp2","topic":"temp2","dht":"11","pintype":"0","pin":"27","x":273,"y":125,"wires":[["4be5aadb.3a11d4","f9bd6656.076348"]]},{"id":"13f67195.053e1e","type":"inject","z":"9e7cf005.4c99a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":94,"y":131,"wires":[["9b3f32de.785b1"]]},{"id":"a82b9151.ca503","type":"inject","z":"9e7cf005.4c99a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":94,"y":81,"wires":[["742df64a.4ea928"]]},{"id":"4be5aadb.3a11d4","type":"debug","z":"9e7cf005.4c99a","name":"","active":false,"console":"false","complete":"true","x":438,"y":81,"wires":[]},{"id":"383c2400.db217c","type":"change","z":"9e7cf005.4c99a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":513,"y":27,"wires":[["c51cff19.df38b","6c49bfaf.77a5"]]},{"id":"f9bd6656.076348","type":"change","z":"9e7cf005.4c99a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":136,"wires":[["c51cff19.df38b","6c49bfaf.77a5"]]},{"id":"6c49bfaf.77a5","type":"debug","z":"9e7cf005.4c99a","name":"","active":false,"console":"false","complete":"true","x":725,"y":85,"wires":[]},{"id":"8e3a8388.0afd","type":"comment","z":"9e7cf005.4c99a","name":"this works becuse the payload is a number","info":"","x":185,"y":500,"wires":[]},{"id":"61c25dd0.2347e4","type":"comment","z":"9e7cf005.4c99a","name":"this flow do not work ","info":"","x":95,"y":171,"wires":[]},{"id":"57c93993.6db8c8","type":"debug","z":"9e7cf005.4c99a","name":"","active":false,"console":"false","complete":"true","x":910,"y":200,"wires":[]}]

Zenofmud

unread,
Dec 16, 2017, 6:46:19 AM12/16/17
to Node-RED
The issue is that the DHT node is returning the Temperature and Humidity as ‘strings’ and the JSONata in the change is expecting them to be numbers. Try changing the JSONata expression to:
payload.(($number(temp1) + $number(temp2))/2) 

-- 
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
--- 
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

ivar denstore

unread,
Dec 16, 2017, 7:37:55 AM12/16/17
to Node-RED
whit our expression and som changing to the join node an to a function node . :D it is working now :D thanks man you are the best !! :) 

ivar denstore

unread,
Dec 16, 2017, 9:35:23 AM12/16/17
to Node-RED
whit your * expression

Stephen Mann

unread,
Dec 16, 2017, 5:07:21 PM12/16/17
to Node-RED
That's surprising since the DHT22 is rated for outdoor use and the DHT11 is not.  But if you get either one of them wet, they are toast.
You might consider using the DS18B20 digital Temperature Sensor.  It's waterproof and more accurate than the DHT series.  And it's cheaper.

Steve Mann

Julian Knight

unread,
Dec 17, 2017, 8:37:48 AM12/17/17
to Node-RED
You should also note that the accuracy of the DHT's, even the 22 is pants.

Try BME280 or HTU21D based sensors. But I agree with Steve that if you only want temperature, the DS18B20 is the one to go for.

ivar denstore

unread,
Jan 13, 2018, 12:48:33 PM1/13/18
to Node-RED
hi sorry for offline :) i now trying to run whit dht22 sensor placed on a better spot and see if they work good . the last time i run dht22  think they did get wet . i need temp and humid thats why i need to run dht11 or 22 ds18b20 is only temp :/ i have them to :)

Julian Knight

unread,
Jan 14, 2018, 8:41:48 AM1/14/18
to Node-RED
As mentioned, the alternative sensors are far better. The DHT's also drift over time and don't cope well if you have excessive humidity. The reality with DHT22's even is that you don't get better than +/- 10-20 humidity% - try comparing two side-by-side for example. Even the reported temperatures can be several degrees different which has a big impact on the reported humidity levels.

Used to be that the DHT's were the only affordable option for low-cost sensors but this is no longer the case.
Reply all
Reply to author
Forward
0 new messages