LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsAn optical flow sensor takes hundreds of tiny images a second and works out how far the surface has moved under it, the same way an optical mouse does. The PAA5100JE works at 15-35 mm from the surface, so it suits robots and handheld rollers. Pimoroni's Python library reads the motion counts over SPI. Calibrate once by sliding it along a known 1 m line, then it shows distance in cm.
Tick anything you already have and the total updates.
Pimoroni PAA5100JE optical flow breakout
Follow the colours: red is power, dark grey is ground, blue is a signal.
The Pi's own 3.3 V.
roll_measure.pyimport time
from pmw3901 import PAA5100
COUNTS_PER_M = 5000 # set from your 1 m calibration
flo = PAA5100(spi_port=0, spi_cs_gpio=7)
flo.set_rotation(0)
total_x = total_y = 0
input("Place the sensor and press Enter to zero")
while True:
try:
dx, dy = flo.get_motion()
except RuntimeError:
continue # no new data yet
total_x += dx
total_y += dy
dist_cm = ((total_x ** 2 + total_y ** 2) ** 0.5) / COUNTS_PER_M * 100
print(f"counts {total_x:6d} {total_y:6d} distance {dist_cm:6.1f} cm", end="\r")
time.sleep(0.01)
Too high above the surface; it works only at about 15-35 mm.
Keep the height constant; a sled or wheels help.
Very shiny or plain surfaces have no texture to track; try a matt surface.
About 1-2% once calibrated at a fixed height.
Yes, it gives odometry that does not slip like wheel encoders.
It has its own LEDs for close surfaces.
5 parts: Pimoroni PAA5100JE Near Optical Flow SPI Breakout – 15-35mm Range, 242fps, Raspberry Pi 4 Model B 2GB RAM Single Board Computer, Official Raspberry Pi 32GB A2 Class Micro SD Card, 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 2 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (roll_measure.py).
About ₹9,901 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
How optical flow works; Calibrating counts to distance; Reading an SPI sensor from Python.
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.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.