Cold storage door and temperature alarm
Build it step by step
0 of 7 doneSet the buck module
Feed 12 V to the LM2596 and turn its trimmer until the output is 5.0 V.
Wire the controller
Nano, relay module and probe as in the table.
Fit the reed switch
Switch on the frame and magnet on the door so they touch when closed.
Test with short times
Set DOOR_MS to 10 seconds, open the door and wait for the buzzer.
Test the temperature alarm
Warm the probe in your hand and temporarily lower LIMIT_C and WARM_MS.
Set real values
Restore the 60 second and 10 minute limits and set LIMIT_C for your store.
Mount
Put the electronics outside the cold room and run the probe in through the door seal.
How do you build a cold storage door and temperature alarm?
A reed switch and a temperature probe sound an alarm if the cold room door is left open for more than a minute or the room warms up. You need Arduino Nano, Door reed switch MC-38, DS18B20 waterproof probe, Resistor 4.7 kΩ, Buzzer 12 V continuous (piezo alarm), Relay Module 5V, 12 V 2 A DC adapter, LM2596 Buck Module and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 75 minutes.
- Level
- Beginner
- Time
- About 75 min
- Parts
- 9
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- SensorsBuy
- PassivesBuyResistor 4.7 kΩ × 1
- Motors & ActuatorsBuy
- InterfacesBuyRelay Module 5V × 1
- PowerBuy
- PowerBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| 12 V adapter + | LM2596 IN+ | Supply |
| LM2596 OUT+ (set to 5.0 V first) | Nano 5V pin and relay module VCC | Regulated 5 V |
| 12 V adapter - and LM2596 - | Nano GND, relay GND, buzzer - | Common ground |
| Relay module IN | Nano D6 | Alarm switch |
| Relay COM | 12 V adapter + | Feeds the 12 V buzzer |
| Relay NO | Buzzer + | Buzzer sounds when the relay closes |
| Reed switch | Nano D3 and GND | Closed (LOW) when the door is shut |
| DS18B20 probe red, black, yellow | Nano 5V, GND, D2, with 4.7 kΩ from D2 to 5V | Temperature probe |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "OneWire" and "DallasTemperature". Set the LM2596 to exactly 5.0 V on a multimeter before connecting the Nano. Everything runs from a 12 V adapter and nothing connects to mains inside the box. If your relay module is active-high, swap the HIGH and LOW writes for the relay.
Runs on a virtual Arduino Nano 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).
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(2);
DallasTemperature sensors(&oneWire);
const byte REED = 3, RELAY = 6;
const float LIMIT_C = 8.0; // alarm above this temperature
const unsigned long DOOR_MS = 60UL * 1000UL; // door open this long
const unsigned long WARM_MS = 10UL * 60UL * 1000UL; // too warm this long
unsigned long doorOpenSince = 0, warmSince = 0;
unsigned int openings = 0;
bool wasOpen = false;
void setup() {
pinMode(REED, INPUT_PULLUP);
pinMode(RELAY, OUTPUT); digitalWrite(RELAY, HIGH); // most relay modules are active low
Serial.begin(9600);
sensors.begin();
}
void loop() {
bool open = digitalRead(REED) == HIGH;
if (open && !wasOpen) { openings++; doorOpenSince = millis(); Serial.print("Openings today: "); Serial.println(openings); }
if (!open) doorOpenSince = 0;
wasOpen = open;
sensors.requestTemperatures();
float t = sensors.getTempCByIndex(0);
if (t != DEVICE_DISCONNECTED_C && t > LIMIT_C) { if (warmSince == 0) warmSince = millis(); }
else warmSince = 0;
bool doorAlarm = doorOpenSince != 0 && millis() - doorOpenSince > DOOR_MS;
bool warmAlarm = warmSince != 0 && millis() - warmSince > WARM_MS;
digitalWrite(RELAY, (doorAlarm || warmAlarm) ? LOW : HIGH); // LOW switches the relay on
Serial.print(t, 1); Serial.println(" C");
delay(1000);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
Openings today: 1 24.5 C
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Door closed | Silent |
| Door open under 60 s | Silent |
| Door open over 60 s | Buzzer on until closed |
| Probe warmed above the limit for 10 minutes | Buzzer on |
If it does not work
Probe reads -127
Not found. Check the 4.7 kΩ pull-up and wires.
Buzzer on all the time
The relay is active low or high the other way. Swap the HIGH and LOW writes.
Relay clicks but buzzer silent
Check COM and NO wiring and the 12 V supply.
Nano resets when the relay clicks
Add a 470 µF capacitor on the 5 V rail.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the cold storage door and temperature alarm?
Arduino Nano, Door reed switch MC-38, DS18B20 waterproof probe, Resistor 4.7 kΩ, Buzzer 12 V continuous (piezo alarm), Relay Module 5V, 12 V 2 A DC adapter, LM2596 Buck Module and Jumper wires male to male (40 pcs, 20 cm).
How long does the cold storage door and temperature alarm take to build?
About 75 minutes for a beginner maker, in 7 steps.
How do I know the cold storage door and temperature alarm works?
Door closed: Silent. Door open under 60 s: Silent. Door open over 60 s: Buzzer on until closed.
Probe reads -127: what should I check?
Not found. Check the 4.7 kΩ pull-up and wires.
Buzzer on all the time: what should I check?
The relay is active low or high the other way. Swap the HIGH and LOW writes.
Relay clicks but buzzer silent: what should I check?
Check COM and NO wiring and the 12 V supply.
Nano resets when the relay clicks: what should I check?
Add a 470 µF capacitor on the 5 V rail.
