Cold-chain temperature monitoring with ESP32 and DS18B20
A fridge full of stock fails quietly. The compressor stops on a Friday evening, the door seal lets go, or a breaker trips, and nobody notices until the morning, when everything inside has to be thrown away. Cold-chain monitoring exists for that moment. A chart of yesterday's temperatures is useful, but it isn't the point. The point is a message to the right person while there's still time to move the stock. This guide covers building that with an ESP32 and DS18B20 probes: the temperature ranges to design around, what the probe can and can't measure, where to put it, how to set alerts that don't fire every time someone opens the door, and what records are worth keeping.
The ranges to design around
Every cold-chain setup starts with the range the stock has to stay inside. These are the common ones:
| What's stored | Must stay | Source |
|---|---|---|
| Refrigerated vaccines | 2 °C to 8 °C (36–46 °F) | CDC Vaccine Storage and Handling Toolkit |
| Frozen vaccines | −50 °C to −15 °C (−58 to +5 °F) | CDC toolkit |
| Chilled food in shops and restaurants | 5 °C (41 °F) or below | US FDA Food Code |
| Frozen food | −18 °C (0 °F) or below | USDA |
These are US figures, checked October 2026. Other countries set their own, and some products print a narrower range on the label, so use the rule that applies to you. Two design decisions follow from the range:
- Run in the middle and alarm before the edge. CDC suggests setting a vaccine fridge to its midpoint, 5 °C, and a freezer to −20 °C, to leave room on both sides. An alert only helps if it fires before the limit, so put a warning band inside the range, for example 3 °C and 7 °C, and the critical alarm at 2 °C and 8 °C. The probe's own error, covered next, eats into that margin.
- Measure what the stock feels, not the air. Air temperature in a fridge jumps several degrees every time the door opens, while a crate of product barely moves. CDC calls for a buffered probe for this reason, and the FDA verifies cold holding by product temperature. A probe in free air measures door traffic as much as it measures the fridge.
What a DS18B20 can and can't tell you
The DS18B20 is the usual probe for a DIY cold-chain monitor, for good reasons. The waterproof stainless-steel versions on a few metres of cable are cheap. Each chip carries a unique 64-bit code, so many probes can share one data wire. And it sends a digital reading, so a long cable doesn't add analogue noise or need its own calibration.
Read its datasheet before you trust it in a freezer, though:
| Datasheet figure | Value | What it means here |
|---|---|---|
| Accuracy | ±0.5 °C from −10 °C to +85 °C | Fine for a fridge at 2–8 °C |
| Accuracy over the full range | ±2 °C from −55 °C to +125 °C | A freezer at −20 °C is outside the ±0.5 °C band, so leave a wider margin |
| Resolution | 12-bit (0.0625 °C) by default | Much finer than the accuracy: the extra digits aren't extra truth |
| Conversion time at 12-bit | 750 ms at most | Irrelevant at cold-chain sample rates |
| Value at power-up | +85 °C | A reading of exactly 85.0 means a conversion didn't run, not that the fridge is hot |
Two more things decide whether the numbers on your screen mean anything:
- Most probes sold online aren't genuine. In 2019 Chris Petrich's group bought more than 1,000 probes and chips from over 70 vendors, and every probe bought on eBay and AliExpress contained a counterfeit or clone chip. Some clone families read up to 3 °C off at 0 °C, and many don't work on parasite power. Buy from an authorised distributor, or check each probe in a glass of crushed ice and water, which sits at 0 °C. Write the offset on a label on the cable, and swap out any probe that reads more than half a degree off.
- A DS18B20 is not a calibrated data logger. Regulated storage expects a device with a calibration certificate. For vaccines, CDC asks for a digital data logger with a current Certificate of Calibration Testing, traceable to national standards and re-tested every two to three years, and pharmaceutical distribution rules ask for calibrated monitoring equipment too. A DIY probe doesn't come with that paperwork. Where those rules apply, keep the certified logger as the official record and use the ESP32 as the remote alarm and a second opinion. Where they don't, such as a restaurant walk-in, a florist's cooler or a lab freezer of non-regulated samples, a checked DS18B20 is a perfectly good monitor.
Wiring DS18B20 probes to an ESP32
1-Wire lets many probes share one GPIO pin, which is the usual way to wire several cabinets to one board. A few rules keep the bus reliable:
- Use three wires per probe: data, 3.3 V and ground. The two-wire "parasite power" mode saves a conductor but needs a strong pull-up during every conversion, and many clone chips don't support it.
- Fit one 4.7 kΩ pull-up resistor between the data line and 3.3 V, at the ESP32 end. One per pin, not one per probe.
- Prefer one trunk to a star. For a few probes on a few metres of cable, almost any layout works. For longer runs, Maxim's guidance on long 1-Wire networks favours a single trunk with short branches over several long cables meeting at one point.
- Keep the ESP32 outside the cabinet. A steel fridge blocks Wi-Fi, and the inside is cold and wet. Only the stainless probe goes in. A thin cable through the door seal usually works, but check that spot for frost after a day. A cable port, if the cabinet has one, is better.
- In a freezer, use a probe with a silicone jacket. Standard PVC cable stiffens and cracks in the cold.
Then work out which probe is which. A 1-Wire bus doesn't number probes by their position on the cable. It finds them in the order of their 64-bit codes, and most software numbers them in that order, so "sensor 1" isn't necessarily the one nearest the board. Warm each probe in your hand in turn, note which reading rises, and label both ends of the cable. Do it again whenever you replace a probe, because the new chip's code can land anywhere in the order and shuffle the numbering. Giving each probe its own pin avoids the problem entirely, and an ESP32 has more free GPIOs than most rows of cabinets need. The Synacl setup below does exactly that.
Where to put the probe
Where the probe sits matters as much as the probe itself:
- In the middle of the load, away from the walls, floor, ceiling, fan outlet and door, where the air is warmer or colder than the stock. That's CDC's placement rule for vaccine fridges, and it holds for any cabinet.
- In a buffer. A buffered probe sits in a small sealed vial of liquid such as glycol or glycerin, in sand or glass beads, or in a block of aluminium, so it follows the temperature of the stock rather than the air. A DS18B20 pushed into a small sealed bottle of glycol is a buffered probe. The buffer is what stops door openings from looking like failures. It also slows the reading down, which is fine, because the stock warms just as slowly.
- One probe per compartment. A fridge-freezer is two units. A walk-in cooler deserves two probes, one near the door and one at the back, so you can see the gradient.
- Plus one probe outside, in the room. When a cabinet starts to warm, the room reading tells you whether the unit is failing or the kitchen just hit 35 °C and the condenser can't keep up.
Alerts that fire for the right reasons
The usual failure of a temperature alarm isn't a missed excursion. It's an alarm on raw air temperature that fires every lunchtime, until someone mutes it, and then misses the real failure. These rules keep alerts worth reading:
- Use two bands. A warning at the edge of normal, for example 7 °C, goes to a dashboard or an email. A critical alarm at the limit, 8 °C, goes to a phone. Someone glances at the first and acts on the second.
- Let the buffer absorb door openings. With a buffered probe, a door left open for a minute barely moves the reading, so the alarm doesn't need a delay. Without a buffer, the alarm needs a condition that has to last, such as "above 8 °C for 15 minutes", or a higher limit for short spikes.
- Alarm on silence. The failure that spoils the most stock is a power cut, and a power cut takes the monitor and often the Wi-Fi router down with it. A monitor that only alarms on temperature says nothing at all. "No data from this unit for a few minutes" has to be an alarm in its own right, raised by the server rather than by the device that just lost power.
- Send the all-clear too. "Back in range after 23 minutes, warmest 9.4 °C" is what you need to decide whether the stock is still usable. Without the end of an excursion, you only know it started.
- Make someone own it. An alarm at 3 a.m. goes to whoever is on call that night, with a second person if the first doesn't respond.
Records worth keeping
When something goes wrong, the questions are always the same: when did it start, how long did it last, how warm did it get, and what did you do. A good log answers them without anyone having to reconstruct it:
- A continuous reading at a fixed interval. Every few minutes is plenty for a fridge. CDC's vaccine guidance asks for a logger that records at least every 30 minutes, plus a check of the minimum and maximum at the start of every workday.
- Every excursion as one entry, with start, end, duration and the peak reading, plus a note of the action taken.
- Gaps shown as gaps. If the monitor was offline for an hour, the log should say so, not draw a straight line across it. CDC's paper logs say the same: if a reading is missed, leave the entry blank.
- Long enough retention. CDC asks vaccine providers to keep temperature logs for three years. Food businesses usually need less, but check your inspector's expectations before you rely on a monitor's default history.
Setting it up on Synacl
The Synacl gateway firmware reads DS18B20 probes over 1-Wire, and the DS18B20 catalog entry fills in the connection settings. Flash an ESP32 from the web flasher, pair it with your account, and then build the monitor like this.
One probe per pin, one device per probe. Add each probe as its own 1-Wire device on its own GPIO, each pin with its own 4.7 kΩ pull-up. The firmware can read several probes on one pin, but it matches them to tags by their position in the bus search, and it searches again on every read. If one probe on a shared pin dies, the probes after it move up a place, so their readings land on the wrong tags, and the last tag keeps showing its old value. With one probe per pin, a dead or unplugged probe turns that device amber and raises a device/offline event marked as a fault, which is something you can alarm on. The app refuses a pin that another device on the same gateway already uses, so you can't double-book one by mistake. See connecting a 1-Wire device for the fields.
Name the tags after what they guard. Call every fridge tag fridge_temp and every freezer tag freezer_temp. A rule can watch one device or every device with a given tag name, so one rule then covers every fridge. Its cooldown runs separately for each device, so one failing fridge doesn't silence an alert from another.
Read once a minute. A sample interval of 60 seconds (sampleIntervalMs: 60000) is plenty for a cabinet. The gateway sends its own heartbeat about every 10 seconds, so slow readings don't make a device look offline. Your plan sets the fastest interval allowed, and the pricing page lists it.
Two rules for the two bands. A threshold rule compares one tag with one number:
| Rule | Condition | Action | Severity |
|---|---|---|---|
| Fridge warning | fridge_temp > 7 |
warning | |
| Fridge critical | fridge_temp > 8 |
Push to the mobile app | critical |
| Fridge too cold | fridge_temp < 2 |
Push to the mobile app | critical |
| Freezer critical | freezer_temp > -15 |
Push to the mobile app | critical |
Rules run in the cloud on every reading, and while the condition holds they fire again each time the cooldown runs out, so a warm fridge keeps reminding you instead of alerting once. Push goes to the account owner and every team member with the Synacl app. Quiet hours in the app mute everything except critical, which is why the rules that should wake someone are set to critical.
Two more rules for silence. Add event rules on gateway/offline and device/offline, with email or a webhook to whatever pages your on-call person. A gateway that loses power is marked offline within a few minutes, from its MQTT last will or, if that never arrives, from missed heartbeats. Its devices go offline with it, but they share the gateway's cooldown, so a dead site sends one alert per rule, not one per probe. The online status article explains every state.
Tag limits as a second line. On paid plans you can also set an alarm band on the tag itself, for example 2 °C to 8 °C. The gateway then checks each reading on the board and logs one alert when the reading leaves the band and another when it comes back, which puts the start and end of each excursion in the event feed. Rules don't send an all-clear, so this is where the end of an excursion is recorded. Use the rules above as the alarm, though. A limit alert raised while the gateway is offline is lost, while a rule re-checks the first reading after the gateway reconnects. See alert thresholds.
For the screen on the wall, a value card and a trend chart per unit plus an uptime strip cover it (build a dashboard).
What Synacl doesn't do, so you can plan around it:
- No "for N minutes" condition. A rule fires on the first reading past the number. Use a buffered probe so door openings never reach that number.
- No acknowledgment or escalation chain, and no SMS. Alerts go out by push, email and webhook. If you need "call the second person after 15 minutes", put a paging service behind the webhook.
- Gaps stay gaps. Readings taken while a gateway is offline aren't kept, so an outage shows as a gap in the history rather than a made-up line.
- Your own long-term record. Readings are kept for as long as your plan allows, and the event feed for up to 30 days. For a log you have to keep for years, stream every reading into your own database with an egress integration (webhook, InfluxDB, MariaDB or Kafka).
- Not a certified logger. Where a calibration certificate is required, keep the certified logger and use Synacl as the remote alarm next to it.
If you haven't wired anything to an ESP32 yet, flash an ESP32 from your browser gets the gateway running in a few minutes, and IoT device uptime monitoring goes deeper into offline windows and alerts on silence.
Try it on your own hardware
Synacl is free for five devices — no card, no sales call. Flash a gateway from the browser, add your first device, and see live data in a few minutes.