Software apps and online services
Our fridge has double doors, and it doesn't have automatic alarm. I decided to set up phone notification alarm based on my earlier work on garage door sensor https://www.hackster.io/medavid008/esp8266-blynk-garage-door-climate-sensor-wifi-phone-app-0e243d. I used Adafruit ESP8266, it can be programmed with Arduino IDE, it has WiFi. I used two reed switches to determine if magnets, attached to the two fridge doors are close or not.
Circuit. The circuit is very simple, shown in the picture below:
Since there are two doors and I need to detect whether ANY ONE OR BOTH of them are open I connected two magnetic Reed switches in series between Pin 12 and the ground. Pin 12 is set as input pullup in the code, this means there is an internal resistor between 3.3V source and the pin. In this configuration, when ANY ONE or BOTH switches are open (either one of them not conducting, at least on magnet is away, at least one door is open), the pin is high, current is not flowing. When both switches are closed (both are conducting, both magnets are close by, both doors are closed) then there the current flowing through internal resistor and the pin is low, it's grounded.
Blynk App. After this I set up an account with Blynk app https://blynk.io/. After searching online I found it being one of the easy ways to set up phone notification with wifi board. Blynk gives you a token for each project, which you need to put into your code to enable the communication (see code). The Blynk project screen shots are shown in a picture below.
In the Blynk project (panel 1) I set up an LED to display whether Reed switch is open or closed as virtual input V4. In the code it is set that when both magnets are close (both doors are closed, pin is low) LED is off, otherwise it is on. I set a cycle time to check the status every 15s (variable CycleTimeInSec). I also set a variable AlertTimeInSec to 60s. If the door stays open for longer than alert time, then Blynk sends notification to the phone. When we get it on the phone we run and close the fridge door.
Mounting. I scotch taped the breadboard to the top of the fridge and two magnets to each of the doors. I adjusted the position of the switches on the board and the boards itself carefully with trial and error, such that even smallest opening alerts us.
Here is the video where I describe the project:
As a result we always keep our fridge door closed. I was surprised how often it alerts us. The fridge doors aren't designed too well, they don't close automatically on their own, actually we need to put extra effort to close them. We probably wasted a lot of energy and cooling power before we installed such sensor.