LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsUnlock the system with a secret sequence of tilts, a gesture password rather than a typed one. This combines two earlier ideas: gesture recognition from Experiment 33 and sequence matching from the touch password. Each tilt is converted to a direction number and appended to an entered array, then compared with the secret. A gesture only counts once the board has returned to flat, which forces a deliberate rhythm, tilt, return, tilt, and prevents one long lean from filling the whole sequence.
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_069_motion_password.inoVerify & upload in Electrolark#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#define LENGTH 4
Adafruit_SSD1306 display(128, 64, &Wire, -1);
Adafruit_MPU6050 mpu;
int greenLed = 27;
int redLed = 26;
int buzzer = 33;
int clearButton = 12;
// 1 up, 2 down, 3 left, 4 right
int secret[LENGTH] = {4, 3, 1, 2};
int entered[LENGTH];
int position = 0;
const char* names[5] = {"-", "UP", "DOWN", "LEFT", "RIGHT"};
bool atRest = true;
bool unlocked = false;
unsigned long unlockedAt = 0;
int readGesture(float pitch, float roll)
{
if (pitch > 30) return 1;
if (pitch < -30) return 2;
if (roll < -30) return 3;
if (roll > 30) return 4;
return 0;
}
void setup()
{
pinMode(greenLed, OUTPUT);
pinMode(redLed, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(clearButton, 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_2_G);
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
}
void loop()
{
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
float pitch = atan2(a.acceleration.y,
sqrt(a.acceleration.x * a.acceleration.x +
a.acceleration.z * a.acceleration.z)) * 180.0 / PI;
float roll = atan2(-a.acceleration.x, a.acceleration.z) * 180.0 / PI;
int gesture = readGesture(pitch, roll);
if (digitalRead(clearButton) == LOW)
{
position = 0;
unlocked = false;
Serial.println("Entry cleared");
delay(300);
}
// Must return to flat between gestures
if (abs(pitch) < 12 && abs(roll) < 12)
{
atRest = true;
}
if (gesture > 0 && atRest && !unlocked)
{
atRest = false;
entered[position] = gesture;
position = position + 1;
tone(buzzer, 900 + gesture * 100, 80);
Serial.print("Gesture ");
Serial.println(names[gesture]);
if (position >= LENGTH)
{
bool correct = true;
for (int i = 0; i < LENGTH; i++)
{
if (entered[i] != secret[i]) correct = false;
}
if (correct)
{
unlocked = true;
unlockedAt = millis();
digitalWrite(greenLed, HIGH);
tone(buzzer, 1600, 400);
Serial.println("UNLOCKED");
}
else
{
digitalWrite(redLed, HIGH);
tone(buzzer, 200, 500);
Serial.println("WRONG SEQUENCE");
delay(900);
digitalWrite(redLed, LOW);
}
position = 0;
}
}
if (unlocked && millis() - unlockedAt > 5000)
{
unlocked = false;
digitalWrite(greenLed, LOW);
}
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.print("GESTURE LOCK");
display.setTextSize(2);
display.setCursor(0, 14);
display.print(unlocked ? "UNLOCKED" : "LOCKED");
display.setTextSize(1);
display.setCursor(0, 36);
display.print("Entered: ");
for (int i = 0; i < LENGTH; i++)
{
display.print(i < position ? "*" : ".");
display.print(" ");
}
display.setCursor(0, 46);
display.print("Now: ");
display.print(names[gesture]);
display.print(atRest ? " (ready)" : " (return flat)");
display.setCursor(0, 56);
display.print("D3 clears entry");
display.display();
delay(40);
}
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.
This combines two earlier ideas: gesture recognition from Experiment 33 and sequence matching from the touch password. Each tilt is converted to a direction number and appended to an entered array, then compared with the secret. A gesture only counts once the board has returned to flat, which forces a deliberate rhythm, tilt, return, tilt, and prevents one long lean from filling the whole sequence.
The screen shows LOCKED with four dots for the sequence. Tilt right, return flat, tilt left, return flat, and so on. Each accepted gesture adds a star and plays a different tone.
Yes. It is project 69 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), 2 × 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 intermediate project and takes about 45 minutes. The build on this page has 8 steps.
No. This page has the complete, tested code (titan_kit_069_motion_password.ino).
About ₹1,059 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Sequence matching with IMUs; Requiring a return to neutral between gestures; Combining gesture recognition with authentication; Masking an entry while it is being made.
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.