Build it step by step
0 of 7 doneWire the probe
Red to 3V3(OUT), black to GND, yellow to GP16, 4.7 kilo-ohms from yellow to 3V3(OUT).
Wire the display
VCC, GND, SDA to GP0, SCL to GP1.
Wire the buzzer
Plus to GP15, minus to GND.
Install the ssd1306 module
From Thonny's Manage packages.
Run the program
The display shows the temperature.
Hold the probe in warm tap water
The value rises.
Put it in cool water for a minute
It shows Too cool and then beeps.
How do you build a yogurt box thermometer?
A waterproof DS18B20 probe in an insulated box of warm water watches the temperature that keeps the milk warm during yogurt making, and a Pico beeps if it drops below a set value. It monitors only and does not heat anything. You need Raspberry Pi Pico H, DS18B20 waterproof probe, Resistor 4.7 kΩ, SSD1306 OLED Display, Passive buzzer and Breadboard 830 Tie Points. It takes 7 steps and about 110 minutes.
- Level
- Beginner
- Time
- About 110 min
- Parts
- 6
Parts list
- Development BoardsBuy
- SensorsBuy
- PassivesBuyResistor 4.7 kΩ × 1
- DisplaysBuy
- Motors & ActuatorsBuyPassive buzzer × 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 (VCC) | Pico 3V3(OUT) pin 36 | Power at 3.3 V |
| DS18B20 black (GND) | Pico GND pin 38 | Common ground |
| DS18B20 yellow (data) | Pico GP16 pin 21 | One-wire data |
| 4.7 kilo-ohm resistor | Between the data wire and 3V3(OUT) | Pull-up for the data line |
| OLED VCC | Pico 3V3(OUT) pin 36 | Power at 3.3 V |
| OLED GND | Pico GND pin 38 | Common ground |
| OLED SDA and SCL | Pico GP0 pin 1 and GP1 pin 2 | I2C0 data and clock |
| Passive buzzer + | Pico GP15 pin 20 | Tone output |
| Passive buzzer - | Pico GND pin 38 | Return |
Code
Yogurt is made by keeping warm milk with a live culture at a steady warm temperature for several hours, and the usual range is between about 38 and 46 degrees. Many people use an insulated box or a cool box filled with warm water. This build is only a thermometer that watches the water bath and warns you when it has cooled too far or is too hot, so you can top it up. It does not heat anything. The DS18B20 is a digital temperature probe that sends its reading over one wire, and the program uses the onewire and ds18x20 modules that come with MicroPython. The probe has a waterproof case, but it is not made for food, so keep it in the water bath and not in the milk. The pull-up resistor holds the data line high. The program only beeps after the temperature has been out of range for thirty seconds, so opening the lid for a moment does not set it off. Follow proper food hygiene with milk, clean the jars well and throw away anything that smells or looks wrong. The thermometer is indicative and is not a food safety device.
import time
import onewire
import ds18x20
import ssd1306
from machine import Pin, I2C, PWM
LOW_C = 38.0 # beep if the water bath falls below this
HIGH_C = 46.0 # and if it rises above this
CHECK_SECONDS = 30 # must stay out of range this long before beeping
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
buzzer = PWM(Pin(15))
buzzer.duty_u16(0)
sensor = ds18x20.DS18X20(onewire.OneWire(Pin(16)))
roms = sensor.scan()
if not roms:
raise RuntimeError("No DS18B20 found, check the wires and the pull-up resistor")
def beep(times):
for _ in range(times):
buzzer.freq(2000)
buzzer.duty_u16(20000)
time.sleep_ms(200)
buzzer.duty_u16(0)
time.sleep_ms(200)
out_of_range_since = None
while True:
sensor.convert_temp()
time.sleep_ms(800) # the probe needs 750 ms to measure
t = sensor.read_temp(roms[0])
if t < LOW_C:
status = "Too cool"
elif t > HIGH_C:
status = "Too hot"
else:
status = "In range"
if status == "In range":
out_of_range_since = None
else:
if out_of_range_since is None:
out_of_range_since = time.time()
if time.time() - out_of_range_since >= CHECK_SECONDS:
beep(3 if status == "Too cool" else 5)
out_of_range_since = time.time() # repeat the beeps every 30 seconds
oled.fill(0)
oled.text("Yogurt box", 0, 0)
oled.text("%.1f C" % t, 0, 20)
oled.text(status, 0, 40)
oled.text("%d to %d C" % (LOW_C, HIGH_C), 0, 54)
oled.show()
time.sleep(2)Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Probe in warm water | Temperature and In range |
| Probe in cold water | Too cool |
| Wait 30 seconds out of range | Beeps three times |
| Probe in very hot water from the tap | Too hot, five beeps |
| Back to range | Beeps stop |
If it does not work
No DS18B20 found
Check the three wires and the 4.7 kilo-ohm pull-up.
Reads 85 degrees
The probe has just started, wait for the next reading.
Display blank
Check the OLED address 0x3C and that ssd1306.py is on the Pico.
No beep
Check the buzzer is passive and on GP15.
Temperature looks wrong
Check the probe is not touching the side of the box or a heater.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the yogurt box thermometer?
Raspberry Pi Pico H, DS18B20 waterproof probe, Resistor 4.7 kΩ, SSD1306 OLED Display, Passive buzzer and Breadboard 830 Tie Points.
How long does the yogurt box thermometer take to build?
About 110 minutes for a beginner maker, in 7 steps.
How do I know the yogurt box thermometer works?
Probe in warm water: Temperature and In range. Probe in cold water: Too cool. Wait 30 seconds out of range: Beeps three times.
No DS18B20 found: what should I check?
Check the three wires and the 4.7 kilo-ohm pull-up.
Reads 85 degrees: what should I check?
The probe has just started, wait for the next reading.
Display blank: what should I check?
Check the OLED address 0x3C and that ssd1306.py is on the Pico.
No beep: what should I check?
Check the buzzer is passive and on GP15.
