LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsScroll and select items in an OLED menu purely by tilting, with no buttons at all. Tilting forward and back moves the highlight; holding a right tilt for half a second selects. That hold-to-confirm gesture solves the hardest problem in a button-free interface, telling a deliberate choice from a passing movement. The menu itself scrolls: only three of the five items fit on screen, so a window offset follows the selection, which is how every scrolling list works internally.
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_070_gesture_controlled_menu_na.inoVerify & upload in Electrolark#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#define ITEMS 5
#define VISIBLE 3
Adafruit_SSD1306 display(128, 64, &Wire, -1);
Adafruit_MPU6050 mpu;
int ledPins[3] = {27, 26, 25};
int buzzer = 33;
const char* menu[ITEMS] =
{
"Light 1", "Light 2", "Light 3", "All On", "All Off"
};
int selected = 0;
int windowTop = 0;
bool atRest = true;
unsigned long selectStart = 0;
bool selecting = false;
unsigned long holdNeeded = 600;
String lastAction = "none";
void doAction(int index)
{
if (index < 3)
{
digitalWrite(ledPins[index], !digitalRead(ledPins[index]));
lastAction = String(menu[index]) + " toggled";
}
else if (index == 3)
{
for (int i = 0; i < 3; i++) digitalWrite(ledPins[i], HIGH);
lastAction = "All lights on";
}
else
{
for (int i = 0; i < 3; i++) digitalWrite(ledPins[i], LOW);
lastAction = "All lights off";
}
tone(buzzer, 1400, 150);
Serial.println(lastAction);
}
void setup()
{
for (int i = 0; i < 3; 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);
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;
if (abs(pitch) < 12)
{
atRest = true;
}
if (atRest && pitch < -25)
{
selected = (selected + 1) % ITEMS;
atRest = false;
tone(buzzer, 800, 40);
}
else if (atRest && pitch > 25)
{
selected = (selected - 1 + ITEMS) % ITEMS;
atRest = false;
tone(buzzer, 800, 40);
}
// Keep the selection inside the visible window
if (selected < windowTop) windowTop = selected;
if (selected > windowTop + VISIBLE - 1) windowTop = selected - VISIBLE + 1;
// Hold a right tilt to select
if (roll > 30)
{
if (!selecting)
{
selecting = true;
selectStart = millis();
}
else if (millis() - selectStart > holdNeeded)
{
doAction(selected);
selecting = false;
delay(500);
}
}
else
{
selecting = false;
}
display.clearDisplay();
display.setCursor(0, 0);
display.print("TILT MENU");
for (int row = 0; row < VISIBLE; row++)
{
int item = windowTop + row;
if (item >= ITEMS) break;
int y = 14 + row * 12;
if (item == selected)
{
display.fillRect(0, y - 2, 128, 12, SSD1306_WHITE);
display.setTextColor(SSD1306_BLACK);
}
display.setCursor(4, y);
display.print(item + 1);
display.print(". ");
display.print(menu[item]);
display.setTextColor(SSD1306_WHITE);
}
// Scroll position indicator
int barHeight = 36 * VISIBLE / ITEMS;
int barY = 12 + (36 - barHeight) * windowTop / (ITEMS - VISIBLE);
display.drawRect(124, 12, 4, 36, SSD1306_WHITE);
display.fillRect(125, barY, 2, barHeight, SSD1306_WHITE);
display.setCursor(0, 54);
if (selecting)
{
display.print("Selecting... hold");
}
else
{
display.print(lastAction);
}
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.
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).
Tilting forward and back moves the highlight; holding a right tilt for half a second selects. That hold-to-confirm gesture solves the hardest problem in a button-free interface, telling a deliberate choice from a passing movement. The menu itself scrolls: only three of the five items fit on screen, so a window offset follows the selection, which is how every scrolling list works internally.
A menu of five items with the current one highlighted. Tilt forward or back to move the highlight, one item per tilt. A scroll bar on the right shows your position in the list.
Yes. It is project 70 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.
10 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, GY-521 MPU6050 6-Axis Gyro and Accelerometer Module and ESP32 38-Pin Expansion Board. 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 7 steps.
No. This page has the complete, tested code (titan_kit_070_gesture_controlled_menu_na.ino).
About ₹1,067 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
UI navigation via motion; Hold-to-confirm as a selection gesture; Scrolling windows over a longer list; Highlighting with inverted text.
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.