LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsA through-beam sensor has a separate emitter and receiver facing each other. Anything that passes between them blocks the beam, so it is very reliable even for small or shiny parts. The M4 FTD-04NO pair runs on 12 V and has an NPN output that pulls the signal to ground when the beam is clear (normally open logic). The Nano counts each beam break and sounds a buzzer when the batch is complete.
Laser class is low, but do not stare into the emitter.
Tick anything you already have and the total updates.
M4 FTD-04NO laser through-beam sensor pair
Follow the colours: red is power, dark grey is ground, blue is a signal.
12 V adapter for the sensors; the Nano from VIN.
part_counter.inoVerify & upload in Electrolark#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const int SENSOR = 2, RESET_BTN = 3, BEEP = 5;
const long BATCH = 100;
volatile long count = 0;
volatile unsigned long lastHit = 0;
void hit() {
unsigned long now = micros();
if (now - lastHit > 3000) { count++; lastHit = now; } // ignore edges within 3 ms
}
void setup() {
pinMode(SENSOR, INPUT_PULLUP);
pinMode(RESET_BTN, INPUT_PULLUP);
pinMode(BEEP, OUTPUT);
attachInterrupt(digitalPinToInterrupt(SENSOR), hit, RISING); // beam broken = output released
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.setTextColor(WHITE);
}
void loop() {
if (digitalRead(RESET_BTN) == LOW) count = 0;
long c = count;
oled.clearDisplay();
oled.setTextSize(3); oled.setCursor(0, 10); oled.print(c);
oled.setTextSize(1); oled.setCursor(0, 52); oled.print("Batch "); oled.print(c % BATCH); oled.print("/"); oled.print(BATCH);
oled.display();
static long lastBatch = 0;
if (c / BATCH > lastBatch) { lastBatch = c / BATCH; tone(BEEP, 2000, 600); }
delay(50);
}
Long parts give a bouncy edge; increase the 3 ms ignore time.
The beam is misaligned or the edge is the other way; try FALLING.
Sunlight on the receiver; shade it with a short tube.
It works with any colour or shine and at longer distance than reflective sensors.
Yes, an NPN output only pulls to ground; the Nano's own pull-up gives the 5 V level.
Hundreds of parts per second with the interrupt; the chute is the limit.
8 parts: Generic M4 FTD-04NO 50mm Laser Micro Diffuse Photoelectric Switch – Stainless Steel Housing, Generic Nano CH340 Development Board (Soldered), 0.96" OLED Display 128x64, Buzzer Module 3.3–5V, Tactile Push Button Switch, DC Power Adapter (5.5x2.1mm), 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 intermediate project and takes about 2 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (part_counter.ino).
About ₹1,723 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Through-beam versus reflective sensors; Reading an NPN industrial sensor on 5 V; Debouncing fast pulses.
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.