LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsModel a two-bay car park: ultrasonic sensors watch each bay and an LCD plus coloured LEDs show which spaces are free. Both bays run the same measurement, so the trigger and echo pins live in arrays and one loop handles them all, adding a third bay means extending the arrays, not copying the code. A car parked in a bay sits close to the sensor, so a short distance means occupied. Measuring one sensor at a time with a short pause between them stops the second sensor from hearing the first sensor's echo.
Every part for this build comes in the Geekobot Explorer Kit box, a Geekobot exclusive, together with the parts for all 61 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.
The brain of every Explorer Kit project
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 segment
16x2 LCD with I2C backpack: four wires, two lines of text
HC-SR04 ultrasonic distance sensor
Nano I/O shield from the kit: every pin has its own S, V, G header, so modules plug in with jumpers
Follow the colours: red is power, dark grey is ground, blue is a signal.
explorer_kit_40_smart_parking_demo.inoVerify & upload in Electrolark#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int trigPins[2] = {2, 4};
int echoPins[2] = {3, 5};
int greenLeds[2] = {6, 8};
int redLeds[2] = {7, 9};
int occupiedBelow = 12; // cm
LiquidCrystal_I2C lcd(0x27, 16, 2);
long readBay(int bay)
{
digitalWrite(trigPins[bay], LOW);
delayMicroseconds(2);
digitalWrite(trigPins[bay], HIGH);
delayMicroseconds(10);
digitalWrite(trigPins[bay], LOW);
long duration = pulseIn(echoPins[bay], HIGH, 25000);
if (duration == 0)
{
return 200;
}
return duration * 0.034 / 2;
}
void setup()
{
for (int i = 0; i < 2; i++)
{
pinMode(trigPins[i], OUTPUT);
pinMode(echoPins[i], INPUT);
pinMode(greenLeds[i], OUTPUT);
pinMode(redLeds[i], OUTPUT);
}
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Smart Parking");
delay(2000);
lcd.clear();
}
void loop()
{
int freeCount = 0;
for (int i = 0; i < 2; i++)
{
long distance = readBay(i);
bool occupied = (distance < occupiedBelow);
digitalWrite(redLeds[i], occupied);
digitalWrite(greenLeds[i], !occupied);
if (!occupied)
{
freeCount = freeCount + 1;
}
lcd.setCursor(0, i);
lcd.print("Bay ");
lcd.print(i + 1);
lcd.print(": ");
if (occupied)
{
lcd.print("FULL ");
}
else
{
lcd.print("FREE ");
}
Serial.print("Bay ");
Serial.print(i + 1);
Serial.print(" distance ");
Serial.println(distance);
delay(60); // Let the echo die away
}
lcd.setCursor(11, 0);
lcd.print("F:");
lcd.print(freeCount);
delay(400);
}
Use the kit's mini-USB cable, install the CH340 driver on Windows if no port appears, pick Tools > Board > Arduino Nano and try Tools > Processor > ATmega328P (Old Bootloader) if the upload times out.
Turn it round: the long leg (anode) goes to the pin side through the 220 ohm resistor, the short leg to GND.
Turn the small contrast pot on the back of the I2C board. If still blank, change 0x27 in the sketch to 0x3F.
Point the sensor at a flat object 5 to 200 cm away and check TRIG and ECHO are not swapped.
Both bays run the same measurement, so the trigger and echo pins live in arrays and one loop handles them all, adding a third bay means extending the arrays, not copying the code. A car parked in a bay sits close to the sensor, so a short distance means occupied. Measuring one sensor at a time with a short pause between them stops the second sensor from hearing the first sensor's echo.
Bay 1: FREE / Bay 2: FREE with both green LEDs on. Place a book within 12 cm of one sensor: that bay shows FULL and its red LED lights. The free-space count in the corner updates immediately.
Yes. It is project 40 of 61 in the Geekobot Explorer Kit, in level 7 (Robotics and motion). 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 Explorer Kit project is wired on the Nano I/O shield and the breadboard with jumper wires.
8 parts: Generic Nano CH340 Development Board (Soldered), USB Cable, Dupont Jumper Wires (40 pcs), Through-Hole LED Pack (Pack of 10), Carbon Film Resistor 1/4W 5% (Pack of 10), LCD1602 16x2 Character LCD Display, 2 × HC-SR04 Ultrasonic Range Finder Sensor Module for Arduino and Arduino Nano IO Expansion Shield (328P Compatible). 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 1 hour. The build on this page has 6 steps.
No. This page has the complete, tested code (explorer_kit_40_smart_parking_demo.ino).
About ₹682 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Precision distance measurement; Handling several identical sensors with arrays; Avoiding cross-talk between ultrasonic sensors; Summarising several states into one count.
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.