In the past few weeks I’ve had the problem that my freezer door didn’t close properly. As a result, at least one night, the refrigerator door was not properly closed for almost seven hours.
When that happened to me (again) a few days later, I decided to do something about it. It would be enough for me to be informed if I left the refrigerator door open for too long.
After a little experimentation, the NodeRed code described below came out. With this (and a Wifi-enabled socket that is also able to measure the energy used) you can see whether the fridge door is closed or open based on the energy consumption of the fridge.
The NodeCode continuously measures the power consumption (using the socket) and detects when it is too high. This is typically the case when the refrigerator door is left open too long, which causes the temperature inside to rise and this in turn leads to the refrigerator compressor starting up more often or not going out at all.
More details and what you have to consider to set up your own refrigerator monitoring are described in the following article.
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
So that you can install new nodes, NodeRed should of course already be installed.
How to prepare a RaspberryPi and then install NodeRed on it is described in the following articles.
RaspberryPi – Setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH
NodeRed – Installation of NodeRed on the RaspberryPi
NodeRed – Installing new nodes
NodeRed – Import and export node code
In the following list you will find all the parts you need to implement this article.
Install required nodes
No special nodes are actually required for this flow. Most of them belong to the standard nodes of NodeRed. Only the dashboard node is required to visualize the collected data. You can find more information about this in the article NodeRed – Creating a user interface with dashboard nodes.
How it works
The function is best explained with the help of the pictures below and a little explanation of how a refrigerator works.
A fridge uses a compressor to cool the air inside. This fridgecompressor is switched on and off automatically via a thermostat if the air inside the fridge is too warm. This means (for my fridge, for example) that the fridge compressor is only really switched on for about 30 minutes per hour. For the rest of the time, the temperature remains inside due to the good thermal insulation of a fridge. These values can of course be different for other fridges. For example, if a fridge is better insulated, the fridge compressor does not have to start as often.
In any case, you can make use of the running time of the compressor. Because if it is permanently too warm in the fridge (for example due to an open door) the compressor will also remain switched on for longer. If the temperature inside the fridge does not drop, this can even mean that the fridge compressor remains switched on permanently.
A switched on compressor can in turn be recognized by the power consumption of the fridge. My fridge (for example) consumes around 80 to 100W when the fridge compressor is switched on. But since it is only switched on for about 30 minutes per hour, this corresponds to a consumption of 40 to 50W per hour.
You may already notice: If you know what consumption is normally to be expected per hour and suddenly realize that the current consumption of the fridge is higher, you can be pretty sure that this is due to a cooling compressor that has been running too long and therefore the fridge door must be opened for a longer time.
The detection of the past average consumption is very slow.
In the area marked in red and marked with a 1, you can see the consumption of my fridge when the door is open. You can see that the consumption is almost continuously around 80 to 100W.
In the same area there is also a slightly darker blue line which shows the average energy consumption during this period.
As you can see there, the average energy consumption increases. Unfortunately, very slowly. A reliable detection would therefore be possible either very late or not very reliably.
After a few more experiments, I found a better way to detect the compressor duty cycle. If you scan the energy consumption for possible edges, you can find out quite reliably when the compressor is switched on and off. As soon as you have these two points in time you also know the running time of the compressor.
Now you can monitor the switch-on time according to a similar principle as before the energy consumption: If the compressor is switched on significantly longer than the average switch-on time, you can assume that this is due to an open door.
This procedure does not recognize an open refrigerator door “directly” but (with my refrigerator) within 30 to 45 minutes. This is enough to save at least a few foods from thawing.
So that the measurement of the energy consumption of your fridge is possible in the first place, you need a socket or an adapter that sends the current energy consumption of your fridge to your smartHome. I used a WiFi adapter with energy measurement, which I also flashed with the Tasmota firmware. The NodeRed code then receives its data later via MQTT.
How you can flash an adapter plug with the Tasmota firmware and configure it a little better is partly described in the article Tasmota – Flashing Firmware with TuyaConvert.
Displayed data in the dashboard
If you import the NodeCode below into your NodeRed configuration, the following views will also be added to your dashboard.
In this view you can see at the top a text field in which it is indicated whether there are already enough measured values to recognize an abnormal consumption value due to the average consumption.
In the middle area, the past and average energy consumption of your refrigerator is displayed.
In the lower area, the switch-on phases of the compressor determined from the energy consumption can be seen. The duration is entered in seconds. The current, previous and the average duty cycle are entered.
In addition to the history data above, you will also see the data on the left.
At the top you can see the past average consumption of your fridge.
In the middle the current consumption of your fridge
At the bottom, the last determined duty cycle of your fridge compressor is displayed.
Import node code
The NodeCode below contains everything necessary to evaluate the energy consumption of your refrigerator according to the scheme described above and, if necessary, to send you a notification via pushbullet. How you can add NodeCode to your NodeRed configuration is described in the article NodeRed – Importing and Exporting Node Code.
So that the notification can be forwarded to you using Pushbullet, you have to configure the Pushbullet Node accordingly. You can find tips on this in the article NodeRed – Sending Pushbullet Messages on Events
Some more information:
The pushbullet message is triggered when the current duty cycle is 1.8 times as high as the average duty cycle. This means that the abnormal duty cycle is only detected after the 1.8 times the average cooling compressor duty cycle of your fridge has expired. With an average on-time of 30 minutes, you would only receive an indication of an abnormal on-time after 54 minutes.
Of course, you can also reduce this value. The only disadvantage is that it can lead to a “false positive”. If you want, just try out different values. This recognition is implemented in the function node “checkForAbnormalValues”.
You can find the NodeCode in the Nerdiy-Git under the following link:
Have fun with the project
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. 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 appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂