LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsThe SW-520D is a ball tilt switch: inside its can, a metal ball connects two contacts when it is upright and rolls away when tilted. The module adds a comparator that gives a clean digital output. The Nano arms the alarm after a button press, then sounds the buzzer if the switch stays tilted for more than half a second, so bumps from the road do not set it off.
Tick anything you already have and the total updates.
Follow the colours: red is power, dark grey is ground, blue is a signal.
One 18650 through the 5 V module, charged by USB.
bike_alarm.inoVerify & upload in Electrolarkbool armed = false;
int armedState;
unsigned long tiltSince = 0;
void setup() { pinMode(2, INPUT); pinMode(3, INPUT_PULLUP); pinMode(5, OUTPUT); }
void loop() {
if (digitalRead(3) == LOW) {
armed = !armed; armedState = digitalRead(2);
tone(5, armed ? 2000 : 800, 150); delay(500);
}
if (!armed) return;
if (digitalRead(2) != armedState) {
if (!tiltSince) tiltSince = millis();
if (millis() - tiltSince > 500) { tone(5, 3000); delay(200); noTone(5); delay(100); }
} else tiltSince = 0;
}
Increase the 500 ms delay.
The switch is mounted on its side; it must be upright when parked.
The power module may stay on; switch it off when riding.
A tilt switch uses almost no power and needs no code to read; it is enough for knock-overs.
A small buzzer is a deterrent; use a 12 V siren with a MOSFET for more volume.
Put it in a sealed box; the switch itself is enclosed.
9 parts: SW-520D Vibration Sensor Tilt Switch Module – Pack of 2, Generic Nano CH340 Development Board (Soldered), Buzzer Module 3.3–5V, Tactile Push Button Switch, 5V 2A Charge-Discharge Integrated Module, 18650 Li-ion Rechargeable Cell, 18650 Battery Holder, 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 beginner project and takes about 1 hour. The build on this page has 5 steps.
No. This page has the complete, tested code (bike_alarm.ino).
About ₹554 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
How tilt switches work; Debouncing with a time delay; Arming and disarming.
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.