LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsIncremental shaft encoders give a fixed number of pulses per turn on two channels (A and B) a quarter-cycle apart, so you get distance and direction. The HS-S32-L gives 600 pulses per revolution with NPN open-collector outputs, which need pull-up resistors. A wheel on the shaft turns pulses into distance: length = pulses / 600 × wheel circumference.
Tick anything you already have and the total updates.
HS-S32-L 600 PPR incremental optical encoder
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB power bank for a handheld wheel.
measuring_wheel.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();
}
const float CIRC_MM = 200.0, PPR = 600.0;
volatile long count = 0;
void onA() { count += (digitalRead(3) == digitalRead(2)) ? 1 : -1; }
void setup() {
pinMode(2, INPUT); pinMode(3, INPUT); pinMode(4, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), onA, CHANGE);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
void loop() {
if (digitalRead(4) == LOW) { noInterrupts(); count = 0; interrupts(); }
noInterrupts(); long c = count; interrupts();
float m = c / (2 * PPR) * CIRC_MM / 1000.0; // CHANGE on A gives 2 counts per pulse
big("Length", m, 3, "m");
delay(100);
}
B is not connected or has no pull-up.
Recalibrate CIRC_MM; tyres compress under pressure.
Use a larger wheel or count only rising edges.
It works with any logic voltage through the pull-up, and over longer cables.
Yes, count pulses per second to get speed.
Yes, press the wheel against the cloth as it unwinds.
7 parts: HS-S32-L Rotary Encoder 600 PPR Incremental Optical Encoder – NPN Open Collector Output, 5-24V DC, Generic Nano CH340 Development Board (Soldered), 0.96" OLED Display 128x64, Resistor Assortment Kit (30 Values), 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 intermediate project and takes about 3 hours. The build on this page has 5 steps.
No. This page has the complete, tested code (measuring_wheel.ino).
About ₹623 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Quadrature encoders and direction; Open-collector outputs and pull-ups; Calibrating with a known length.
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.