Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Sensors
  4. ›MG811 and MG812 Solid Electrolyte CO2 Sensors

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

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerWhat the MG811 and MG812 CO2 sensors isMG811 and MG812 CO2 sensors pinoutWiring the MG811 and MG812 CO2 sensorsExample codeSetup and tuningWhat you needAlternatives and when to choose themCommon mistakesFAQsParts and next steps
Short answer

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.

  • Option 1MG811 CO2 Carbon Dioxide Gas Sensor Module – Analog & Digital Output₹2,299
  • Option 2DFRobot Gravity Analog CO2 Sensor MG811 for Arduino – Module Only₹5,989
  • Option 3Winsen MG812 Mini Solid Electrolyte CO2 Gas Sensor – Metal Shell₹1,009
01

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.

02

MG811 and MG812 CO2 sensors pinout

The pins on the MG811 and MG812 CO2 sensors and what each one does.

PinFunction
VCC5 V (module)
GNDGround
AOAmplified analog output
DOThreshold output
PinFunction
VCC
5 V (module)
GND
Ground
AO
Amplified analog output
DO
Threshold output
03

Wiring the MG811 and MG812 CO2 sensors

Connect the MG811 and MG812 CO2 sensors like this.

MG811 and MG812 CO2 sensors pinArduino UnoESP32
VCC5 V5 V (VIN)
GNDGNDGND
AOA0GPIO 34 via divider
DOD2GPIO 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
04

Example code

A minimal sketch to check the part works.

Convert the DFRobot MG811 output to ppm · Arduino C++Verify & upload in Electrolark
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);
}
05

Setup and tuning

Heater

feed 6 V to the heater (about 200 mA); modules include the supply circuit.

Output

the sensor voltage falls as CO2 rises; read the amplified module output.

Warm-up

allow at least 24 hours on first use and some minutes each start.

Calibration

calibrate in fresh air (about 420 ppm) and use the datasheet curve.

Accuracy

for reliable ppm values, use an NDIR sensor like MH-Z19 or SCD40.

06

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
07

Alternatives and when to choose them

  • ✓CO2 NDIR sensors: more accurate and stable.
  • ✓MH-Z19 sensor: low-cost NDIR.
  • ✓SCD4x: small photoacoustic CO2.
08

Common mistakes to avoid

  • !Reading before warm-up.
  • !Expecting NDIR accuracy.
  • !Underpowering the heater.
  • !Skipping calibration.
09

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

  • MG811 CO2 Carbon Dioxide Gas Sensor Module – Analog & Digital Output
    ₹2,299View
  • DFRobot Gravity Analog CO2 Sensor MG811 for Arduino – Module Only
    ₹5,989View
  • Winsen MG812 Mini Solid Electrolyte CO2 Gas Sensor – Metal Shell
    ₹1,009View
  • Uno R3 Development Board (No Cable)
    ₹359View
  • ESP32-WROOM-32 38-Pin Development Board
    ₹389View
  • MH-Z19C Infrared Carbon Dioxide Sensor Module with 7-Pin JST Cable – UART/PWM Output
    ₹2,999View
  • 0.96" OLED Display 128x64
    ₹139View
Shop Gas, Air Quality & CO2 Sensors

Keep learning

ComparisonIntermediateCO2 SensorsCO2 sensors tell you when a room needs fresh air: outdoors is about 420 ppm, under 1000 ppm indoors is good and above 1500 ppm calls for ventilation.3 min read · SensorsComponent guideIntermediateMH-Z19 CO2 SensorThe MH-Z19 from Winsen is an NDIR (infrared) CO2 sensor that measures real carbon dioxide from 400 to 5,000 ppm.3 min read · SensorsComponent guideIntermediateSCD40 and SCD41 CO2 SensorsThe SCD40 and SCD41 from Sensirion are small CO2 sensors that measure real carbon dioxide with photoacoustic NDIR, plus temperature and humidity.3 min read · Sensors

Sources

  • Hanwei MG811 datasheet
  • DFRobot SEN0159 wiki

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWhat the MG811 and MG812 CO2 sensors isMG811 and MG812 CO2 sensors pinoutWiring the MG811 and MG812 CO2 sensorsExample codeSetup and tuningWhat you needAlternatives and when to choose themCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide (Arduino Uno)2 items · ₹2,503

MG811 CO2 Carbon Dioxide Gas Sensor Module – Analog & Digital Output · Uno R3 CH340G ATmega328p Compatible Development Board

Run itChange the inputs and watch the output

MG811 output falls as CO2 rises, through an x8.5 amplifier. Calibrate V400 in fresh air after a 48 h burn-in.

Serial monitor115200 baud
889 ppm

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question