Component guide · Intermediate · 3 min read
MG811 and MG812 Solid Electrolyte CO2 Sensors and DFRobot Gravity MG811 Module

By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The MG811 is a solid electrolyte CO2 sensor whose output voltage falls as CO2 rises, roughly 30 to 50 mV per decade of concentration. It needs a 6 V heater and a high-impedance amplifier, which the modules provide. It covers about 350 to 10,000 ppm. The MG812 is a smaller version. For accurate indoor CO2, an NDIR sensor is usually the better choice.
Key specs at a glance
- Heater
- 6 V, about 200 mA (modules run from 5 to 6 V)
- Range
- About 350 to 10,000 ppm
- Output
- EMF falls about 30 to 50 mV per decade; module amplifies it
- Warm-up
- Several minutes; 48 hours burn-in
- Impedance
- Very high; needs an op-amp buffer
- Accuracy
- Low; needs calibration
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
What the MG811 and MG812 CO2 sensors is
The MG811 and MG812 are electrochemical CO2 sensors with a heater, used on analog modules for basic CO2 detection, though less accurate than NDIR sensors.
Calibrate at 400 ppm outdoors, then use the log curve from the datasheet. Recalibrate often because the zero drifts.
The DFRobot Gravity module includes a boost converter for the heater and the amplifier.
MG811 and MG812 CO2 sensors pinout
The pins on the MG811 and MG812 CO2 sensors and what each one does.
| Pin | Function |
|---|---|
| VCC | 5 V (module) |
| GND | Ground |
| AO | Amplified analog output |
| DO | Threshold output |
- VCC
- 5 V (module)
- GND
- Ground
- AO
- Amplified analog output
- DO
- Threshold output
Wiring the MG811 and MG812 CO2 sensors
Connect the MG811 and MG812 CO2 sensors like this.
| MG811 and MG812 CO2 sensors pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5 V | 5 V (VIN) |
| GND | GND | GND |
| AO | A0 | GPIO 34 via divider |
| DO | D2 | GPIO 27 |
- VCC
- Arduino Uno:
- 5 V
- ESP32:
- 5 V (VIN)
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- AO
- Arduino Uno:
- A0
- ESP32:
- GPIO 34 via divider
- DO
- Arduino Uno:
- D2
- ESP32:
- GPIO 27
Example code
A minimal sketch to check the part works.
const float V400 = 0.324; // module output at 400 ppm, measured by you
const float DV = 0.020; // voltage drop from 400 to 1000 ppm, from calibration
void setup() { Serial.begin(115200); }
void loop() {
float v = analogRead(A0) * 5.0 / 1023.0 / 8.5; // DFRobot module gain is about 8.5
float slope = DV / (log10(400) - log10(1000));
float ppm = pow(10, (v - V400) / slope + log10(400));
Serial.print(ppm, 0); Serial.println(" ppm");
delay(1000);
}Setup and tuning
feed 6 V to the heater (about 200 mA); modules include the supply circuit.
the sensor voltage falls as CO2 rises; read the amplified module output.
allow at least 24 hours on first use and some minutes each start.
calibrate in fresh air (about 420 ppm) and use the datasheet curve.
for reliable ppm values, use an NDIR sensor like MH-Z19 or SCD40.
What you need
Shop this list6 of 7 found in our store · ₹12,637
MG811 CO2 Carbon Dioxide Gas Sensor Module – Analog & Digital Output: the part this guide coversMG811 CO2 Carbon Dioxide Gas Sensor Module – Analog & Digital Output₹2,299
DFRobot Gravity Analog CO2 Sensor MG811 for Arduino – Module Only: another version this guide coversDFRobot Gravity Analog CO2 Sensor MG811 for Arduino – Module Only₹5,989
Winsen MG812 Mini Solid Electrolyte CO2 Gas Sensor – Metal Shell: another version this guide coversWinsen MG812 Mini Solid Electrolyte CO2 Gas Sensor – Metal Shell₹1,009- Uno R3 development board: the controller used in the wiring tableFind this part
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
MH-Z19C NDIR CO2 sensor: the popular low-cost NDIR CO2 sensorWinsen MH-Z19C NDIR CO2 Sensor HVAC/IAQ – UART/PWM Output₹2,812Closest match, check the specs
0.96 inch OLED display 128x64: to show readings without a computer0.96" OLED Display 128x64₹139Closest match, check the specs
Alternatives and when to choose them
- CO2 NDIR sensors: more accurate and stable.
- MH-Z19 sensor: low-cost NDIR.
- SCD4x: small photoacoustic CO2.
Common mistakes to avoid
- Reading before warm-up.
- Expecting NDIR accuracy.
- Underpowering the heater.
- Skipping calibration.
Frequently asked questions
Is the MG811 accurate for CO2?
Only roughly. NDIR sensors such as the MH-Z19 or SCD40 are far more accurate.
Why does the output fall when CO2 rises?
That is how the MG811 works: its output voltage drops as CO2 rises.
How long does the MG811 need to warm up?
Burn in for a day, then a few minutes each start.
Can I power it from USB?
The heater needs 6 V; use the module's supply.
Should I use MG811 or MH-Z19?
Choose the MH-Z19 NDIR sensor for accurate ppm, and the MG811 only for learning.
Parts for this guide
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.


