LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsA TF-Luna LiDAR measures distance with a pulse of infrared light from 20 cm to 8 m, and works on dark and shiny cars where ultrasonic sensors struggle. Mount it on the garage wall at bumper height. An ESP32 reads the 9-byte frames over UART and lights green while the car is far, yellow as it gets close and red with a fast beep at the stop point.
Keep the beeper volume low indoors and the wiring away from the car's path.
Tick anything you already have and the total updates.
TF-Luna LiDAR, 0.2 to 8 m, UART
Sharp 4-30 cm IR sensor for short-range jobs such as a robot bumper
E18-D80NK IR switch: just a yes/no output at an adjustable distance
IR tracking module for line-following robots
Spare 4-pin cable for TFMini-family LiDARs
Follow the colours: red is power, dark grey is ground, blue is a signal.
parking_lidar.inoVerify & upload in ElectrolarkHardwareSerial lidar(2);
const int G = 25, Y = 26, R = 27, BUZ = 14;
int STOP_CM = 60;
int readLuna() { // returns cm, or -1 if no valid frame
while (lidar.available() >= 9) {
if (lidar.read() != 0x59) continue;
if (lidar.peek() != 0x59) continue;
uint8_t f[9]; f[0] = 0x59;
for (int i = 1; i < 9; i++) f[i] = lidar.read();
uint8_t sum = 0;
for (int i = 0; i < 8; i++) sum += f[i];
if (sum != f[8]) continue;
int dist = f[2] | (f[3] << 8);
int amp = f[4] | (f[5] << 8);
if (amp < 100 || amp == 65535) return -1; // signal too weak or saturated
return dist;
}
return -2; // no new frame yet
}
void setup() {
Serial.begin(115200);
lidar.begin(115200, SERIAL_8N1, 16, 17);
pinMode(G, OUTPUT); pinMode(Y, OUTPUT); pinMode(R, OUTPUT); pinMode(BUZ, OUTPUT);
}
int last = 800;
unsigned long beepAt = 0;
void loop() {
int d = readLuna();
if (d >= 0) { last = d; Serial.println(d); }
bool red = last <= STOP_CM, yellow = !red && last < STOP_CM + 60;
digitalWrite(R, red); digitalWrite(Y, yellow); digitalWrite(G, !red && !yellow);
int gap = red ? 120 : yellow ? 400 : 0;
if (gap && millis() - beepAt > (unsigned long)gap) {
digitalWrite(BUZ, HIGH); delay(40); digitalWrite(BUZ, LOW); beepAt = millis();
}
delay(10);
}
The sketch above runs here on a simulated ESP32. Move the sliders for the sensors and buttons it reads, and watch the Serial monitor, display and outputs change.
Swap GPIO16 and GPIO17. The TF-Luna starts at 115200 baud in UART mode.
Direct sunlight into the lens lowers the signal; the code ignores weak frames, so shade the sensor.
Lower STOP_CM, or check the LiDAR sees the bumper and not the number plate gap.
LiDAR has a narrow beam, reads further and is not confused by angled car panels.
It is a Class 1 device, but do not stare into it.
Yes, add a relay module and switch the light when a car comes within 3 m.
11 parts: ESP32-WROOM-32 38-Pin Development Board, Benewake TF-LUNA Micro LiDAR Distance Sensor (Range: 0.2m~8m) – UART/I2C Interface, Through-Hole LED Pack (Pack of 10), Resistor Assortment Kit (30 Values), Buzzer Module 3.3–5V, Sharp Microelectronics GP2Y0A41SK0F 4–30 cm IR Distance Sensor with Cable, Generic E18-D80NK Mini Adjustable Infrared Sensor Switch 3-80cm – Diffuse Reflective, Digital Output, 70cm Wire, HS-S01-L Infrared Tracking Sensor Module – Digital Output, 2.54mm Pin Header, Generic Replacement 4-Pin Cable for TF Mini & TF Mini S LiDAR – 10cm Grove-Compatible, Solderless Breadboard, 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 beginner project and takes about 1 to 2 hours. The build on this page has 5 steps.
No. This page has the complete, tested code (parking_lidar.ino).
Yes. The Run it panel under the code runs this exact sketch on a simulated board. Move the sliders or press the buttons for the sensors it reads, and the Serial monitor, display and outputs react as they will on the real build. It is a simulation, so real readings depend on your parts and wiring.
About ₹3,766 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Parsing a binary UART frame with a checksum; Choosing thresholds and hysteresis; Comparing LiDAR, IR and switch-type distance sensors.
Ideas that reuse this build: Bike GNSS trip computer. They are listed under Take it further on this page.
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.
Learning project. Check every circuit and the datasheet of each part before you power it up.
A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.