LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsA single reading says little; the range tells the story. This MicroPython program reads a DHT22 every 3 seconds and keeps the minimum and maximum temperature and humidity since start-up, showing both on a 0.96 inch OLED. It is handy for judging a cupboard, a store room or a plant shelf over a day. The DHT22 should be read no faster than once every two seconds.
Tick anything you already have and the total updates.
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB power or a power bank.
main.pyimport time, dht
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)
sensor = dht.DHT22(Pin(15))
tmin, tmax, hmin, hmax = 999, -999, 999, -999
while True:
try:
sensor.measure()
t, h = sensor.temperature(), sensor.humidity()
tmin, tmax = min(tmin, t), max(tmax, t)
hmin, hmax = min(hmin, h), max(hmax, h)
oled.fill(0)
oled.text("%.1fC %.0f%%" % (t, h), 0, 0)
oled.text("T lo %.1f hi %.1f" % (tmin, tmax), 0, 20)
oled.text("H lo %.0f hi %.0f" % (hmin, hmax), 0, 36)
oled.show()
except OSError:
pass
time.sleep(3)
The sensor is failing silently. Check wiring and that DATA is on GP15.
The DHT22 reads high near steam or a breath. Keep it in free air.
Check the I2C wires and driver install.
Yes, append lines to a text file on the Pico's flash, but limit how often you write.
It works with dht.DHT11 but is less precise.
No. It restarts at power-up.
5 parts: Raspberry Pi Pico, DHT22 AM2302 Digital Temperature & Humidity Sensor, 0.96" OLED Display 128x64, 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 ₹734 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Using MicroPython's dht module; Tracking running minimums and maximums; Handling sensor read errors with try/except.
Ideas that reuse this build: Pico weather 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.