LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsTwo kinds of pressure sensor cover most water jobs. A threaded 0 to 10 bar transducer screws into a pipe and gives 0.5 to 4.5 V, so an Arduino reads it on an analog pin. An HX710B air-pressure module reads up to 40 kPa through a thin tube dipped to the bottom of a tank: every 10 cm of water adds about 0.98 kPa, so the pressure tells you the depth. Both values show on a small OLED screen and the serial monitor.
Release the pressure before you open any pipe fitting.
Keep the electronics above the tank, in a closed box, away from splashes.
Tick anything you already have and the total updates.
Reads both sensors and drives the screen
0 to 10 bar threaded pipe transducer, 5 V in, 0.5-4.5 V out
0 to 40 kPa air-pressure module for the tank tube
Bare HX710B interposer if you want to design your own board
Membrane position strip: a float on a slider gives a level reading without any tube
Follow the colours: red is power, dark grey is ground, blue is a signal.
pressure_level.inoVerify & upload in Electrolark#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const int PIPE = A0, HX_OUT = 2, HX_SCK = 3;
const float FULL_BAR = 10.0; // transducer range
long RAW_EMPTY = 0; // raw HX710B value with the tube out of the water
long RAW_KNOWN = 1000000; // raw value at KNOWN_CM depth
const float KNOWN_CM = 50.0;
long readHX710B() {
while (digitalRead(HX_OUT) == HIGH) ; // wait until data is ready
long v = 0;
for (int i = 0; i < 24; i++) {
digitalWrite(HX_SCK, HIGH); delayMicroseconds(1);
v = (v << 1) | digitalRead(HX_OUT);
digitalWrite(HX_SCK, LOW); delayMicroseconds(1);
}
digitalWrite(HX_SCK, HIGH); delayMicroseconds(1); // 25th pulse: differential input, 10 Hz
digitalWrite(HX_SCK, LOW);
if (v & 0x800000) v |= 0xFF000000; // sign-extend 24 bits
return v;
}
void setup() {
Serial.begin(115200);
pinMode(HX_OUT, INPUT); pinMode(HX_SCK, OUTPUT);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
void loop() {
float v = analogRead(PIPE) * 5.0 / 1023.0;
float bar = (v - 0.5) / 4.0 * FULL_BAR;
if (bar < 0) bar = 0;
long raw = 0;
for (int i = 0; i < 8; i++) raw += readHX710B();
raw /= 8;
float cm = (raw - RAW_EMPTY) * KNOWN_CM / (float)(RAW_KNOWN - RAW_EMPTY);
Serial.print("raw "); Serial.print(raw); Serial.print(" bar "); Serial.print(bar, 2);
Serial.print(" level cm "); Serial.println(cm, 1);
oled.clearDisplay(); oled.setTextColor(WHITE);
oled.setTextSize(1); oled.setCursor(0, 0); oled.print("Pipe pressure");
oled.setTextSize(2); oled.setCursor(0, 12); oled.print(bar, 2); oled.print(" bar");
oled.setTextSize(1); oled.setCursor(0, 36); oled.print("Tank level");
oled.setTextSize(2); oled.setCursor(0, 48); oled.print(cm, 0); oled.print(" cm");
oled.display();
delay(500);
}
The sketch above runs here on a simulated Arduino Uno. Move the sliders for the sensors and buttons it reads, and watch the Serial monitor, display and outputs change.
Check that the output wire is on A0 and that the line is really under pressure. A reading of about 0.1 V means the output wire is open.
Air slowly dissolves or leaks from the tube. Lift the tube out once a day to refill it with air, or seal the joint at the sensor.
Swap the two calibration values, or use the other nozzle on the module.
40 kPa is roughly 4 m of water, which covers most overhead and sump tanks.
Yes, with a 250 ohm resistor it gives 1-5 V; see the Modbus project for industrial sensors.
Check the wetted material on the product page; many low-cost transducers are not certified for potable water.
8 parts: Uno R3 CH340G ATmega328p Compatible Development Board, Ascenta MM818 Pressure Sensor Module 0-10 bar Gauge – 5V Input, 0.5-4.5V Output, HX710B Air Pressure Sensor Module (0–40KPa) with Straight Pin Header, 0.96" OLED Display 128x64, Generic HX710B Pressure Sensor Module Interposer – 0-40 kPa, 3.3V/5V, SOP-16, Tekscan FlexiForce FlexiPot Strip Position Sensor – 3-Pin Male Connector, 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 to 3 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (pressure_level.ino).
Yes. The Run it panel under the code runs this exact sketch on a simulated board. Move the sliders or press the buttons for the sensors it reads, and the Serial monitor, display and outputs react as they will on the real build. It is a simulation, so real readings depend on your parts and wiring.
About ₹3,716 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Converting a 0.5-4.5 V ratiometric signal to bar; Reading a 24-bit HX710B by bit-banging; Two-point calibration of a level reading.
Ideas that reuse this build: ESP32 Modbus RS485 sensor reader. 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.
raw 0 bar 2.49 level cm 0.0 raw 0 bar 2.49 level cm 0.0 raw 0 bar 2.50 level cm 0.0 raw 0 bar 2.50 level cm 0.0 raw 0 bar 2.51 level cm 0.0 raw 0 bar 2.49 level cm 0.0
A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.