Indoor air quality has emerged as one of the most important factors in human health and productivity, yet most homes and offices have no way to measure it in real time. The ENS160 + AHT21 combination module changes that by packing a digital multi-gas sensor (ENS160) and a precision temperature/humidity sensor (AHT21) onto a single compact breakout board. Together, they give you a comprehensive picture of indoor climate — eCO2, TVOC, temperature, and relative humidity — using just one I2C connection.
This tutorial walks you through understanding the ENS160 and AHT21 individually, why combining them on one board is brilliant engineering, and how to wire and code them with Arduino and ESP32 to build a real indoor air quality monitor.
What Is the ENS160?
The ENS160 from ScioSense is a digital multi-gas sensor based on metal oxide semiconductor (MOS) technology. It houses four independently operated hotplate elements, each coated with a different sensitive material designed to detect specific gas families. The onboard AI-powered signal processing algorithm converts raw resistance readings into standardised air quality metrics.
The two primary outputs are:
- eCO2 (equivalent CO2): Estimated CO2 concentration in ppm, ranging from 400 ppm (clean outdoor air) to 65,000 ppm. Critically, this is an equivalent CO2 reading derived from TVOC — not a true NDIR CO2 measurement.
- TVOC (Total Volatile Organic Compounds): Concentration in ppb, ranging from 0 to 65,000 ppb. VOCs include ethanol, acetone, formaldehyde, toluene, and hundreds of other compounds emitted by paints, cleaning products, furniture, and human breath.
The ENS160 also provides an AQI (Air Quality Index) value from 1 (excellent) to 5 (unhealthy), providing a quick human-readable summary. Unlike the older CCS811 (which it essentially replaces), the ENS160 offers three operating modes: Ultra-Low Power, Low Power, and Standard — allowing significant power saving in battery-operated designs.
What Is the AHT21?
The AHT21 from ASAIR is a calibrated digital temperature and humidity sensor. It uses a capacitive humidity sensing element and a standard bandgap temperature circuit, with 20-bit ADC resolution. Key characteristics:
- Temperature range: −40°C to +85°C, accuracy ±0.3°C
- Humidity range: 0–100% RH, accuracy ±2% RH
- Response time: 5s (humidity), 8s (temperature)
- Supply voltage: 2.2–5.5V (wide range — 5V compatible)
- Interface: I2C, fixed address 0x38
The AHT21 is the successor to the popular DHT21 but communicates over I2C instead of single-wire, making it easier to interface reliably. Its calibration coefficients are stored in OTP (one-time programmable) memory and applied automatically — no factory calibration routine required from the user.
Crucially for the combo board, the ENS160 needs temperature and humidity compensation data to refine its gas resistance calculations. The AHT21 sits right next to the ENS160 and feeds it this environmental context — significantly improving eCO2 and TVOC accuracy.
Why the Combo Board Makes Sense
Running the ENS160 without temperature/humidity compensation produces noticeably less accurate eCO2 and TVOC readings. The ENS160’s hot plate elements change resistance with ambient humidity — and without knowing the humidity, the onboard algorithm makes assumptions that can cause 10–30% errors in TVOC readings in humid Indian climates.
By co-locating the AHT21 on the same PCB:
- Both sensors measure the same air pocket — no gradient error from separate placements
- One I2C cable instead of two separate modules and two sets of pull-up resistors
- Smaller footprint — the combo board is typically 15mm × 20mm
- Compensation data is always available — no code logic needed to handle missing sensor
The AHT21’s I2C address (0x38) and ENS160’s I2C address (0x53, or 0x52 if ADDR pin pulled low) don’t conflict, so both sit happily on the same bus.
Full Specifications Comparison
| Parameter | ENS160 | AHT21 |
|---|---|---|
| Measurement | eCO2, TVOC, AQI | Temperature, Humidity |
| Range | eCO2: 400–65000 ppm TVOC: 0–65000 ppb |
−40 to +85°C 0–100% RH |
| Accuracy | ±15% of reading (TVOC) | ±0.3°C / ±2% RH |
| Interface | I2C (0x52/0x53) | I2C (0x38) |
| Supply Voltage | 1.71–1.98V (core) 1.71–3.6V (I2C) |
2.2–5.5V |
| Current (active) | ~15 mA (Standard mode) | 0.96 mA |
| Warm-up Time | ~60 s initial, 1 min run-in | None required |
Wiring to Arduino
The ENS160+AHT21 combo board operates at 3.3V logic. Most Arduino boards (Uno, Nano) are 5V, so use the 3.3V pin for power if the breakout board includes an onboard regulator. If your board has no onboard regulator:
| Sensor Board Pin | Arduino Uno Pin |
|---|---|
| VCC | 3.3V (or 5V if board has regulator) |
| GND | GND |
| SDA | A4 (SDA) |
| SCL | A5 (SCL) |
Add 4.7 kΩ pull-up resistors between SDA/SCL and VCC if the breakout board doesn’t include them. Most commercial breakout boards include 10 kΩ pull-ups, which work but may cause issues at higher I2C speeds.
Wiring to ESP32
The ESP32 runs at 3.3V natively — no level shifting needed. The default I2C pins on most ESP32 dev boards are GPIO 21 (SDA) and GPIO 22 (SCL).
| Sensor Board Pin | ESP32 Dev Board Pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | GPIO 21 |
| SCL | GPIO 22 |
Arduino Code: Read eCO2, TVOC, Temp, Humidity
Install these libraries via the Arduino Library Manager before compiling:
- DFRobot_ENS160 by DFRobot (or ScioSense_ENS160 library)
- Adafruit AHTX0 by Adafruit
#include <Wire.h>
#include "DFRobot_ENS160.h"
#include "Adafruit_AHTX0.h"
DFRobot_ENS160_I2C ens160(&Wire, 0x53);
Adafruit_AHTX0 aht;
void setup() {
Serial.begin(115200);
Wire.begin();
// Init AHT21
if (!aht.begin()) {
Serial.println("AHT21 not found! Check wiring.");
while (1) delay(10);
}
// Init ENS160
while (ens160.begin() != NO_ERR) {
Serial.println("Waiting for ENS160...");
delay(3000);
}
ens160.setPWRMode(ENS160_STANDARD_MODE);
// Get temp/humidity for compensation
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);
ens160.setTempAndHum(temp.temperature, humidity.relative_humidity);
Serial.println("Sensors ready. Warming up...");
delay(60000); // 60-second warm-up
}
void loop() {
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);
// Update compensation data
ens160.setTempAndHum(temp.temperature, humidity.relative_humidity);
uint8_t status = ens160.getENS160Status();
if (status == 0 || status == 1 || status == 2) {
Serial.print("eCO2: "); Serial.print(ens160.getECO2()); Serial.println(" ppm");
Serial.print("TVOC: "); Serial.print(ens160.getTVOC()); Serial.println(" ppb");
Serial.print("AQI: "); Serial.println(ens160.getAQI());
}
Serial.print("Temp: "); Serial.print(temp.temperature); Serial.println(" °C");
Serial.print("Hum: "); Serial.print(humidity.relative_humidity); Serial.println(" %");
Serial.println("---");
delay(5000);
}
Expected serial output:
eCO2: 612 ppm
TVOC: 48 ppb
AQI: 2
Temp: 27.4 °C
Hum: 58.2 %
---
ESP32 + MQTT: Send Data to Home Assistant
For a connected air quality monitor, use the ESP32’s Wi-Fi and the PubSubClient MQTT library to push readings to Home Assistant or Node-RED.
#include <WiFi.h>
#include <PubSubClient.h>
// ... (include sensor libraries as above)
const char* ssid = "YourSSID";
const char* password = "YourPass";
const char* mqtt_server = "192.168.1.100";
WiFiClient espClient;
PubSubClient client(espClient);
void publishSensorData() {
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);
ens160.setTempAndHum(temp.temperature, humidity.relative_humidity);
char payload[128];
snprintf(payload, sizeof(payload),
"{"eco2":%d,"tvoc":%d,"aqi":%d,"temp":%.1f,"hum":%.1f}",
ens160.getECO2(), ens160.getTVOC(), ens160.getAQI(),
temp.temperature, humidity.relative_humidity
);
client.publish("home/airquality", payload);
}
In Home Assistant’s configuration.yaml, add an MQTT sensor for each value. The JSON payload can be parsed using Home Assistant’s MQTT JSON platform or the template sensor. This gives you real-time dashboards, alerts when TVOC exceeds 300 ppb, and historical trending.
Calibration and Warm-Up Requirements
The ENS160 uses metal oxide sensing elements that require a thermal conditioning cycle. The first time you power on a brand-new ENS160, it needs a “run-in” period of at least 1 hour to stabilise the sensing materials. During this period, readings will be elevated and unstable — this is normal.
After the initial run-in, every subsequent power-on requires a 60-second warm-up before readings are reliable. The sensor status register reports:
- 0 (Operating OK): Normal operation, data valid
- 1 (Warm-Up): Sensor heating up, data may be inaccurate
- 2 (Initial Start-Up): First-time baseline establishment (10 minutes)
- 3 (Invalid Output): Error state — check connections
Always check the status register in your code before using data. The library’s getENS160Status() function returns this byte. The ENS160 also maintains a baseline stored in internal memory — if the sensor is powered off for more than 7 days, the baseline resets and the initial start-up cycle repeats.
For the AHT21, no calibration is needed — calibration coefficients are baked in at the factory. However, avoid placing the sensor near heat sources (CPUs, power regulators) or in enclosed spaces with poor airflow, as this will skew temperature readings.
Enclosure and Placement Tips
Physical placement dramatically affects reading accuracy:
Height Matters
CO2 and VOCs accumulate at breathing height (1–1.5 m above floor). Mounting the sensor at desk height gives readings representative of what people actually breathe. Ceiling mounting or floor mounting will give misleading numbers in most rooms.
Airflow is Essential
If you enclose the sensor in a sealed box, VOC and humidity accumulate inside the enclosure — the readings will reflect the enclosure, not the room. Use an enclosure with ventilation slots. A passive chimney effect (holes at bottom and top) provides good air exchange without needing a fan.
Avoid Direct Sunlight
Direct sunlight heats the AHT21 significantly, biasing temperature readings upward by 5–15°C and humidity readings downward. Mount in a naturally shaded location or use a radiation shield (Stevenson screen style) for outdoor or sunny window placements.
Keep Away from Cooking Vapours
High ethanol/acetone concentrations (cooking fumes, cleaning spray nearby) will temporarily saturate the ENS160 — readings spike for 2–5 minutes and then return to baseline as the sensing material desorbs. This is normal behaviour, not a sensor failure.
MQ-135 Air Quality/Gas Detector Sensor Module
A cost-effective gas sensor for detecting NH3, NOx, benzene, and CO2 — a great companion or entry-level alternative to the ENS160 for air quality projects.
DHT11 Digital Relative Humidity and Temperature Sensor Module
A budget-friendly alternative to the AHT21 for temperature and humidity sensing in basic climate monitoring projects.
Project Ideas and Applications
Home Air Quality Monitor with OLED Display
Pair the ENS160+AHT21 combo with a 0.96″ OLED display (SSD1306) on the same I2C bus. Display all four metrics on the screen, add a tri-colour LED (green/amber/red) that changes with AQI, and power it all from a USB phone charger. Total BOM cost under ₹400.
School Classroom CO2 Alert System
High eCO2 in classrooms (above 1000 ppm) correlates with reduced cognitive performance. Build a wall-mounted monitor that flashes a red LED and sounds a buzzer when eCO2 exceeds 1000 ppm, reminding teachers to open windows. ESP32 Wi-Fi allows central logging for multiple classrooms.
Server Room / Data Centre Monitoring
Server rooms accumulate VOCs from burning electronics and high CO2 from poor ventilation. The ENS160 can detect anomalies — a sudden TVOC spike can indicate overheating components producing off-gassing before smoke detectors trigger.
Indoor Plant Growing Environment
Plants thrive with slightly elevated CO2 (600–1000 ppm). Monitor and auto-ventilate grow tents based on ENS160 eCO2 data. Pair with DHT20 or the AHT21 from the combo board to control humidity for humidity-sensitive plants like orchids.
HVAC Smart Control
Install in duct return air paths to measure TVOC and eCO2 levels. Use an ESP32 to control a relay that activates the fresh air intake damper when air quality degrades. This is far cheaper than commercial BMS (Building Management System) sensors.
Frequently Asked Questions
Is the ENS160 measuring real CO2?
No — the ENS160 measures TVOC (Total Volatile Organic Compounds) and uses an algorithm to estimate equivalent CO2 (eCO2). It cannot distinguish between CO2 and other VOCs. For true CO2 measurement you need an NDIR (Non-Dispersive Infrared) sensor like the SCD40 or MH-Z19. The eCO2 value is useful as a proxy for ventilation quality and human occupancy density.
Can I use the ENS160+AHT21 with Raspberry Pi?
Yes. Enable I2C on the Raspberry Pi (raspi-config → Interface Options → I2C). Use the Python smbus2 library or Adafruit’s CircuitPython libraries for both sensors. The ENS160 address (0x53) and AHT21 address (0x38) don’t conflict with most common Raspberry Pi I2C devices.
Why does my ENS160 show eCO2 = 400 ppm constantly?
400 ppm is the minimum reported value (clean outdoor baseline). If you always see exactly 400 ppm, the sensor may still be in warm-up mode (check status register), the baseline may not have been established yet (wait 10 minutes for initial start-up), or the sensor may be detecting genuinely clean air.
The AHT21 reads 5–7°C higher than a calibrated thermometer. What’s wrong?
Self-heating from nearby components (the ENS160’s hotplate reaches 200–300°C) can bias the AHT21 temperature reading upward. On some breakout boards, the thermal isolation between the two sensors is insufficient. Apply a correction offset in software, or contact the manufacturer to check if they’ve included thermal isolation in the PCB layout.
What’s the difference between AHT21 and AHT20?
The AHT21 is essentially the AHT20 with an additional CRC checksum on the data output, improving data integrity over noisy I2C buses. Software libraries handle both transparently. If you already have AHT20 code, it will work with the AHT21 (though you’re missing the CRC check benefit).
Conclusion
The ENS160 + AHT21 combination board is one of the most practical sensor modules available for indoor air quality monitoring. In one tiny package, it gives you eCO2, TVOC, AQI, temperature, and relative humidity — all the data you need to understand and act on indoor climate conditions.
The mutual benefit of combining both sensors cannot be overstated: the AHT21’s temperature and humidity readings feed directly into the ENS160’s compensation algorithm, producing significantly more accurate gas concentration data than running the ENS160 alone. Whether you’re building a simple desktop air quality display or a networked multi-room monitoring system, this combo board is an excellent foundation.
With the straightforward I2C interface, abundant library support for Arduino and ESP32, and the growing importance of indoor air quality awareness in Indian homes and offices, this is a sensor combination worth integrating into your next project.
Find Quality Sensors at Zbotic
Explore our full range of environmental sensors, gas sensors, and climate measurement modules — fast delivery across India.
Add comment