Fridge Door Alarm

Updated 31 March 2022

This project uses an ESP8266-01 WiFi module to send an alert to my phone if the fridge door is left open or ajar.

After ordering a few of the ESP8266 board variations I found myself with an ESP8266-01 variant which wasn't very useful for other projects as it had only two GPIO pins broken out. Around the same time, I arrived home one afternoon to find that the door on the freezer was not quite closed and its contents had started to defrost. If only there was some alarm that could have let me know...

Initially, I considered a simple buzzer alarm, however, I suspected that the door had been closed in a hurry when leaving the house and a buzzer would only serve to annoy the neighbours with its endless noise in an empty house. From previous projects, I knew that the ESP8266 could run on very little power when in deep sleep, so I could power it from batteries and would also be able to send an alarm through my home WiFi connection.

To Create this project the following components were used:

How I built this project:

The device was made in three parts:

Creating the case

The AA holder was modified to house the project. One of the AA dividers was removed to make space for the PCB and microswitch. A hole was cut in the top corner of the holder and the microswitch was glued in place using Araldite. The battery end clips were rearranged as shown below so that the holder created a circuit with 2xAA batteries with the holder switch and microswitch in series. The microswitch was connected so that when it was pressed in (i.e. the fridge door pressed against it) the switch was open circuit. This means that the device will use very little power as it will only be on when the switch is released (i.e. the door is open)

Creating the PCB

Some prototype board was cut to fit the available space in the holder and the components were connected as shown in the circuit diagram below. P1 is some header pins for configuration and programming. GPIO_0 has a 10K pull-up resistor to enable normal boot and normal run. When GPIO_0 is pulled low at boot the ESP8266 enters program mode this feature is reused in the program and when GPIO_0 is pulled low during program execution the ESP8266 creates a WiFi access point using the Arduino WiFiManager library and allows the user to configure the device to connect to an existing WiFi connection.

For the ESP8266 to wake from deep sleep mode GPIO_16 needs to be connected to RST. Unfortunately, the pin isn't broken out in on the board, but there is no shield so we can solder directly to the chip. GPIO_16 is the pin on the very end, for this I used some very fine wire and a soldering iron. Also for the 10K pull-up resistor, I used an SMD 1206 resistor and the connection was made with a basic soldering iron (i.e. no special tools necessary here).

Software

Code for the project was written with the Arduino IDE and is linked at the bottom of this project write-up, so you can download and use it yourself. The code makes use of open source libraries available in the Arduino IDE, and I would like to thank the various library authors for their contributions.

When the microswitch is first released device starts and detects that the reason for restart is power and immediately goes to sleep for a specified time. If the microswitch is still released (fridge open) after the allotted time GPIO_16 will pull the RST pin low and reset the device, but this time the device detects that it reset from sleep and fires an alert.

In order to get alerts on my phone, I use the IFTTT webhooks service. It is free to create an account and can build lots of useful alerts with simple "If This Then That" style rules. Once your account is set up, alter the code with your webhooks key (https://ifttt.com/services/maker_webhooks/settings) and create a new applet where THIS is a webhooks "Receive a web request" (Create a new event name e.g. Fridge_Open) and THAT is "Send a notification from the IFTTT app" (Alter the message if you wish). Also download the IFTTT app on your phone, sign in and allow push notifications.

To program the device an FTDI programmer was used remembering that the voltage of the programmer needs to be set to 3.3V. The programmer was connected to TXD, RXD and GND header pins on the device and GPIO_0 was pulled low by shorting the remaining two header pins. After the program was sent the device runs the program, and because GPIO_0 is still being pulled low it the WiFiManager Config Accesspoint is made available. I used my phone to connect to the WiFi access point which then presents a page allowing the user to enter the settings for the WiFi connection that the device will use. When the jumper pulling GPIO_0 low is remove the device will remember the SSID and password and connect to the WiFi automatically. If the password or network needs to be changed in the future GPIO_0 needs to be pulled low within 5 seconds of starting.

The project was tested and 60 seconds after the microswitch was released an alert was received via the IFTTT app on the phone. The device was glued to the underside of the fridge using some liquid nails and a small block of wood was glued onto the door to push the microswitch in when the door was closed.

Attachment - Project Files

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.