LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsMaxBotix WR sensors are sealed for outdoor use and filter out noise, so they work well in dusty, wet places like bins and silos. The MB7040 I2CXL-MaxSonar-WR talks I2C: write the range command 0x51 to address 0x70, wait about 100 ms, then read two bytes of distance in centimetres. The ESP32 turns distance into a fill percentage and shows it on an OLED; you can post it to a server too.
Tick anything you already have and the total updates.
MaxBotix MB7040 I2CXL-MaxSonar-WR
Follow the colours: red is power, dark grey is ground, blue is a signal.
5 V USB supply or a power bank in a weatherproof box.
bin_level.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();
}
#include <Wire.h>
const int ADDR = 0x70, EMPTY_CM = 90, FULL_CM = 20;
int rangeCm() {
Wire.beginTransmission(ADDR); Wire.write(0x51); Wire.endTransmission();
delay(100);
Wire.requestFrom(ADDR, 2);
if (Wire.available() < 2) return -1;
return (Wire.read() << 8) | Wire.read();
}
void setup() { Wire.begin(); oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); }
void loop() {
int cm = rangeCm();
if (cm > 0) {
float pct = constrain(100.0 * (EMPTY_CM - cm) / (EMPTY_CM - FULL_CM), 0, 100);
big("Bin full", pct, 0, "%");
}
delay(1000);
}
Run an I2C scanner; the default address is 0x70 (224 in 8-bit form).
Mount it in the centre and keep the beam clear of the sides.
That is the sensor's minimum range; anything closer reads as the minimum.
WR models are IP67 when mounted with their thread sealed.
Yes, put the ESP32 in deep sleep and wake it every 15 minutes.
Yes, the same code works; set EMPTY_CM and FULL_CM for the tank.
5 parts: MaxBotix MB7040-100 I2CXL-MaxSonar-WR Ultrasonic Sensor – I2C Interface, 3/4″ NPS WR Housing, ESP32-WROOM-32 38-Pin Development Board, 0.96" OLED Display 128x64, 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 5 steps.
No. This page has the complete, tested code (bin_level.ino).
About ₹7,624 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
I2C range commands on MaxBotix sensors; Mapping distance to fill percentage; Mounting ultrasonic sensors in containers.
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.