Build it step by step
0 of 7 doneBuild it on a breadboard
Test the reading in light and dark.
Set the threshold
BRIGHT between the two.
Remove the power LED
Cuts the drain.
Wire the coin cell
Bypass the regulator.
Fix it near the lamp
Not touching food.
Test for 60 seconds
Door open.
Watch it for a week
Check the cell in the cold.
How do you build a fridge door left open alarm?
A light sensor inside the fridge notices the lamp is on for over a minute and beeps until the door is closed. You need Digispark ATtiny85 USB board, LDR Photoresistor, Resistor 10 kΩ, Active buzzer 5 V, CR2032 coin cell and CR2032 coin cell holder. It takes 7 steps and about 60 minutes.
- Level
- Beginner
- Time
- About 60 min
- Parts
- 6
Parts list
- Development BoardsBuy
- SensorsBuy
- PassivesBuyResistor 10 kΩ × 1
- Motors & ActuatorsBuy
- BatteriesBuyCR2032 coin cell × 1
- PowerBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Coin cell holder plus | Digispark 5V pin and LDR one leg | Powers the board directly (the regulator is bypassed) |
| Coin cell holder minus | Digispark GND | Ground |
| LDR other leg | Digispark P2 and one end of the 10 k resistor | Divider output |
| 10 k resistor other end | Digispark GND | Divider bottom |
| Buzzer plus | Digispark P0 | Beep |
| Buzzer minus | Digispark GND | Return |
Code
Instead of a reed switch, this uses the fridge's own lamp: an LDR and a fixed resistor make a divider whose reading rises when the lamp is on, which only happens when the door is open. The Digispark sleeps almost all the time, waking every four seconds on the watchdog timer, and only beeps when it has seen light fifteen times in a row, about a minute, so a quick look into the fridge does nothing. Settings that make a coin cell last: run at 1 MHz and use the No USB board setting; bypass the on-board regulator and feed the 3 V cell to the 5V pin; and remove the on-board power LED, which would drain the cell in days. A coin cell cannot supply much, so use a small buzzer and keep beeps short. Cold reduces battery capacity, so test it for a week in your fridge. Mount the board away from food and moisture, and do not rely on it alone to protect food or medicine. Adjust BRIGHT after trying the lamp on and off. Arduino IDE with the Digistump AVR boards package, board "Digispark (1 MHz - No USB)" so it runs on a 3 V coin cell. The USB bootloader waits a few seconds at power-up.
Runs on a virtual Digispark ATtiny85 in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Fridge door alarm: sleeps in 4 second steps, beeps if the lamp has been on for about 60 seconds.
// Board: Digispark ATtiny85 at 1 MHz. LDR on P2 (analog channel 1), buzzer on P0.
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
const uint8_t BUZ = 0;
const uint8_t LDR_CH = 1; // P2 is analog channel 1
const int BRIGHT = 500; // adjust after testing in your fridge
const uint8_t LIMIT = 15; // 15 wakes of 4 s is about 60 s
uint8_t brightCount = 0;
ISR(WDT_vect) {}
void sleep4s() {
cli();
MCUSR &= ~(1 << WDRF);
WDTCR |= (1 << WDCE) | (1 << WDE);
WDTCR = (1 << WDIE) | (1 << WDP3); // 4 second watchdog interrupt
ADCSRA &= ~(1 << ADEN); // ADC off while sleeping
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sei();
sleep_cpu();
sleep_disable();
ADCSRA |= (1 << ADEN);
}
void setup() {
pinMode(BUZ, OUTPUT);
}
void loop() {
sleep4s();
int v = analogRead(LDR_CH);
if (v > BRIGHT) brightCount++; else brightCount = 0;
if (brightCount >= LIMIT) {
for (int i = 0; i < 3; i++) { digitalWrite(BUZ, HIGH); delay(150); digitalWrite(BUZ, LOW); delay(150); }
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Door open under 30 s | Silent |
| Door open over a minute | Three beeps every 4 seconds |
| Door closed | Stops at once |
| Sleep current | Very low |
If it does not work
Never beeps
Lower BRIGHT or move the LDR nearer the lamp.
Beeps in the dark
Raise BRIGHT or shield the LDR from the display light.
Resets
A weak coin cell; use a fresh one.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the fridge door left open alarm?
Digispark ATtiny85 USB board, LDR Photoresistor, Resistor 10 kΩ, Active buzzer 5 V, CR2032 coin cell and CR2032 coin cell holder.
How long does the fridge door left open alarm take to build?
About 60 minutes for a beginner maker, in 7 steps.
How do I know the fridge door left open alarm works?
Door open under 30 s: Silent. Door open over a minute: Three beeps every 4 seconds. Door closed: Stops at once.
Never beeps: what should I check?
Lower BRIGHT or move the LDR nearer the lamp.
Beeps in the dark: what should I check?
Raise BRIGHT or shield the LDR from the display light.
Resets: what should I check?
A weak coin cell; use a fresh one.
