Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use MG811: Examples, Pinouts, and Specs

Image of MG811Design with MG811 in Cirkit Designer

Introduction

The MG811 is a carbon dioxide (CO2) sensor manufactured by Arduino with the part ID CO2. It utilizes non-dispersive infrared (NDIR) technology to detect CO2 levels in the air. The sensor outputs an analog voltage that is proportional to the concentration of CO2, making it ideal for applications requiring accurate and reliable CO2 measurements.

Explore Projects Built with MG811

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of WiFi-Controlled Basket-Carrying Robot with GPS and GSM Notification: A project utilizing MG811 in a practical application
WiFi-Controlled Basket-Carrying Robot with GPS and GSM Notification

This circuit is designed for a 4-wheeled WiFi-controlled car with a basket, which uses an ESP8266 NodeMCU microcontroller for logic control. It features an IR sensor for basket full detection, a GPS module for location tracking, and a GSM module (Sim800l) for sending SMS notifications. The L298N motor driver controls four DC gearmotors for movement, and the system is powered by a Li-ion battery with a 7805 voltage regulator providing stable power to the GSM module.

Open Project in Cirkit Designer
Image of ESP32-Based Accident Detection and GPS Tracking System with GSM Notifications: A project utilizing MG811 in a practical application
ESP32-Based Accident Detection and GPS Tracking System with GSM Notifications

This circuit features an ESP32 microcontroller interfaced with an MPU6050 accelerometer/gyroscope, a Neo 6M GPS module, and a SIM800L GSM module. The ESP32 communicates with the MPU6050 via I2C (SCL and SDA lines) to detect potential accidents based on acceleration thresholds, with the GPS module providing location data via a serial connection (RX0 and TX0). The SIM800L GSM module is connected to the ESP32 through another serial interface (RX2 and TX2) to send SMS alerts with location information in case of an accident detection.

Open Project in Cirkit Designer

Common Applications

Technical Specifications

The MG811 sensor is designed to provide high sensitivity and stability for CO2 detection. Below are its key technical details:

Parameter Value
Operating Voltage 6V DC
Output Signal Analog voltage (proportional to CO2 concentration)
CO2 Detection Range 350 ppm to 10,000 ppm
Preheating Time 24 hours (recommended for stable readings)
Operating Temperature -20°C to 50°C
Operating Humidity 0% to 95% RH (non-condensing)
Power Consumption ~200 mA
Sensor Type NDIR (Non-Dispersive Infrared)

Pin Configuration

The MG811 sensor module typically comes with a 4-pin interface. Below is the pin configuration:

Pin Name Description
1 VCC Power supply input (6V DC)
2 GND Ground connection
3 AOUT Analog output voltage (proportional to CO2 level)
4 DOUT Digital output (high/low signal based on threshold)

Usage Instructions

Connecting the MG811 to a Circuit

  1. Power Supply: Connect the VCC pin to a 6V DC power source and the GND pin to ground.
  2. Analog Output: Connect the AOUT pin to an analog input pin of your microcontroller (e.g., Arduino UNO) to read the CO2 concentration as an analog voltage.
  3. Digital Output: Optionally, connect the DOUT pin to a digital input pin of your microcontroller to detect whether the CO2 level exceeds a preset threshold.

Important Considerations

Example Code for Arduino UNO

Below is an example of how to interface the MG811 sensor with an Arduino UNO to read the analog output and display the CO2 concentration:

// Define the analog pin connected to the MG811 AOUT pin
const int analogPin = A0;

// Variable to store the analog reading
int sensorValue = 0;

void setup() {
  // Initialize serial communication for debugging
  Serial.begin(9600);
  Serial.println("MG811 CO2 Sensor Test");
}

void loop() {
  // Read the analog value from the sensor
  sensorValue = analogRead(analogPin);

  // Convert the analog value to a voltage (assuming 5V reference)
  float voltage = sensorValue * (5.0 / 1023.0);

  // Display the raw sensor value and voltage
  Serial.print("Raw Sensor Value: ");
  Serial.print(sensorValue);
  Serial.print(" | Voltage: ");
  Serial.print(voltage);
  Serial.println(" V");

  // Add your calibration formula here to convert voltage to CO2 concentration
  // Example: float co2Concentration = (voltage - offset) * scaleFactor;

  delay(1000); // Wait for 1 second before the next reading
}

Notes on Calibration

Troubleshooting and FAQs

Common Issues

  1. No Output Signal

    • Cause: Incorrect wiring or insufficient power supply.
    • Solution: Verify the connections and ensure a stable 6V DC power source.
  2. Unstable Readings

    • Cause: Insufficient preheating time or environmental interference.
    • Solution: Allow the sensor to preheat for at least 24 hours and ensure proper ventilation.
  3. Inaccurate CO2 Measurements

    • Cause: Lack of calibration or incorrect reference voltage.
    • Solution: Calibrate the sensor in a known CO2 concentration environment and verify the reference voltage.
  4. High Power Consumption

    • Cause: The MG811 sensor's internal heating element.
    • Solution: Ensure your power supply can handle the sensor's ~200 mA current draw.

FAQs

Q: Can the MG811 sensor detect gases other than CO2?
A: No, the MG811 is specifically designed for CO2 detection using NDIR technology. It is not suitable for detecting other gases.

Q: How long does the MG811 sensor last?
A: The sensor has a long lifespan if used under recommended conditions. However, periodic calibration is necessary to maintain accuracy.

Q: Can I use the MG811 with a 5V power supply?
A: No, the MG811 requires a 6V DC power supply for proper operation. Using a lower voltage may result in inaccurate readings or sensor malfunction.

Q: Is the MG811 suitable for outdoor use?
A: The MG811 can be used outdoors, but it must be protected from extreme weather conditions and condensation to ensure reliable performance.