LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsThe DS18B20 is a digital temperature sensor sealed in a waterproof steel probe. MicroPython has built-in onewire and ds18x20 modules, so reading it takes a few lines. The program shows the current temperature and remembers the lowest and highest since power-up. Use it to check bath water, a pot of milk, or a cold-storage box.
Tick anything you already have and the total updates.
Waterproof DS18B20 probe
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB power or a power bank.
main.pyimport time, onewire, ds18x20
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
ds = ds18x20.DS18X20(onewire.OneWire(Pin(15)))
roms = ds.scan()
lo, hi = 999, -999
while True:
ds.convert_temp()
time.sleep_ms(800)
t = ds.read_temp(roms[0])
lo, hi = min(lo, t), max(hi, t)
oled.fill(0)
oled.text("Temperature", 0, 0)
oled.text("%.1f C" % t, 0, 16)
oled.text("Min %.1f" % lo, 0, 40)
oled.text("Max %.1f" % hi, 0, 52)
oled.show()
No sensor was found. Check the pull-up resistor and wiring.
Check SDA on GP4 and SCL on GP5.
That is the power-up default. Wait for the conversion; check the wiring.
About half a degree between 0 and 85 C.
Yes. They share the same wire; use roms[1] for the second.
No. The DS18B20 reads up to 125 C and the cable is not rated for hot oil.
6 parts: Raspberry Pi Pico, DS18B20 Waterproof Temperature Probe – 1m Cable, Stainless Steel, 0.96" OLED Display 128x64, Resistor Assortment Kit (30 Values), Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 45 minutes. The build on this page has 6 steps.
No. This page has the complete, tested code (main.py).
About ₹688 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Reading a DS18B20 with onewire and ds18x20; Tracking min and max; Drawing on an SSD1306 OLED.
Ideas that reuse this build: Pico room climate OLED. They are listed under Take it further on this page.
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
See the smoke level live on a crisp screen and get a loud warning when it spikes.
An infrared eye that spots an open flame and raises the alarm.
Walk into the room and it sounds the alarm: the classic first security build.
Learning project. Check every circuit and the datasheet of each part before you power it up.