LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsHall-effect flow sensors have a small turbine with a magnet; each turn gives a pulse. The YF-S402C fits G3/8 pipe and covers 0.3-10 L/min. Pulses per litre vary between batches, so you calibrate once by filling a bucket of known volume. The Nano counts pulses with an interrupt and shows flow and total on an OLED.
Keep the electronics in a waterproof box away from the hose.
Tick anything you already have and the total updates.
YF-S402C G3/8 hall-effect flow sensor
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB power bank or a 5 V adapter in a dry box.
litre_meter.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();
}
float PULSES_PER_L = 450; // set from your bucket test
volatile unsigned long pulses = 0;
unsigned long lastP = 0, lastT = 0;
float lpm = 0;
void onPulse() { pulses++; }
void setup() {
Serial.begin(9600);
pinMode(2, INPUT_PULLUP); pinMode(4, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), onPulse, FALLING);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
void loop() {
if (digitalRead(4) == LOW) { noInterrupts(); pulses = 0; interrupts(); lastP = 0; }
if (millis() - lastT >= 1000) {
noInterrupts(); unsigned long p = pulses; interrupts();
lpm = (p - lastP) / PULSES_PER_L * 60.0;
lastP = p; lastT = millis();
Serial.println(p);
big("Total litres", p / PULSES_PER_L, 1, "L");
oled.setTextSize(1); oled.setCursor(0, 56); oled.print(lpm, 1); oled.print(" L/min"); oled.display();
}
}
The arrow points against the flow, or the signal wire is on the wrong pin.
Recalibrate; pulses per litre depend on pressure and flow.
Use thread tape and do not overtighten the plastic threads.
Check the sensor's material rating; many are not rated for potable water.
About 0.3 L/min; drip lines may be below that.
Yes, add a 12 V solenoid valve and close it at a set total.
6 parts: Generic YF-S402C Water Flow Sensor Flowmeter G3/8 0.3-10L/min 5-18V, Generic Nano CH340 Development Board (Soldered), 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 beginner project and takes about 2 hours. The build on this page has 5 steps.
No. This page has the complete, tested code (litre_meter.ino).
About ₹727 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Hall-effect flow sensors; Counting pulses with interrupts; Calibrating with a measured volume.
Keep the electronics in a waterproof box away from the hose.
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.