LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsThe MG811 is an older solid-electrolyte CO2 sensor: its heated cell gives a voltage that falls as CO2 rises, with a strong change between about 350 and 10,000 ppm. The module amplifies the cell and has an adjustable digital alarm output. Because each sensor differs, you record the voltage in fresh outdoor air (about 420 ppm) and the sketch shows the change from it as a trend. A falling CO2 level in a closed greenhouse at noon is a sign to vent.
Keep the 12 V supply dry in a greenhouse; use a sealed box.
Tick anything you already have and the total updates.
MG811 CO2 sensor module
Follow the colours: red is power, dark grey is ground, blue is a signal.
12 V adapter through a 5 V buck converter.
mg811.inoVerify & upload in Electrolark#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
#include <EEPROM.h>
float refV;
float volts() { long s = 0; for (int i = 0; i < 32; i++) s += analogRead(A0); return s / 32.0 * 5.0 / 1023; }
void setup() {
pinMode(3, INPUT_PULLUP); pinMode(8, OUTPUT);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.setTextColor(WHITE);
EEPROM.get(0, refV);
if (isnan(refV) || refV <= 0 || refV > 5) refV = 0;
}
void loop() {
float v = volts();
if (digitalRead(3) == LOW) { refV = v; EEPROM.put(0, refV); }
float diff = v - refV; // MG811 voltage RISES when CO2 FALLS
oled.clearDisplay(); oled.setTextSize(1); oled.setCursor(0, 0);
oled.print("Ref "); oled.print(refV, 3); oled.print(" V");
oled.setTextSize(2); oled.setCursor(0, 20); oled.print(v, 3); oled.print(" V");
oled.setTextSize(1); oled.setCursor(0, 50);
if (refV == 0) oled.print("Store fresh-air ref");
else if (diff > 0.010) oled.print("CO2 LOW: open vents");
else if (diff < -0.040) oled.print("CO2 high: ventilate");
else oled.print("Near outdoor level");
digitalWrite(8, refV > 0 && diff > 0.010 && (millis() / 600) % 2);
oled.display();
delay(1000);
}
Normal for a new sensor; give it a full day of burn-in.
The heater is not warm or the supply is weak; measure 5 V at the module under load.
Each sensor's swing is different; watch a day's readings and set the two limits from them.
NDIR is more accurate; the MG811 is a classic sensor that shows the trend for less.
Yes, closed greenhouses on bright days can fall well below outdoor levels.
Yes, drive a relay or a linear actuator at the low level.
8 parts: MG811 CO2 Carbon Dioxide Gas Sensor Module – Analog & Digital Output, Generic Nano CH340 Development Board (Soldered), 0.96" OLED Display 128x64, Buzzer Module 3.3–5V, Step-Down Converter to 5V USB / 5V 3A, DC Power Adapter (5.5x2.1mm), 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 (mg811.ino).
About ₹2,969 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Solid electrolyte CO2 cells; Recording a fresh-air reference; Why greenhouses run short of CO2.
Keep the 12 V supply dry in a greenhouse; use a sealed box.
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.