LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsThe Waveshare TOF Mini uses a 940 nm laser pulse and measures its flight time. In its default active UART mode it streams 16-byte frames at 921600 baud: the frame starts 0x57 0x00, the distance in millimetres is in bytes 8-10, and the last byte is a checksum. The ESP32's hardware UART handles that baud rate easily. A button freezes the reading like a real laser measure.
Do not point any laser device into people's eyes.
Tick anything you already have and the total updates.
Waveshare TOF Mini laser range sensor
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB power bank, so it is portable.
laser_tape.inoVerify & upload in Electrolark#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
void big(const char* top, float value, int dp, const char* unit) {
oled.clearDisplay(); oled.setTextColor(WHITE);
oled.setTextSize(1); oled.setCursor(0, 0); oled.print(top);
oled.setTextSize(3); oled.setCursor(0, 20); oled.print(value, dp);
oled.setTextSize(1); oled.print(" "); oled.print(unit);
oled.display();
}
uint8_t f[16];
bool hold = false;
long shown = 0;
long readMm() {
while (Serial2.available() >= 16) {
if (Serial2.read() != 0x57) continue;
f[0] = 0x57; Serial2.readBytes(f + 1, 15);
uint8_t sum = 0;
for (int i = 0; i < 15; i++) sum += f[i];
if (f[1] == 0x00 && sum == f[15]) return f[8] | (f[9] << 8) | ((long)f[10] << 16);
}
return -1;
}
void setup() {
Serial2.begin(921600, SERIAL_8N1, 16, 17);
pinMode(4, INPUT_PULLUP);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
void loop() {
long mm = readMm();
if (digitalRead(4) == LOW) { hold = !hold; delay(300); }
if (mm >= 0 && !hold) shown = mm;
big(hold ? "Distance HOLD" : "Distance", shown / 1000.0, 3, "m");
delay(50);
}
The sensor may be in I2C or query mode; reset it to UART active mode with Waveshare's tool.
Dark or shiny targets reflect less; aim at a matt surface.
Sunlight reduces range; it reaches 7.8 m indoors.
It is a Class 1 infrared laser, safe in normal use; still do not stare into it.
About 1-3 cm over its range.
Not at 921600 baud with SoftwareSerial; use the I2C mode or an ESP32.
6 parts: Waveshare TOF Mini Laser Range Sensor, UART/I2C, Up to 7.8m Range, ESP32-WROOM-32 38-Pin Development Board, 0.96" OLED Display 128x64, Tactile Push Button Switch, Solderless Breadboard and Dupont Jumper Wires (40 pcs). 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 2 hours. The build on this page has 5 steps.
No. This page has the complete, tested code (laser_tape.ino).
About ₹1,691 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Time-of-flight distance sensing; Parsing a fixed binary frame at high baud; Hold and zero functions.
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.