LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsThe VL53L1X measures distance with a laser pulse. Aimed across a narrow gap, the distance reads the far wall until a person steps in front, when it drops sharply. The sketch counts each drop below a threshold as one pass. A single sensor cannot tell which direction someone went, so this counts passes, not people in the room, and two people walking side by side count as one. For direction, two sensors are needed.
Tick anything you already have and the total updates.
VL53L1X laser distance sensor
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB phone charger.
people_counter.inoVerify & upload in Electrolark#include <Wire.h>
#include <VL53L1X.h>
#include <Adafruit_SSD1306.h>
VL53L1X sensor;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const int TRIGGER_MM = 1000; // a pass is any reading closer than this
const unsigned long DEAD_MS = 600; // ignore re-triggers for this long
int count = 0;
bool inBeam = false;
unsigned long lastPass = 0;
void draw() {
oled.clearDisplay(); oled.setTextColor(WHITE);
oled.setTextSize(1); oled.setCursor(0, 0); oled.print("People passed");
oled.setTextSize(4); oled.setCursor(0, 24); oled.print(count);
oled.display();
}
void setup() {
Wire.begin(21, 22);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
sensor.setTimeout(500);
sensor.init();
sensor.setDistanceMode(VL53L1X::Short);
sensor.setMeasurementTimingBudget(20000);
sensor.startContinuous(25);
draw();
}
void loop() {
int mm = sensor.read();
bool near = (mm > 0 && mm < TRIGGER_MM);
if (near && !inBeam && millis() - lastPass > DEAD_MS) {
count++;
lastPass = millis();
draw();
}
inBeam = near;
}
Increase DEAD_MS or narrow the sensor's view with a short tube.
Check TRIGGER_MM against the background distance in the Serial Monitor.
Check I2C wiring and that the sensor initialised.
Not with one sensor. Use two sensors a few centimetres apart and compare the order they trigger.
Strong direct sun reduces the range. Shade the sensor.
Short mode works to about 1.3 metres, best in shade.
5 parts: ESP32-WROOM-32 38-Pin Development Board, Generic TOF400C VL53L1X Laser Ranging Sensor Module – I2C Interface, 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 advanced project and takes about 2 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (people_counter.ino).
About ₹1,154 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Reading a VL53L1X over I2C; Detecting a change from a background distance; Why one beam cannot tell direction.
Ideas that reuse this build: ESP32 VL53L1X laser distance meter. 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.