LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsFactory sensors run on 12-24 V and switch an NPN or PNP transistor instead of giving a 5 V signal. The Omron E3Z-D61 is a diffuse-reflective sensor that sees objects 5-100 mm away and pulls its black output wire to 0 V when it does. With a pull-up to 5 V and a shared ground, the Nano reads it safely, counts each carton once and shows the total and rate on a TM1637 display.
The 12-24 V supply's mains side must be in a closed, earthed enclosure.
Keep hands clear of moving conveyors; mount sensors only when the line is stopped.
Tick anything you already have and the total updates.
Omron E3Z-D61 NPN photoelectric sensor
Follow the colours: red is power, dark grey is ground, blue is a signal.
12 V adapter for the sensor; the Nano can run from the same 12 V on VIN.
box_counter.inoVerify & upload in Electrolark#include <TM1637Display.h>
TM1637Display seg(4, 5);
volatile unsigned long count = 0, lastEdge = 0;
unsigned long times[10]; int tn = 0;
const unsigned long GAP_MS = 150; // ignore re-triggers within 150 ms
void onBox() {
unsigned long now = millis();
if (now - lastEdge > GAP_MS) count++;
lastEdge = now;
}
void setup() {
pinMode(2, INPUT);
pinMode(7, INPUT_PULLUP);
seg.setBrightness(5);
attachInterrupt(digitalPinToInterrupt(2), onBox, FALLING); // NPN pulls low when it sees a box
}
void loop() {
static unsigned long shown = 0, pressedAt = 0;
noInterrupts(); unsigned long c = count; interrupts();
if (c != shown) { times[tn % 10] = millis(); tn++; shown = c; }
if (digitalRead(7) == LOW) {
if (!pressedAt) pressedAt = millis();
unsigned long held = millis() - pressedAt;
if (held > 3000) { noInterrupts(); count = 0; interrupts(); shown = 0; tn = 0; }
else if (tn >= 10) {
float perMin = 9 * 60000.0 / (times[(tn - 1) % 10] - times[tn % 10]);
seg.showNumberDec((int)perMin); delay(200); return;
}
} else pressedAt = 0;
seg.showNumberDec(c % 10000);
delay(50);
}
Check the common ground between the 12 V supply and the Nano, and the pull-up to 5 V.
Raise GAP_MS or lower the sensor's sensitivity so gaps in the carton do not re-trigger.
Angle the sensor slightly so reflections do not miss it.
Yes, but it outputs +V: use a voltage divider or optocoupler down to 5 V.
That would put 12 V on the Nano pin and damage it.
Yes, drive a relay that feeds the conveyor's control input.
8 parts: Generic Nano CH340 Development Board (Soldered), Omron E3Z-D61 Photoelectric Sensor, NPN Open-Collector, 12-24 VDC, 5-100 mm Sensing, IP67, TM1637 4-Digit 7-Segment Display Module, Tactile Push Button Switch, Resistor Assortment Kit (30 Values), 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 (box_counter.ino).
About ₹1,485 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
NPN open-collector outputs on industrial sensors; Interfacing 24 V sensors to 5 V logic; Counting each object once with a debounce.
The 12-24 V supply's mains side must be in a closed, earthed enclosure. Keep hands clear of moving conveyors; mount sensors only when the line is stopped.
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.