LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsRecognise the signature of a fall, near weightlessness followed by a heavy impact, and raise an alarm that can be cancelled. A falling object is in free fall, and an accelerometer in free fall reads close to zero, gravity is no longer being resisted. That brief near-zero reading, followed within half a second by a large impact spike, is a far more specific signature than impact alone, which is why simply dropping the board on a cushion does not trigger it. Real devices then wait before calling for help, so the user can cancel a false alarm.
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
MPU6050 motion sensor: 3-axis accelerometer and gyroscope on I2C
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_066_fall_detection_prototype.inoVerify & upload in Electrolark#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
Adafruit_SSD1306 display(128, 64, &Wire, -1);
Adafruit_MPU6050 mpu;
int led = 25;
int buzzer = 33;
int cancelButton = 12;
float freeFallBelow = 3.0; // m/s2 - near weightless
float impactAbove = 22.0; // m/s2 - hard landing
unsigned long impactWindow = 600; // Impact must follow this soon
bool freeFalling = false;
unsigned long freeFallTime = 0;
bool alarm = false;
unsigned long alarmStart = 0;
unsigned long callDelay = 15000;
int fallsDetected = 0;
void setup()
{
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(cancelButton, INPUT_PULLUP);
Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { while (true) { } }
display.setTextColor(SSD1306_WHITE);
if (!mpu.begin())
{
display.clearDisplay();
display.setCursor(0, 28);
display.print("MPU6050 not found");
display.display();
while (true) { }
}
mpu.setAccelerometerRange(MPU6050_RANGE_16_G);
mpu.setFilterBandwidth(MPU6050_BAND_94_HZ);
}
void loop()
{
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
float magnitude = sqrt(a.acceleration.x * a.acceleration.x +
a.acceleration.y * a.acceleration.y +
a.acceleration.z * a.acceleration.z);
if (!alarm)
{
if (magnitude < freeFallBelow && !freeFalling)
{
freeFalling = true;
freeFallTime = millis();
Serial.println("Free fall detected");
}
if (freeFalling && millis() - freeFallTime > impactWindow)
{
freeFalling = false; // No impact followed - not a fall
}
if (freeFalling && magnitude > impactAbove)
{
alarm = true;
alarmStart = millis();
freeFalling = false;
fallsDetected = fallsDetected + 1;
Serial.println("FALL DETECTED");
}
}
if (alarm)
{
digitalWrite(led, (millis() / 300) % 2);
if ((millis() / 600) % 2 == 0)
{
tone(buzzer, 2000, 200);
}
if (digitalRead(cancelButton) == LOW)
{
alarm = false;
noTone(buzzer);
digitalWrite(led, LOW);
Serial.println("Alarm cancelled by user");
delay(300);
}
if (millis() - alarmStart > callDelay)
{
Serial.println("*** ALERTING EMERGENCY CONTACT ***");
alarm = false;
digitalWrite(led, LOW);
}
}
else
{
digitalWrite(led, LOW);
}
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.print("FALL DETECTION");
if (alarm)
{
display.setTextSize(2);
display.setCursor(0, 14);
display.print("FALL!");
display.setTextSize(1);
display.setCursor(0, 36);
display.print("Calling in ");
display.print((callDelay - (millis() - alarmStart)) / 1000);
display.print("s");
display.setCursor(0, 48);
display.print("Press D3 if you");
display.setCursor(0, 56);
display.print("are OK");
}
else
{
display.setTextSize(2);
display.setCursor(0, 14);
display.print(freeFalling ? "FALLING" : "MONITOR");
display.setTextSize(1);
display.setCursor(0, 38);
display.print("Force ");
display.print(magnitude, 1);
display.print(" m/s2");
display.setCursor(0, 50);
display.print("Falls today: ");
display.print(fallsDetected);
}
display.display();
}
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.
The sketch uses INPUT_PULLUP, so one leg goes to the GPIO and the other to GND. Use two legs on opposite sides of the button.
This project needs the passive buzzer (the one that plays notes), not the active one.
A falling object is in free fall, and an accelerometer in free fall reads close to zero, gravity is no longer being resisted. That brief near-zero reading, followed within half a second by a large impact spike, is a far more specific signature than impact alone, which is why simply dropping the board on a cushion does not trigger it. Real devices then wait before calling for help, so the user can cancel a false alarm.
Normal handling shows MONITOR with the live force reading. Drop the board a short distance onto a thick cushion. Free fall then impact gives FALL! with a flashing LED and alarm.
Yes. It is project 66 of 120 in the Geekobot Titan Kit, in level 11 (Motion and IMU). 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), Through-Hole LED Pack (Pack of 10), Carbon Film Resistor 1/4W 5% (Pack of 10), Tactile Push Button Switch, Buzzer Module 3.3–5V, 0.96" OLED Display 128x64, GY-521 MPU6050 6-Axis Gyro and Accelerometer Module, 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 advanced project and takes about 45 minutes. The build on this page has 8 steps.
No. This page has the complete, tested code (titan_kit_066_fall_detection_prototype.ino).
About ₹1,044 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Freefall detection algorithms; Why free fall reads near zero on an accelerometer; Requiring two events in sequence within a window; Cancellable alarms with a grace period.
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.