LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsPotentiometric displacement sensors are long precision potentiometers with a rod. The SOP KTR2-R-50 has a 5 kΩ track over 50 mm and a spring that keeps the tip pressed on the part you measure. With 5 V across the ends, the wiper voltage is proportional to position, so the Nano's ADC converts it straight to millimetres. Use it to check press strokes, door gaps, spring travel or how far a part moves.
Keep fingers clear of presses and moving machines; fit the sensor only when they are stopped.
Tick anything you already have and the total updates.
SOP KTR2-R-50 spring-return displacement sensor
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB from a computer or charger.
stroke_gauge.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 FULL_MM = 50.0;
float zero = 0;
float readMm() {
long sum = 0;
for (int i = 0; i < 64; i++) sum += analogRead(A0);
return sum / 64.0 / 1023.0 * FULL_MM;
}
void setup() { pinMode(2, INPUT_PULLUP); oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); }
void loop() {
float mm = readMm();
if (digitalRead(2) == LOW) { zero = mm; delay(300); }
big("Displacement", mm - zero, 1, "mm");
delay(100);
}
Swap the two track-end wires.
Do not use the last half millimetre of travel; mount so it works mid-range.
Average more samples, or power the sensor from a clean 5 V reference.
Linearity is typically about 0.05-0.1 % of full scale; the Nano's 10-bit ADC limits resolution to about 0.05 mm.
The sensor accepts higher voltages, but the Nano input must stay below 5 V; keep 5 V excitation.
Yes, print readings to the serial monitor or add an SD card.
6 parts: SOP KTR2-R-50 5KΩ Linear Displacement Sensor with Spring Return, 0-50mm Range, 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 6 steps.
No. This page has the complete, tested code (stroke_gauge.ino).
About ₹3,067 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
How a resistive displacement sensor works; Converting ADC counts to millimetres; Averaging readings and zeroing.
Keep fingers clear of presses and moving machines; fit the sensor only when they are 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.