Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Notes: For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.
CO2 Sensor Arduino: NDIR vs Electrochemical Comparison Guide
Choosing the right CO2 sensor Arduino combination can make or break your air quality monitoring project. I’ve integrated both NDIR and electrochemical sensors into dozens of PCB designs over the years, and the technology differences translate directly into real-world performance gaps that matter for your application.
This guide breaks down what actually happens inside these sensors, which specifications you should care about, and when each technology makes sense from a practical design standpoint.
How CO2 Sensors Work: The Fundamentals
Before diving into comparisons, understanding the operating principles helps explain why these sensors behave so differently in the field.
NDIR (Non-Dispersive Infrared) Technology
NDIR sensors exploit the fact that CO2 molecules absorb infrared light at a specific wavelength around 4.26 micrometers. The sensor contains an infrared emitter, a sample chamber where ambient air flows through, and a detector with an optical filter tuned to that absorption band.
The relationship follows the Beer-Lambert Law: as CO2 concentration increases, more infrared light gets absorbed, and less reaches the detector. The sensor measures this attenuation and calculates CO2 concentration from the signal strength difference.
High-quality NDIR sensors like the Sensirion SCD30 use dual-channel detection with a reference wavelength unaffected by CO2. This reference compensates for LED aging, dust contamination, and temperature drift, dramatically improving long-term stability.
Electrochemical Technology
Electrochemical CO2 sensors like the MG-811 work on a completely different principle. They contain a solid electrolyte that generates a voltage proportional to CO2 concentration through an electrochemical reaction at the sensing electrode.
The output voltage decreases as CO2 concentration increases, which feels counterintuitive at first. The sensor also requires an internal heating element to maintain optimal operating temperature, typically consuming 140-200mA continuously. This heating circuit must stabilize for 48-72 hours before readings become reliable.
NDIR vs Electrochemical: Head-to-Head Specifications
Here’s where the rubber meets the road. This table summarizes the key specifications you’ll encounter when selecting a CO2 sensor Arduino module:
Parameter
NDIR Sensors
Electrochemical Sensors
Detection Range
400-5000 ppm (typical), up to 50000 ppm
350-10000 ppm
Accuracy
±30-50 ppm + 3-5% of reading
Qualitative (relative changes)
Response Time (T90)
20-120 seconds
30-90 seconds
Warm-up Time
3-10 minutes
48-72 hours
Operating Current
20-60 mA average
140-200 mA continuous
Lifespan
5-15 years
2-5 years
Cross-Sensitivity
Very low
Sensitive to temperature, humidity
Calibration Stability
Excellent (months to years)
Requires frequent recalibration
Cost
$15-60 (module)
$8-25 (module)
Best For
Quantitative IAQ monitoring
Threshold alarms, event triggers
The accuracy difference is substantial. NDIR sensors give you actual ppm readings you can trust for data logging and HVAC control. Electrochemical sensors work better for “go/no-go” threshold detection where you need to know if CO2 exceeded a certain level, not the exact concentration.
Popular CO2 Sensor Modules for Arduino Projects
Let me walk through the sensors I’ve actually used in production designs and what you can expect from each.
MH-Z19B: The Budget NDIR Workhorse
The MH-Z19B from Winsen has become the de facto standard for hobbyist and mid-range Arduino CO2 projects. It offers genuine NDIR measurement at a price point that doesn’t hurt when you’re prototyping.
Specification
Value
Range
0-2000 ppm or 0-5000 ppm (configurable)
Accuracy
±50 ppm + 5%
Interface
UART (9600 baud) or PWM
Operating Voltage
4.5-5.5V DC
Average Current
< 60 mA
Warm-up Time
3 minutes
Lifespan
> 5 years
The MH-Z19B communicates via UART with a simple 9-byte command protocol. You send a read request, and the sensor returns CO2 concentration along with temperature data. The PWM output provides an alternative interface where the duty cycle correlates to concentration.
One quirk worth noting: the ABC (Automatic Baseline Calibration) algorithm assumes the sensor sees fresh outdoor air (~400 ppm) at least once every 7.5 days. For continuously occupied spaces or indoor-only installations, you’ll want to disable ABC and calibrate manually.
Sensirion SCD30: The Professional Choice
When accuracy and long-term stability matter more than cost, the SCD30 delivers. This dual-channel NDIR sensor includes onboard temperature and humidity measurement, which it uses internally to compensate CO2 readings.
Specification
Value
Range
400-10000 ppm
Accuracy
±(30 ppm + 3%)
Interface
I2C (address 0x61) or Modbus
Operating Voltage
3.3-5.5V DC
Average Current
19 mA at 2-second interval
Warm-up Time
2 seconds for first reading
Lifespan
> 15 years
The SCD30’s dual-channel design uses a reference measurement that tracks LED intensity changes over time. This self-compensation eliminates the primary drift mechanism that plagues single-channel sensors, making it suitable for permanent installations where you can’t easily access the unit for recalibration.
SCD41: Compact Photoacoustic NDIR
Sensirion’s SCD41 represents the next generation of miniaturized CO2 sensing. At just 10.1 × 10.1 × 6.5 mm, it’s smaller than most decoupling capacitors on your PCB.
Specification
Value
Range
400-5000 ppm
Accuracy
±(40 ppm + 5%)
Interface
I2C
Operating Voltage
2.4-5.5V DC
Average Current
< 4 mA (single-shot mode)
Warm-up Time
< 1 second
Form Factor
SMD, 10.1 × 10.1 × 6.5 mm
The photoacoustic measurement technique allows this dramatic size reduction. Instead of measuring light absorption directly, it detects the acoustic waves generated when CO2 molecules absorb pulsed infrared light and release energy as heat. Battery-powered and wearable applications finally become practical with this power profile.
MG-811: Basic Electrochemical Option
For simple threshold detection where you just need to know when CO2 gets too high, the MG-811-based modules offer a low-cost entry point.
Specification
Value
Range
350-10000 ppm
Output
Analog voltage (decreases with CO2)
Heater Current
140 mA ± 20 mA
Operating Voltage
6V (heater) + 5V (logic)
Warm-up Time
48-72 hours for stable readings
Best Use Case
Threshold alarms, relative changes
The MG-811 requires an external 6V power supply for its heater circuit, which the Arduino cannot provide directly. You’ll need a separate power rail or boost converter in your design. The module typically includes a comparator with adjustable threshold, outputting a digital signal when CO2 exceeds a preset level.
Wiring Your CO2 Sensor to Arduino
The connection scheme depends on the sensor interface. Here are the standard configurations:
MH-Z19B UART Connection
MH-Z19B Pin
Arduino Pin
Notes
VIN
5V
Requires stable 5V supply
GND
GND
Common ground
TX
D10 (RX)
Software Serial receive
RX
D11 (TX)
Software Serial transmit
PWM
D9 (optional)
Alternative PWM interface
Note the TX/RX crossover: the sensor’s TX connects to Arduino’s receive pin, and vice versa.
SCD30 I2C Connection
SCD30 Pin
Arduino Pin
Notes
VCC
3.3V or 5V
Either voltage works
GND
GND
Common ground
SDA
A4
I2C data line
SCL
A5
I2C clock line
For longer cable runs or noisy environments, add 4.7kΩ pull-up resistors on SDA and SCL lines. The sensor’s I2C address is fixed at 0x61.
Basic Arduino Code for NDIR CO2 Sensors
Here’s a working example for the MH-Z19B using the popular library:
Serial.println(“MH-Z19B CO2 Sensor Initializing…”);
delay(180000); // 3-minute warm-up period
Serial.println(“Sensor ready”);
}
void loop() {
// Send read command
mhzSerial.write(cmd_read, 9);
delay(100);
// Read response
if (mhzSerial.available() >= 9) {
for (int i = 0; i < 9; i++) {
response[i] = mhzSerial.read();
}
// Verify response header
if (response[0] == 0xFF && response[1] == 0x86) {
int co2 = (response[2] << 8) | response[3];
int temp = response[4] – 40; // Temperature offset
Serial.print(“CO2: “);
Serial.print(co2);
Serial.print(” ppm, Temp: “);
Serial.print(temp);
Serial.println(” C”);
}
}
delay(5000); // Read every 5 seconds
}
For the SCD30, the SparkFun library simplifies everything:
#include <Wire.h>
#include “SparkFun_SCD30_Arduino_Library.h”
SCD30 airSensor;
void setup() {
Serial.begin(115200);
Wire.begin();
if (!airSensor.begin()) {
Serial.println(“SCD30 not detected. Check wiring.”);
while (1);
}
// Optional: Set measurement interval (2-1800 seconds)
airSensor.setMeasurementInterval(2);
Serial.println(“SCD30 initialized”);
}
void loop() {
if (airSensor.dataAvailable()) {
Serial.print(“CO2: “);
Serial.print(airSensor.getCO2());
Serial.print(” ppm, Temp: “);
Serial.print(airSensor.getTemperature(), 1);
Serial.print(” C, Humidity: “);
Serial.print(airSensor.getHumidity(), 1);
Serial.println(” %”);
}
delay(2000);
}
Calibration Best Practices
Proper calibration separates useful data from expensive noise. Both sensor types need attention here, but the requirements differ substantially.
NDIR Sensor Calibration
Most NDIR sensors support two calibration methods:
Automatic Baseline Calibration (ABC): The sensor assumes the lowest reading over a 7-24 day period represents 400 ppm (fresh air baseline). Works well for offices and homes that get ventilated regularly.
Manual Zero-Point Calibration: Expose the sensor to a known 400 ppm environment (outdoor air or calibration gas) for 20+ minutes, then trigger the calibration command. Required for installations that never see fresh air.
Electrochemical Sensor Calibration
The MG-811 and similar electrochemical sensors need reference voltage measurements at known CO2 concentrations. You measure the analog output at 400 ppm (fresh air) and ideally at a higher concentration using calibration gas, then use these two points to create a voltage-to-ppm conversion curve.
The logarithmic relationship between voltage and concentration makes accurate calibration challenging without proper equipment. For most applications, treating the output as a relative indicator rather than an absolute measurement produces more reliable results.
Common Troubleshooting Issues
Erratic Readings from NDIR Sensors
The most frequent cause is insufficient power supply. The MH-Z19B draws transient currents up to 150 mA during the IR emission pulse. A weak USB supply or long cables cause voltage sag that corrupts measurements. Add a 100µF electrolytic capacitor across the sensor’s power pins close to the module.
Electrochemical Sensor Shows Constant Value
The heater hasn’t stabilized. These sensors genuinely need 48-72 hours of continuous operation before the electrochemical cell reaches thermal equilibrium. Don’t skip this step expecting it to work anyway.
MH-Z19B Stuck at Maximum Range
ABC calibration has drifted because the sensor never sees fresh air. Disable ABC with the appropriate command, manually calibrate at 400 ppm outdoors, then re-enable if needed.
SCD30 Readings Drift Over Weeks
The automatic self-calibration algorithm needs 7 days of continuous operation with at least 1 hour of fresh air exposure daily to converge. During this initial period, readings will wander. After convergence, the algorithm maintains accuracy indefinitely.
Which CO2 sensor is best for indoor air quality monitoring?
For quantitative IAQ monitoring where you need accurate ppm readings, NDIR sensors like the SCD30 or MH-Z19B are the only reasonable choice. The SCD30 offers better long-term stability and doesn’t require regular recalibration, making it ideal for permanent installations. The MH-Z19B works well for projects with tighter budgets where occasional drift is acceptable.
Can I use an electrochemical CO2 sensor with a 3.3V Arduino?
The sensor logic may run at 3.3V, but the heater circuit requires a separate 6V supply capable of providing 150-200 mA continuously. The heater cannot be powered from the Arduino’s voltage regulator. You’ll need an external power source and potentially a logic level shifter depending on the specific module.
Why does my MH-Z19B show 400 ppm all the time?
This typically indicates the ABC calibration has been triggered incorrectly or the sensor genuinely calibrated to an environment with elevated CO2 as its “baseline.” Disable ABC, perform a manual calibration in fresh outdoor air (actual 400 ppm), and verify the sensor responds to breath or exhaled air before re-enabling automatic calibration.
How long do CO2 sensors last before replacement?
NDIR sensors with dual-channel compensation (SCD30) can last 10-15 years under normal conditions. Single-channel NDIR sensors (MH-Z19B) typically last 5-7 years before drift becomes problematic. Electrochemical sensors degrade faster, with 2-5 years being typical depending on environmental conditions and how often the sensor is heated.
Can these sensors detect other gases besides CO2?
NDIR sensors are highly selective for CO2 due to the optical filter tuned specifically to the 4.26 µm absorption band. Cross-sensitivity to other gases is minimal. Electrochemical sensors have some cross-sensitivity to temperature and humidity changes, which can cause readings to shift even when CO2 concentration remains constant. Neither sensor type can reliably detect other gases like CO or VOCs.
Choosing the Right Sensor for Your Project
After working through all these specifications, the decision usually comes down to a few key questions:
Need accurate ppm readings? NDIR is your only option. Pick SCD30 for stability or MH-Z19B for cost.
Just need threshold detection? Electrochemical sensors work fine for triggering fans or alarms when CO2 gets “too high” without knowing the exact level.
Battery powered? The SCD41’s single-shot mode with sub-4mA average current makes extended battery operation feasible. Other sensors draw too much power for coin cell applications.
Permanent installation? Dual-channel NDIR (SCD30) eliminates calibration hassles for years at a time.
Tight budget? The MH-Z19B provides genuine NDIR measurement for under $20, making it the value leader for most hobby projects.
The CO2 sensor Arduino combination you choose should match your accuracy requirements, power budget, and willingness to deal with calibration over time. Get those fundamentals right, and your air quality monitoring project will deliver useful data instead of frustration.
Meta Description Suggestion:
“Compare NDIR vs electrochemical CO2 sensor Arduino options with specifications, wiring diagrams, and code examples. Learn which technology fits your air quality monitoring project.”
Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Notes: For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.