LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsBarcode scanner modules such as the GM65 read 1D barcodes and QR codes and send each code as plain text over a serial line, followed by a carriage return. An Arduino listens on a software serial pin, looks the code up in a small table, and adds or removes one from its stock depending on an IN/OUT switch. A beep confirms each scan and the LCD shows the item and its new count.
Do not look into the scanner's light or aiming LED from close up.
Tick anything you already have and the total updates.
Receives the codes and keeps the counts
GM65 1D/2D scanner module with a UART output
GM65-S, a similar scanner module
M5Stack ATOM QR scanner kit, a ready unit with its own ESP32
Follow the colours: red is power, dark grey is ground, blue is a signal.
stock_counter.inoVerify & upload in Electrolark#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
SoftwareSerial scanner(2, 3); // RX on D2 (scanner TX); D3 is not connected
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int MODE_SW = 4, BUZZ = 8;
struct Item { const char* code; const char* name; int stock; };
Item ITEMS[] = {
{"8901234567890", "Glue stick", 0},
{"8909876543210", "AA cells", 0},
{"SHELF-A-RESISTORS", "Resistor kit", 0}, // QR codes can hold any text
};
const int N_ITEMS = sizeof(ITEMS) / sizeof(ITEMS[0]);
char buf[64];
int len = 0;
void beep(int ms) { digitalWrite(BUZZ, HIGH); delay(ms); digitalWrite(BUZZ, LOW); }
void handle(const char* code) {
bool in = digitalRead(MODE_SW) == HIGH; // switch open = IN, closed = OUT
Serial.println(code);
lcd.clear();
for (int i = 0; i < N_ITEMS; i++) {
if (strcmp(code, ITEMS[i].code) == 0) {
ITEMS[i].stock += in ? 1 : -1;
lcd.print(ITEMS[i].name);
lcd.setCursor(0, 1); lcd.print(in ? "IN " : "OUT "); lcd.print("stock "); lcd.print(ITEMS[i].stock);
beep(60);
return;
}
}
lcd.print("Unknown code");
lcd.setCursor(0, 1); lcd.print(String(code).substring(0, 16));
beep(400);
}
void setup() {
Serial.begin(115200);
scanner.begin(9600); // the module's serial speed
pinMode(MODE_SW, INPUT_PULLUP);
pinMode(BUZZ, OUTPUT);
lcd.init(); lcd.backlight();
lcd.print("Ready to scan");
}
void loop() {
while (scanner.available()) {
char c = scanner.read();
if (c == '\r' || c == '\n') {
if (len > 0) { buf[len] = 0; handle(buf); len = 0; }
} else if (len < (int)sizeof(buf) - 1) {
buf[len++] = c;
}
}
}
The module is still in USB mode or at another baud rate. Scan the serial output and 9600 baud setting codes again from its manual.
The module is not sending an end-of-line. Scan the 'add CR' or 'add suffix' setting code in its manual.
In manual mode it scans only while the trigger is pressed. Scan the continuous or sense mode code, or wire its trigger pin as the manual shows.
A 2D module such as the GM65 reads QR codes; the whole text inside (for a UPI code, the payment link) arrives as one line.
Not in this sketch. Save each count to EEPROM after a scan, or log to an SD card, to keep them.
Most modules also work as a USB keyboard: set them to USB mode and they type each code into a spreadsheet.
An Uno has 2 KB of RAM, enough for a few dozen short codes. For more, keep the table in flash with PROGMEM or use an ESP32.
9 parts: Uno R3 CH340G ATmega328p Compatible Development Board, Grow GM65 1D/2D Barcode Scanner Module – USB & UART Interface, 16×2 LCD with I2C (RG1602A), Buzzer Module 3.3–5V, Miniature Toggle Switch, Grow GM65-S Barcode Scanner Module – UART/USB Interface, 0.10mm Resolution, M5Stack ATOM QR-CODE 2D/1D Barcode Scanner Module Kit w/ M5Atom Lite – UART/TTL, 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.
About ₹11,139 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Reading a UART device with SoftwareSerial; Collecting a line of text until the end-of-line character; Keeping a small lookup table of codes and counts.
Do not look into the scanner's light or aiming LED from close up.
Ideas that reuse this build: RFID attendance logger. They are listed under Take it further on this page.
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.
Learning project. Check every circuit and the datasheet of each part before you power it up.