LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsCheck that people waiting in a line are keeping a safe distance apart, using zones rather than a single threshold. Zoned tracking divides a continuous distance into named regions with fixed boundaries, and the useful addition here is time. Momentarily stepping close is not a problem; standing close for ten seconds is. The sketch therefore tracks how long the current zone has been occupied and only escalates once that time passes, which is the same sustained-condition idea used by the noise monitor, applied to space instead of sound.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
Every part for this build comes in the Geekobot Titan Kit box, a Geekobot exclusive, together with the parts for all 120 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
ESP32 DevKit V1 (38-pin): the brain of every Titan Kit project, with Wi-Fi and Bluetooth
Male-to-female and female-to-female leads for the modules
LEDs from the kit's red, green, yellow and blue packs
220 ohm resistors: one in series with every LED
HC-SR04 ultrasonic distance sensor
1k and 2k resistors: drop a 5V signal to the 3.3V an ESP32 pin can take
ESP32 expansion board from the kit: every GPIO has its own S, V, G header
Follow the colours: red is power, dark grey is ground, blue is a signal.
titan_kit_094_queue_distance_monitor.inoVerify & upload in Electrolark#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define ZONES 3
Adafruit_SSD1306 display(128, 64, &Wire, -1);
int trigPin = 32, echoPin = 5;
int ledPins[ZONES] = {27, 26, 25};
int buzzer = 33;
int zoneLimit[ZONES] = {60, 120, 400}; // cm
const char* zoneName[ZONES] = {"TOO CLOSE", "CLOSE", "SAFE"};
int currentZone = 2;
unsigned long zoneSince = 0;
unsigned long warnAfter = 5000;
int violations = 0;
float smoothed = 200;
float readDistance()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH, 30000);
if (duration == 0) return 400;
return duration * 0.0343 / 2.0;
}
int zoneFor(float distance)
{
for (int i = 0; i < ZONES; i++)
{
if (distance < zoneLimit[i]) return i;
}
return ZONES - 1;
}
void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
for (int i = 0; i < ZONES; i++) pinMode(ledPins[i], OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { while (true) { } }
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
zoneSince = millis();
}
void loop()
{
smoothed = smoothed * 0.6 + readDistance() * 0.4;
int zone = zoneFor(smoothed);
if (zone != currentZone)
{
currentZone = zone;
zoneSince = millis();
Serial.print("Zone: ");
Serial.println(zoneName[zone]);
}
unsigned long inZone = millis() - zoneSince;
for (int i = 0; i < ZONES; i++)
{
digitalWrite(ledPins[i], i == zone);
}
bool warning = (zone == 0 && inZone > warnAfter);
if (warning && (millis() / 700) % 2 == 0)
{
tone(buzzer, 1300, 180);
}
if (zone == 0 && inZone > warnAfter && inZone < warnAfter + 100)
{
violations = violations + 1;
}
display.clearDisplay();
display.setCursor(0, 0);
display.print("QUEUE MONITOR");
display.setTextSize(2);
display.setCursor(0, 12);
display.print((int)smoothed);
display.setTextSize(1);
display.print(" cm");
display.setCursor(70, 18);
display.print(zoneName[zone]);
// Zone bar with boundaries
display.drawRect(0, 34, 128, 10, SSD1306_WHITE);
int marker = map(constrain((int)smoothed, 0, 200), 0, 200, 1, 125);
display.fillRect(marker, 35, 3, 8, SSD1306_WHITE);
for (int i = 0; i < ZONES - 1; i++)
{
int x = map(zoneLimit[i], 0, 200, 0, 126);
display.drawLine(x, 32, x, 46, SSD1306_WHITE);
}
display.setCursor(0, 48);
display.print("In zone ");
display.print(inZone / 1000);
display.print("s");
display.setCursor(0, 56);
if (warning) display.print("PLEASE STEP BACK");
else if (zone == 0) display.print("Close - watch the time");
else display.print("Violations: ");
if (!warning && zone != 0)
{
display.print(violations);
}
display.display();
delay(150);
}
Use a micro-USB data cable (some cables only charge), install the CP210x or CH340 driver if no port appears, pick Tools > Board > ESP32 Dev Module and hold the BOOT button on the board until the upload starts.
Turn it round: the long leg (anode) goes to the GPIO side through the 220 ohm resistor, the short leg to GND.
This project needs the passive buzzer (the one that plays notes), not the active one.
Check SDA on GPIO21 and SCL on GPIO22, power from 3V3, and that the sketch uses address 0x3C (some boards are 0x3D).
Zoned tracking divides a continuous distance into named regions with fixed boundaries, and the useful addition here is time. Momentarily stepping close is not a problem; standing close for ten seconds is. The sketch therefore tracks how long the current zone has been occupied and only escalates once that time passes, which is the same sustained-condition idea used by the noise monitor, applied to space instead of sound.
Standing well back shows SAFE with the green LED. Move to about a metre: CLOSE with the yellow LED. Move inside 60 cm: TOO CLOSE, red LED and a running timer.
Yes. It is project 94 of 120 in the Geekobot Titan Kit, in level 14 (Distance). Every part on the list comes in the kit box, and you can also buy the parts one by one from the list above.
No. Every Titan Kit project is wired on the ESP32 expansion board and the breadboard with jumper wires.
11 parts: ESP32-WROOM-32 38-Pin Development Board, USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), 3 × Through-Hole LED Pack (Pack of 10), Carbon Film Resistor 1/4W 5% (Pack of 10), Buzzer Module 3.3–5V, 0.96" OLED Display 128x64, HC-SR04 Ultrasonic Range Finder Sensor Module for Arduino, Carbon Film Resistor 1/4W 5% (Pack of 10), plus 1 more. 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 45 minutes. The build on this page has 7 steps.
No. This page has the complete, tested code (titan_kit_094_queue_distance_monitor.ino).
About ₹976 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Zoned distance tracking; Timing how long a condition persists; Drawing zone boundaries on a scale; Counting violations rather than just flagging them.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
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.