LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsGPS modules send plain text called NMEA sentences. The Pico reads them on UART1 and the program picks out the $GPRMC or $GNRMC sentence, which holds time, status, latitude, longitude and speed. The code parses it by hand, so you see exactly how the data is built. Time is in UTC; the program adds the Indian offset of five hours thirty minutes. The module needs a clear view of the sky and a first fix can take several minutes.
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 bank for carrying it around.
main.pyfrom machine import Pin, I2C, UART
from ssd1306 import SSD1306_I2C
i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
gps = UART(1, baudrate=9600, tx=Pin(8), rx=Pin(9))
def to_deg(value, hemi):
deg = int(float(value) / 100)
mins = float(value) - deg * 100
d = deg + mins / 60
return -d if hemi in ("S", "W") else d
def show(*lines):
oled.fill(0)
for i, t in enumerate(lines):
oled.text(t, 0, i * 12)
oled.show()
show("Waiting for GPS")
while True:
line = gps.readline()
if not line:
continue
try:
s = line.decode().strip()
except UnicodeError:
continue
if s[3:6] == "RMC":
f = s.split(",")
if len(f) > 6 and f[2] == "A":
hh, mm = int(f[1][0:2]), int(f[1][2:4])
total = (hh * 60 + mm + 330) % 1440
lat = to_deg(f[3], f[4])
lon = to_deg(f[5], f[6])
show("%02d:%02d IST" % (total // 60, total % 60), "Lat %.5f" % lat, "Lon %.5f" % lon)
else:
show("No fix yet", "Go outdoors")
Take it outside with a clear sky view and wait a few minutes.
Swap TX and RX and check the baud rate (9600 is common).
The code skips corrupted lines. Check the wiring if it happens constantly.
GPS time is UTC. The code adds the Indian offset.
Yes. Field 7 in the RMC sentence is speed in knots; multiply by 1.852 for km/h.
Typical accuracy is a few metres outdoors, worse near buildings.
5 parts: Raspberry Pi Pico, DFRobot Gravity GNSS GPS BeiDou Receiver Module – I2C & UART, 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 intermediate project and takes about 1.5 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (main.py).
About ₹2,464 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Reading a UART on the Pico; Parsing NMEA RMC sentences; Converting degrees and minutes to decimal degrees.
Ideas that reuse this build: ESP32 GPS speedometer. 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.