LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsAir pressure falls as you go up: near the ground it drops about 0.12 hPa per metre, so one 3 m floor is about 0.36 hPa. The LPS22 measures pressure with a noise of around 0.01 hPa, well below one floor. The Nano zeroes the pressure at the ground floor, then shows the current floor and counts floors climbed. Weather also changes pressure, but slowly, so the sketch re-zeroes whenever you press the button at ground level.
Tick anything you already have and the total updates.
Adafruit LPS22 pressure sensor (STEMMA QT)
Follow the colours: red is power, dark grey is ground, blue is a signal.
A small power bank so you can carry it.
floor_counter.inoVerify & upload in Electrolark#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
#include <Adafruit_LPS2X.h>
Adafruit_LPS22 lps;
const float HPA_PER_FLOOR = 0.36;
float zero = 0, smooth = 0;
int lastFloor = 0, climbed = 0;
void setup() {
pinMode(2, INPUT_PULLUP);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.setTextColor(WHITE);
lps.begin_I2C();
lps.setDataRate(LPS22_RATE_10_HZ);
sensors_event_t p, t; lps.getEvent(&p, &t);
zero = smooth = p.pressure;
}
void loop() {
sensors_event_t p, t;
lps.getEvent(&p, &t);
smooth = smooth * 0.9 + p.pressure * 0.1;
if (digitalRead(2) == LOW) { zero = smooth; lastFloor = 0; }
int floorNow = round((zero - smooth) / HPA_PER_FLOOR);
if (floorNow > lastFloor) climbed += floorNow - lastFloor;
lastFloor = floorNow;
oled.clearDisplay();
oled.setTextSize(1); oled.setCursor(0, 0); oled.print("Floor");
oled.setTextSize(3); oled.setCursor(0, 14); oled.print(floorNow);
oled.setTextSize(1); oled.setCursor(0, 52); oled.print("Climbed "); oled.print(climbed);
oled.display();
delay(100);
}
Weather is changing; press zero again at ground level.
Lift shafts have pressure gusts; the smoothing settles it within seconds.
Floor heights differ; measure yours and set HPA_PER_FLOOR.
It resolves about 0.01 hPa, roughly 10 cm of height.
Closed rooms with strong fans can shift pressure slightly; it settles when you leave.
Yes, convert pressure to metres instead of floors.
6 parts: Adafruit LPS22 Pressure Sensor – STEMMA QT / Qwiic – LPS22HB, Generic Nano CH340 Development Board (Soldered), 0.96" OLED Display 128x64, Tactile Push Button Switch, 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 (floor_counter.ino).
About ₹1,507 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Pressure and altitude; Filtering a sensitive signal; Separating fast changes from slow drift.
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.