LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsBuild a precise digital tape measure with fast polling, unit switching and a memory of recent measurements. Precision comes from polling quickly and reporting steadily. The sensor is read as fast as it allows, but the value shown is an average of the last eight readings, and a stability check compares the newest reading with that average, so the display can tell you when it is safe to record. Three unit systems are offered from one stored value in centimetres, because converting on display rather than on capture keeps the stored data clean.
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
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_099_smart_measuring_tape.inoVerify & upload in Electrolark#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define WINDOW 8
#define MEMORY 4
Adafruit_SSD1306 display(128, 64, &Wire, -1);
int trigPin = 32, echoPin = 5;
int storeButton = 12, unitButton = 14, buzzer = 33;
float samples[WINDOW];
int sampleIndex = 0;
bool windowFull = false;
float stored_[MEMORY];
int storedCount = 0;
int units = 0; // 0 cm, 1 mm, 2 inches
const char* unitName[3] = {"cm", "mm", "in"};
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 -1;
return duration * 0.0343 / 2.0;
}
float average()
{
int count = windowFull ? WINDOW : sampleIndex;
if (count == 0) return 0;
float total = 0;
for (int i = 0; i < count; i++) total = total + samples[i];
return total / count;
}
float convert(float cm)
{
if (units == 1) return cm * 10.0;
if (units == 2) return cm / 2.54;
return cm;
}
void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(storeButton, INPUT_PULLUP);
pinMode(unitButton, INPUT_PULLUP);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { while (true) { } }
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
}
void loop()
{
float reading = readDistance();
if (reading > 0)
{
samples[sampleIndex] = reading;
sampleIndex = sampleIndex + 1;
if (sampleIndex >= WINDOW)
{
sampleIndex = 0;
windowFull = true;
}
}
float value = average();
bool steady = (reading > 0 && abs(reading - value) < 0.5);
if (digitalRead(unitButton) == LOW)
{
units = (units + 1) % 3;
tone(buzzer, 1000, 60);
delay(250);
}
if (digitalRead(storeButton) == LOW)
{
if (storedCount >= MEMORY)
{
for (int i = 0; i < MEMORY - 1; i++) stored_[i] = stored_[i + 1];
storedCount = MEMORY - 1;
}
stored_[storedCount] = value;
storedCount = storedCount + 1;
tone(buzzer, 1600, 150);
Serial.print("Stored ");
Serial.print(value, 2);
Serial.println(" cm");
delay(350);
}
display.clearDisplay();
display.setCursor(0, 0);
display.print("MEASURING TAPE");
display.setCursor(96, 0);
display.print(steady ? "STEADY" : "...");
display.setTextSize(3);
display.setCursor(0, 12);
display.print(convert(value), units == 1 ? 0 : 1);
display.setTextSize(1);
display.setCursor(96, 24);
display.print(unitName[units]);
display.drawLine(0, 38, 127, 38, SSD1306_WHITE);
display.setCursor(0, 42);
display.print("Memory:");
for (int i = 0; i < storedCount; i++)
{
display.setCursor((i % 2) * 64, 52 + (i / 2) * 0);
if (i < 2)
{
display.print(convert(stored_[i]), 1);
display.print(unitName[units]);
display.print(" ");
}
}
if (storedCount == 0)
{
display.setCursor(44, 42);
display.print("empty - D3 stores");
}
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.
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.
Check SDA on GPIO21 and SCL on GPIO22, power from 3V3, and that the sketch uses address 0x3C (some boards are 0x3D).
Precision comes from polling quickly and reporting steadily. The sensor is read as fast as it allows, but the value shown is an average of the last eight readings, and a stability check compares the newest reading with that average, so the display can tell you when it is safe to record. Three unit systems are offered from one stored value in centimetres, because converting on display rather than on capture keeps the stored data clean.
The measurement updates continuously with a STEADY flag when it settles. Press the second button to switch between centimetres, millimetres and inches. Press the first button to store the current value into memory.
Yes. It is project 99 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.
10 parts: ESP32-WROOM-32 38-Pin Development Board, USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), 2 × Tactile Push Button Switch, 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) 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 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_099_smart_measuring_tape.ino).
About ₹936 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
High-precision polling; Averaging a sliding window of samples; Detecting when a reading has settled; Converting units at display time, not at capture.
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.