Fridge Door Sensor
Have you ever encountered a situation where the refrigerator door did not close properly and you needed to throw away all the frozen food? Unfortunately, I ran into this problem many times.
Some modern refrigerators equipped with door sensing that warns the users when the door is not properly closed.
Instead of buying a modern machine with door sensing, I decided to DIY a simple sensor for my old machine. It has been running for several years. It did save my frozen meat and ice-creams a few times. and it costs less than $3.
Order a 3V Magnetic Sensing Door Siren and STC15W204S board. They are available at AliExpress. You could search the keyword "alarm magnet" and "STC15W204s".
Write a simple timer program and get it compiled in Keil uVision (https://www.keil.com). Download the binary code into STC15W204S using STC tools "stc-isp". USB to TTL adaptor is needed (You could order it from Aliexpress.com. You could use the search word "STC USB TTL programmer")..
Here is the C code for reference.
#include "rtx51tny.h"
#include "define.h"
#define ALARM_PIN P55
void init_MCU(void);
void init_variable(void);
void startup(void) _task_ INIT {
init_variable();
init_MCU();
os_wait(K_TMO,60,0); // wait for about 0.3sec
os_create_task(FREEZER_TIMER_TASK);
os_delete_task(INIT); // delete itself
}
void init_variable() {
ALARM_PIN = 1;
return;
}
void init_MCU() {
return;
}
void REEZER_TIMER(void) _task_ FREEZER_TIMER_TASK {
unsigned char i;
ALARM_PIN = 0;
os_wait(K_TMO,6,0);
ALARM_PIN = 1;
for (i=0; i<6 ;) // wait for about 10Sec
{
os_wait(K_TMO,250,0);
i++;
}
for (i=0; i<60 ; i++) {
ALARM_PIN = 0;
os_wait(K_TMO,10,0); // Alarm turns on
ALARM_PIN = 1;
os_wait(K_TMO,180,0); // Alarm turns off for about 1Sec
os_wait(K_TMO,180,0); // Alarm turns off for about 1Sec
os_wait(K_TMO,180,0); // Alarm turns off for about 1Sec
}
ALARM_PIN = 0; // Alarm turns on continuously
}
Use Velcro to fix the Siren on the fridge. You should trim the position such that the siren is not triggered when the door is closed properly.
This unit is operated by two AAA cells. And it consumes almost 0 current when it is idle.