HowTo: Node Red – Warning if humidity is too high

Especially in rooms where a lot of work is done with water or steam, you should always ventilate sufficiently to avoid damage and health risks caused by mold.

If you're one of those people who tend to forget things like this and happen to have a humidity sensor in the rooms in question, which also happens to be connected to your NodeRed installation, you can also be automatically reminded when the humidity is too high.

How to do this is described in the following article.

Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.

Affiliate links/advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support in being able to offer other useful projects in the future. 🙂 


Helpful articles:
To be able to use this configuration, NodeRed should of course already be installed.
How to prepare a RaspberryPi and then install NodeRed on it is described in the following articles.

The following articles describe what has to be done to prepare the RaspberryPi so far:
RaspberryPi – setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH

NodeRed – Installing NodeRed on the RaspberryPi
NodeRed – Install new nodes

Required material:

Required material:

In the following list you will find all the parts you need to implement this article.

Log into the NodeRed configuration interface

Before you can edit your NodeRed configuration, you must - if activated - first log into the NodeRed configuration interface.

View of the login dialog. Here you have to enter the login data that you specified during the configuration of the login. You can find information about this in the article NodeRed - set up user login.

Need to install nodes

For this example, in addition to the standard nodes, the nodes “node-red-node-pushbullet” and “node-red-dashboard” are also used. In order for this example to work for you, you have to install these nodes. How your node is installed in the article NodeRed – Install new nodes described.

Import node code

The core function of this example is to create a moving average from the most recent humidity values and then check whether this exceeds a certain value. In this context, moving average means that the average is always determined from the last (for example) ten measured values. This has the advantage that one-time peaks in the measured values do not cause an alarm. Only a permanent increase in humidity causes the value of the moving average to rise above the set limit and thus trigger an alarm.

To import this example into your NodeRed installation, you need to import the Node code below. You can find tips on this in the article NodeRed – Import and export node code.

After importing, remember to position the dashboard nodes on your dashboard. You can find tips on this in the article NodeRed - Create a user interface with dashboard nodes.

You may also need to provide an API key for the Pushbullet node. This is also in the article Register Pushbullet API Key described.

Node configuration view in the NodeRed editor.
View of the limit setting option in the dashboard.
[{"id":"f73f8a41.7d9278","type":"mqtt in","z":"4131a41e.b9233c","name":"","topic":"bathroomTemp","qos": "2","broker":"ddb40b41.78ae38","x":780,"y":1340,"wires":[["93e1108d.ad9c7"]]},{"id":"93e1108d.ad9c7 ","type":"smooth","z":"4131a41e.b9233c","name":"","property":"payload","action":"mean","count":"10" ,"round":"","mult":"single","x":960,"y":1340,"wires":[["d7851151.0479b","8465689.bf4d298"]]},{ "id":"8465689.bf4d298","type":"debug","z":"4131a41e.b9233c","name":"","active":false,"tosidebar":true,"console" :false,"tostatus":false,"complete":"false","x":1150,"y":1280,"wires":[]},{"id":"589714bd.e93cec","type ":"pushbullet","z":"4131a41e.b9233c","config":"1788f4a5.0c63bb","pushtype":"note","title":"SmartHome","chan":""," name":"SmartHome","x":1470,"y":1340,"wires":[]},{"id":"d7851151.0479b","type":"function","z": "4131a41e.b9233c","name":"check","func":"msg.payload=msg.payload>; return msg; ","outputs":1,"noerr":0, "x":1110,"y":1340,"wires":[["6a9e9862.05e698"]]},{"id":"290bb7a0.63d8c8","type":"ui_numeric","z": "4131a41e.b9233c","name":"","label":"Max.Humidity Bathroom","group":"6938a6b5.5f1de8","order":0,"width":0,"height": 0,"passthru":true,"topic":"","format":"{{value}}","min":"30","max":"100","step":1," x":1210,"y":1380,"wires":[["7c2998ea.ef3658"]]},{"id":"dd457329.9d893","type":"inject","z":" 4131a41e.b9233c","name":"load StandardValue","topic":"","payload":"70","payloadType":"num","repeat":"","crontab":"" ,"once":true,"onceDelay":0.1,"x":960,"y":1380,"wires":[["290bb7a0.63d8c8"]]},{"id":"7c2998ea.ef3658" ,"type":"function","z":"4131a41e.b9233c","name":"save maxHumiBath","func":"; return msg;","outputs":1,"noerr":0,"x":1430,"y":1380,"wires":[[]]},{"id":"6a9e9862.05e698", "type":"trigger","z":"4131a41e.b9233c","op1":"Humidity in bathroom is high.","op2":"0","op1type":"str","op2type" :"str","duration":"0","extend":false,"units":"ms","reset":"false","bytopic":"all","name":"", "x":1280,"y":1340,"wires":[["589714bd.e93cec","ee53da08.077d68"]]},{"id":"ee53da08.077d68","type":"ui_toast ","z":"4131a41e.b9233c","position":"dialog","displayTime":"25","highlight":"","outputs":1,"ok":"OK"," cancel":"","topic":"Information","name":"Information","x":1470,"y":1300,"wires":[[]]},{"id":" ddb40b41.78ae38","type":"mqtt-broker","z":"","name":"Server-Mqtt","broker":"","port":"1883 ","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0", "birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":"" },{"id":"1788f4a5.0c63bb","type":"pushbullet-config","z":"","name":"FabsPushbullet"},{"id":"6938a6b5.5f1de8", "type":"ui_group","z":"","name":"Values","tab":"fddf98ef.773da8","disp":true,"width":"6","collapse" :false},{"id":"fddf98ef.773da8","type":"ui_tab","z":"","name":"Settings","icon":"dashboard"}]

Adjust values

In this configuration, two values determine the function.
On the one hand, there is the limit value, which determines at what humidity level an alarm is issued. This can be set directly via the dashboard node.

On the other hand, by increasing or decreasing the number of values from which the moving average is determined, you can control how “slowly” - but more precisely - the alarm reacts. If the moving average refers to very few values, changes (and also exceeding the limit value) are detected more quickly. Unfortunately, even very short-term changes in measured values such as measurement errors can lead to the alarm being triggered incorrectly.

It's best to experiment a little with the values and see what's best for your case. In this example, the limit value is 70% humidity with ten values on which the moving average is based.

In the configuration of the smooth node you can set in the “over the most recent…values” field how many values the moving average is formed over.

Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at       

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.