Serial at 9600 baudTap a part to see what it does.
Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.
Build it step by step
0 of 4 doneProbe and pull-up
Yellow to D4 with 4.7 kΩ to 5V.
Limit knob
Wiper to A0.
LED and buzzer
LED on D9 through 220 Ω, buzzer on D8.
Set and test
Turn the knob to just above room temperature, then hold the probe.
How do you build a temperature threshold alarm?
A waterproof DS18B20 probe watches a fridge, aquarium or room. A knob sets the limit, and a buzzer and LED warn when it is crossed. You need Arduino Uno R3, DS18B20 Temperature Sensor, Resistor 4.7 kΩ, Potentiometer 10 kΩ, Active buzzer 5 V, LED 5 mm red, Resistor 220 Ω and Breadboard 830 Tie Points. It takes 4 steps and about 40 minutes.
- Level
- Beginner
- Time
- About 40 min
- Parts
- 8
Parts list
- Development BoardsBuyArduino Uno R3 × 1
- SensorsBuy
- PassivesBuyResistor 4.7 kΩ × 1
- PassivesBuy
- Motors & ActuatorsBuy
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 220 Ω × 1
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| DS18B20 red / black | 5V / GND | Power |
| DS18B20 yellow | D4, with 4.7 kΩ to 5V | 1-Wire data |
| Pot wiper | A0 (ends to 5V and GND) | Limit knob |
| D9 → 220 Ω → LED | Alarm light | |
| Buzzer | D8 | Alarm sound |
Code
Libraries: OneWire and DallasTemperature. A missing probe also raises the alarm, because silence would be unsafe.
Runs on a virtual Arduino Uno 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 bus(4);
DallasTemperature probe(&bus);
const int LED = 9, BUZZ = 8;
bool alarm = false;
void setup() { Serial.begin(9600); probe.begin(); pinMode(LED, OUTPUT); pinMode(BUZZ, OUTPUT); }
void loop() {
probe.requestTemperatures();
float t = probe.getTempCByIndex(0);
float limit = map(analogRead(A0), 0, 1023, 0, 500) / 10.0; // 0.0 to 50.0 °C
if (t == DEVICE_DISCONNECTED_C) { Serial.println("Probe missing"); alarm = true; }
else if (t > limit + 0.5) alarm = true;
else if (t < limit - 0.5) alarm = false; // 1 °C of hysteresis
digitalWrite(LED, alarm);
digitalWrite(BUZZ, alarm && (millis() / 400) % 2);
Serial.print(t); Serial.print(" C, limit "); Serial.println(limit);
delay(500);
}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 Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
24.50 C, limit 25.00
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Hold the probe | Alarm starts once it passes the limit + 0.5 °C |
| Let go | Alarm stops only after it falls 1 °C, no chattering |
| Unplug the probe | "Probe missing" and the alarm sounds |
If it does not work
Reads −127
Missing 4.7 kΩ pull-up or yellow wire not on D4.
Reads 85 every time
Power-on value: the conversion did not finish; check supply wiring.
Limit jumps around
Pot wiper loose; average a few readings.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the temperature threshold alarm?
Arduino Uno R3, DS18B20 Temperature Sensor, Resistor 4.7 kΩ, Potentiometer 10 kΩ, Active buzzer 5 V, LED 5 mm red, Resistor 220 Ω and Breadboard 830 Tie Points.
How long does the temperature threshold alarm take to build?
About 40 minutes for a beginner maker, in 4 steps.
How do I know the temperature threshold alarm works?
Hold the probe: Alarm starts once it passes the limit + 0.5 °C. Let go: Alarm stops only after it falls 1 °C, no chattering. Unplug the probe: "Probe missing" and the alarm sounds.
Reads −127: what should I check?
Missing 4.7 kΩ pull-up or yellow wire not on D4.
Reads 85 every time: what should I check?
Power-on value: the conversion did not finish; check supply wiring.
Limit jumps around: what should I check?
Pot wiper loose; average a few readings.
