LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsEnter a PIN on a 4×4 keypad and let a servo open the door only when the code is correct. A matrix keypad has sixteen buttons but only eight wires. The library drives one row LOW at a time and reads all four columns, where a LOW appears, that button is down. This is keypad matrix scanning, the same trick the LED matrix used in reverse. Each key press is added to a String; pressing # compares that String with the stored password, and * clears it so a mistake can be retyped.
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
16x2 LCD with I2C backpack: four wires, two lines of text
SG90 servo: turns to the angle the sketch asks for
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_026_password_door_lock.inoVerify & upload in Electrolark#include <Keypad.h>
#include <ESP32Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] =
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {32, 33, 25, 26};
byte colPins[COLS] = {27, 14, 12, 13};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
Servo lock;
LiquidCrystal_I2C lcd(0x27, 16, 2);
String password = "1234";
String entered = "";
void askForCode()
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Enter PIN:");
entered = "";
}
void setup()
{
lock.attach(23);
lock.write(0);
lcd.init();
lcd.backlight();
askForCode();
}
void loop()
{
char key = keypad.getKey();
if (key == NO_KEY)
{
return;
}
if (key == '*')
{
askForCode();
return;
}
if (key == '#')
{
lcd.clear();
lcd.setCursor(0, 0);
if (entered == password)
{
lcd.print("ACCESS GRANTED");
lock.write(90);
delay(3000);
lock.write(0);
}
else
{
lcd.print("WRONG PIN");
delay(2000);
}
askForCode();
return;
}
entered = entered + key;
lcd.setCursor(0, 1);
for (int i = 0; i < entered.length(); i++)
{
lcd.print("*");
}
}
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 the small contrast pot on the back of the I2C board. If still blank, change 0x27 in the sketch to 0x3F.
A servo can pull more current than USB gives when it starts. Keep the servo wires short and avoid moving it under load.
Lay the keypad face up: the eight pins run left to right as row 1 to 4, then column 1 to 4, in the order of the table.
A matrix keypad has sixteen buttons but only eight wires. The library drives one row LOW at a time and reads all four columns, where a LOW appears, that button is down. This is keypad matrix scanning, the same trick the LED matrix used in reverse. Each key press is added to a String; pressing # compares that String with the stored password, and * clears it so a mistake can be retyped.
LCD shows Enter PIN:. Each key press adds a * on the second line. Press # after 1234: ACCESS GRANTED and the servo turns for 3 seconds.
Yes. It is project 26 of 120 in the Geekobot Titan Kit, in level 6 (Security and access). 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.
7 parts: ESP32-WROOM-32 38-Pin Development Board, USB Cable, Dupont Jumper Wires (40 pcs), LCD1602 16x2 Character LCD Display, TowerPro SG90 9g Micro Servo (180°), Membrane Matrix Keypad 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 6 steps.
No. This page has the complete, tested code (titan_kit_026_password_door_lock.ino).
About ₹923 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Keypad matrix scanning; String comparison for authentication; Masking an entry with * characters; Using * and # as control keys.
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.