ESP Projects

Build a freezer and fridge alarm with an ESP32

A tripped breaker, a door that didn't latch, or a compressor on its way out can spoil hundreds of dollars of food before anyone notices. This monitor watches the temperature in both compartments and both doors, and warns your phone long before anything thaws.

What it watches

  • Temperature in each compartment, using waterproof DS18B20 probes.
  • Each door, using magnetic contacts, so you hear about a door left ajar in minutes rather than hours.
  • Power. The ESP32 plugs into the same outlet as the appliance, so if the monitor drops offline, the freezer has probably lost power too.

Parts

  • An ESP32 DevKit and a USB power supply.
  • Two waterproof DS18B20 probes, one per compartment.
  • Two magnetic door contacts, the wired kind sold for alarm systems.
  • Two 4.7 kΩ resistors, one pull-up for each probe.
  • A small enclosure to stick on the side or top of the fridge.

Wiring

PartWireESP32
Freezer probeRed / black / yellow3.3V / GND / GPIO13
Fridge probeRed / black / yellow3.3V / GND / GPIO14
4.7 kΩ resistorsFrom each probe's yellow (data) wire to 3.3V
Freezer door contactEither wireGPIO19 and GND
Fridge door contactEither wireGPIO23 and GND

Each probe gets its own pin, so there's no need to look up the probes' serial numbers. Wire colors vary between sellers; check yours against the listing if they don't match.

Wiring diagram
Wiring diagram. Click to open full size.

Getting the probe inside

The probe cable is thin enough to pass under the door gasket. Run it on the hinge side, where the seal is squeezed least, and check the door still closes with a light push. Hang the probe in the air near the middle of the compartment rather than touching the back wall, the food, or the cooling vents.

Build this config in the generator Pick your board, adjust pins, and copy a ready-to-flash config with fresh keys.

The ESPHome config

one_wire:
  - platform: gpio
    id: freezer_bus
    pin: GPIO13
  - platform: gpio
    id: fridge_bus
    pin: GPIO14

sensor:
  - platform: dallas_temp
    one_wire_id: freezer_bus
    name: "Freezer temperature"
    update_interval: 30s
  - platform: dallas_temp
    one_wire_id: fridge_bus
    name: "Fridge temperature"
    update_interval: 30s

binary_sensor:
  - platform: gpio
    name: "Freezer door"
    device_class: door
    pin:
      number: GPIO19
      mode:
        input: true
        pullup: true
    filters:
      - delayed_on_off: 100ms
  - platform: gpio
    name: "Fridge door"
    device_class: door
    pin:
      number: GPIO23
      mode:
        input: true
        pullup: true
    filters:
      - delayed_on_off: 100ms

The temperatures that matter

The FDA recommends keeping the freezer at 0 °F (−18 °C) or colder and the fridge at 40 °F (4 °C) or colder. Both swing a few degrees during defrost cycles and every time the door opens, so alerts need a delay, not just a threshold.

Home Assistant alerts

  • Freezer warming: notify when Freezer temperature stays above 10 °F (−12 °C) for 30 minutes.
  • Fridge warming: notify when Fridge temperature stays above 41 °F (5 °C) for 30 minutes.
  • Door left open: notify when either door has been open for 2 minutes.
  • Power or monitor lost: notify when the temperature sensors become unavailable for 10 minutes. For this to reach you during a power cut, Home Assistant and your router need a battery backup.

After an outage

The history graph is the useful part after a power cut: it shows how warm each compartment got and for how long. USDA guidance is that a closed fridge keeps food safe for about 4 hours without power, and a full freezer holds its temperature for about 48 hours (24 if half full). When in doubt, throw it out.

Going further

  • Add a buzzer from the config generator for a local alarm that works even if Wi-Fi is down.
  • A chest freezer in the garage is the classic candidate. Add a third probe there; the generator supports up to four.