ENS160 Air Quality Sensor Library for Proteus Simulation: the ENS160 + AHT21 module, an I2C LCD 16x2, an RGB LED and a buzzer on an Arduino UNO V4.0

ENS160 Air Quality Sensor Library for Proteus Simulation

40
700
60
25
60
PCBWay

Hello friends, I hope you all are doing great. Today, I am going to share the new ENS160 Air Quality Sensor Library for Proteus Simulation. The ENS160 is a small digital gas sensor that tells you how clean the air in a room is: an air quality index from 1 to 5, the volatile organic compounds (TVOC) in ppb and an equivalent CO2 (eCO2) in ppm. It usually comes on a module together with the AHT21, a temperature and humidity sensor. With this library you can run a full Proteus simulation of that module, talk to both chips on the I2C bus, follow the warm-up, feed the compensation and watch a room's air change.

Animated ENS160 air quality sensor Proteus simulation: an Arduino UNO V4.0 showing the AQI, TVOC and eCO2 on an I2C LCD with an RGB LED
Figure: The ENS160 air quality sensor simulation at work.
Updates

ENS160 Air Quality Sensor Library for Proteus

Latest version: V1.0 (December 2026, this tutorial)

Helping Tools

The demo is a meeting room air monitor: an Arduino UNO V4.0 reads the ENS160 every second, gives it the AHT21's temperature and humidity, shows the AQI and both readings on a 16x2 LCD, colours an RGB LED from green to red and sounds a buzzer when the air turns unhealthy.

NOTICE: Our team has put a lot of effort into these small parts: the bodies, the animation and the pop-ups are all our own design, and you get them free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the air quality sensor board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the ENS160 Air Quality Sensor Library for Proteus Simulation:

ENS160 Air Quality Sensor Library for Proteus Simulation: the ENS160 + AHT21 module, an I2C LCD 16x2, an RGB LED and a buzzer on an Arduino UNO V4.0
Figure: The ENS160 Air Quality Sensor Library for Proteus Simulation.

What Is the ENS160 Air Quality Sensor?

The ENS160 is a metal-oxide (MOX) gas sensor in a tiny 3 x 3 mm package. Inside are four small hotplates, each with a sensing layer. When a hotplate is heated, the layer's resistance changes with the gases around it - alcohols, aldehydes, ketones, organic acids, amines and other volatile organic compounds that come from people, cooking, cleaning products, paints and furniture. A built-in processor reads the four resistances, compensates them for temperature and humidity and reports three results:

  • AQI-UBA: an air quality index from 1 to 5 after the German Federal Environmental Agency: 1 excellent, 2 good, 3 moderate, 4 poor, 5 unhealthy.
  • TVOC: the total volatile organic compounds, 0 to 65,000 ppb.
  • eCO2: an equivalent CO2, 400 to 65,000 ppm.

One point is important: eCO2 is not a CO2 measurement. The chip has no CO2 sensor; it estimates CO2 from the VOCs that people breathe out along with it. It is a good indicator in an occupied room, but for real CO2 you need an NDIR or photoacoustic sensor such as the one in our SCD41 CO2 Sensor Library for Proteus.

The Module: ENS160 + AHT21

The common module is a board of about 24 x 20 mm with the ENS160, the AHT21, a 3.3 V and a 1.8 V regulator (the ENS160 itself runs on 1.8 V) and I2C level shifters, so it works with 5 V boards. Its 8-pin header has VIN, 3V3 (the regulator's output), GND, SCL, SDA, ADD, CS and INT. Both chips share the I2C bus: the ENS160 at 0x53 (0x52 with ADD to ground) and the AHT21 at 0x38. CS stays high for I2C - pulling it low switches the ENS160 to SPI until the next power-up.

The Registers

The ENS160 is a register chip with 8-bit addresses and little-endian 16-bit values; the address counts up by itself, so several bytes can be read in one go:

  • 0x00 PART_ID: 0x0160 (read as 0x60, 0x01).
  • 0x10 OPMODE: 0x00 deep sleep, 0x01 idle, 0x02 standard (measuring), 0xF0 reset.
  • 0x11 CONFIG: the INT pin - on or off, on new data, push-pull or open drain, active low or high.
  • 0x12 COMMAND: 0x0E reads the firmware version, 0xCC clears the general-purpose registers - only in idle.
  • 0x13 TEMP_IN, 0x15 RH_IN: the temperature in Kelvin x 64 and the humidity in % x 512, for the compensation.
  • 0x20 DEVICE_STATUS: bits 3-2 the validity (0 normal, 1 warm-up, 2 initial start-up, 3 invalid), bit 1 new data.
  • 0x21 DATA_AQI, 0x22 DATA_TVOC, 0x24 DATA_ECO2: the three results, five bytes in a row.
  • 0x38 DATA_MISR: a checksum of every byte read from 0x20 to 0x37, to check the transfers.

Warm-Up and Compensation

A metal-oxide sensor needs its hotplates to settle. After every start the ENS160 reports validity 1 - warm-up - for 3 minutes, and in the first hour of its life it reports validity 2, the initial start-up. A sketch should show the readings but not act on them until the validity is 0. The other rule is compensation: the sensing layers react to humidity and temperature too, so the chip wants the real values in TEMP_IN and RH_IN. Until the host writes them it assumes 25 C and 50 %. That is what the AHT21 on the same board is for.

Features of the ENS160 Library

  • A real-looking module: the board at its true size with both sensors, the regulators and the header; at Run the ENS160's hotplate glows while it measures and a blue dot marks each AHT21 measurement.
  • The ENS160's register map: PART_ID, OPMODE, CONFIG, COMMAND, TEMP_IN / RH_IN, DEVICE_STATUS, AQI, TVOC, eCO2, DATA_T / DATA_RH, MISR and GPR, with auto-increment.
  • Modes and timing: deep sleep, idle and standard, a reset, a result every second, the warm-up with its validity flag.
  • The INT pin: on each new result, configured by CONFIG, released when the data is read.
  • The AHT21 on the same bus: its status, the 0xAC trigger, 80 ms, 20-bit humidity and temperature and the CRC-8.
  • Compensation: the results drift when the chip is told the wrong humidity or temperature.
  • A pop-up: the AQI on its 1 - 5 scale, TVOC, eCO2, the room and the compensation in use, the registers; graphs, an event log and a check page.
  • A complete package: about 2.7 MB with the library, our I2C LCD, resistors, RGB LED and buzzer, our Arduino UNO V4.0 and the demo, without the source code of the model.

The ENS160 in Proteus

The device is ENS160TEP in TEPENS160.LIB, under Modules > Sensors, with the model TEPENS160.DLL. Search ENS160 or air quality in Pick Devices. Its eight pins are the header of the real board; ADD and CS may stay open. Five properties set it up: PROFILE (DEMO or STEADY), TVOC, TEMP and RH for STEADY, and WARMUP, the warm-up in seconds - 3 by default, so the demo shows it in fast time instead of the real 3 minutes.

ENS160 + AHT21 air quality module from the ENS160 Library for Proteus Simulation, with the 8-pin header
Figure: The ENS160 + AHT21 module.

Download ENS160 Air Quality Sensor Library for Proteus Simulation

Click the button below to download ENS160-Air-Quality-Sensor-Library-for-Proteus-v1.0.zip (about 2.7 MB, without the source code of the models):

ENS160 Air Quality Sensor Library for Proteus V1.0
  • README.txt: installation, the demo, the wiring, troubleshooting and the limits of the simulation.
  • Proteus Library Files: TEPENS160.LIB, TEPI2CLCD16X2.LIB, TEPRESISTOR.LIB, TEPRGB.LIB, TEPBUZZER.LIB and ArduinoV4TEP.LIB.
  • Proteus Model Files: TEPENS160.DLL, TEPLCD.DLL, TEPRESISTOR.DLL, TEPRGB.DLL, TEPBUZZER.DLL and TEPARDUINO.DLL.
  • Arduino Code: the demo sketch (Wire only).
  • Proteus Simulation: the demo project, its HEX file and copies of the DLLs.

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install ENS160 Air Quality Sensor Library for Proteus Simulation

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
  3. Copy the files from Proteus Model Files into the MODELS folder.
  4. Delete TEPENS160.IDX from the LIBRARY folder if it is there.
  5. Start Proteus, press P and search for ENS160.

Proteus Simulation of a Meeting Room Air Monitor

The demo uses an A4 sheet with our Arduino UNO Library for Proteus V4.0. The module (U1) and a 16x2 LCD from our I2C LCD 16x2 Library for Proteus share the I2C bus on A4 / A5 - three devices at 0x53, 0x38 and 0x27. INT goes to D2. Our RGB LED on D9 to D11 shows the AQI colour - green, yellow-green, yellow, orange, red - and blue during the warm-up, and BZ1 from our Active Buzzer Library for Proteus on D8 beeps at AQI 5. The Arduino's monitor is built in, the same window as our TEP Serial Monitor Advance for Proteus. Open ENS160-Room-Air-ArduinoUnoV4.pdsprj.

The DEMO air is a recorded meeting room, played in fast time: clean air, people arriving, somebody spraying a cleaner, and the window opened. The temperature and humidity rise with the people too, which is why the compensation matters.

ENS160 simulation in Proteus: the ENS160 + AHT21 module, an I2C LCD 16x2, an RGB LED and a buzzer on an Arduino UNO V4.0, A4 sheet
Figure: The whole simulation on an A4 sheet.

The Sketch

The start-up follows the datasheet: a reset, the identity check, idle for the commands, the INT configuration, then standard mode:

  ensWrite1(OPMODE, 0xF0); delay(15);                        // reset; the checksum starts again from 0
  ensWrite1(CONFIG, 0x23);                                   // INT on, on new data, push-pull, active low
  ensWrite1(OPMODE, 0x02); delay(15);                        // STANDARD: a result every second

Every second the sketch measures with the AHT21 and passes the result on. The temperature goes in Kelvin x 64 and the humidity in % x 512, low byte first, because the chip takes the new value when the high byte arrives:

      const byte comp[4] = {lowByte(t), highByte(t), lowByte(h), highByte(h)};   // TEMP_IN (K x 64), RH_IN (% x 512), LSB first
      ensWrite(TEMP_IN, comp, 4);

When INT goes low, a new result is waiting. The sketch reads DEVICE_STATUS for the validity, then the five data bytes in one go:

  const byte validity = (st >> 2) & 0x03;
  byte d[5]; ensRead(DATA_AQI, d, 5);                        // AQI, TVOC (LSB, MSB), eCO2 (LSB, MSB) - reading them releases INT

Finally it checks the transfers. The ENS160 keeps a checksum, DATA_MISR, of every byte read from 0x20 to 0x37; the sketch keeps the same checksum of what it received, and the two must match:

void misrAdd(byte d) { byte m = misr << 1; if (misr & 0x80) m ^= 0x1D; misr = m ^ d; }

ENS160 Simulation Results

Open the project and press Run. The demo runs 13.3 simulated seconds and took about 3 minutes on our PC with the pop-up open and the pictures being taken. Click U1 for its pop-up. Every number below comes from one simulation run, the demo exactly as it ships.

Start-Up

At power-on the ENS160 boots in 10 ms at 0x53 - ADD is open, so the board's pull-up holds it high - and the AHT21 is ready after 100 ms. The sketch sets up the LCD, then follows the datasheet. The Event log shows every step: the reset at 302 ms and the chip back in IDLE at 313 ms; IDLE written at 317.9 ms; GET_APPVER at 348.9 ms, which puts the firmware version 5.4.6 into GPR_READ4 to 6; CONFIG 0x23 at 364.9 ms - INT on new data, active low, push-pull; and STANDARD at 365.2 ms. The monitor confirms it: "ENS160: PART_ID 0x0160, firmware 5.4.6, OPMODE 2" and "AHT21: status 0x18 (calibrated)".

The Warm-Up

The first result arrives one second later, at 1.37 s, with validity 1 in DEVICE_STATUS: the warm-up. The monitor prints "WARM-UP" with TVOC 11 ppb and eCO2 409 ppm, then 24 ppb and 422 ppm - the hotplates are still settling, and the values creep up towards the real air. The RGB LED glows blue and the LCD says WARM-UP. The pop-up at 2.4 s shows the same: the banner counts down the warm-up, DEVICE_STATUS reads validity 1, and on the right the registers - PART_ID 0x0160, OPMODE 0x02, CONFIG 0x23 - and the compensation the sketch wrote: TEMP_IN 0x49CB = 18,891 / 64 = 295.17 K = 22.0 C and RH_IN 0x53E9 = 21,481 / 512 = 42.0 %. On the sheet, the ENS160's hotplate glows orange. At 3.37 s the Event log says "warm-up over: validity 0".

ENS160 Proteus simulation pop-up: the warm-up, validity 1, the registers and the AHT21
Figure: The warm-up.
ENS160 Proteus simulation: the air quality module with its hotplate glowing
Figure: The module at work.
The ENS160 air quality sensor simulation running in the Proteus workspace
Figure: The simulation in the workspace.

Clean Air

From then on the readings count. In the clean room the monitor shows AQI 1 EXCELLENT: TVOC 40, 42 and 44 ppb, eCO2 439 to 449 ppm, at 22.0 C and 42 %. Every line ends in "ok": the sketch's own MISR checksum matches the chip's DATA_MISR, so not one byte was lost. The pop-up at 4.4 s shows AQI 1 on the green end of the scale and "the ENS160 compensates with 22.0 C, 42 %" - the AHT21's values, written into TEMP_IN and RH_IN every second.

ENS160 Proteus simulation pop-up: clean air, AQI 1 excellent
Figure: Clean air.

People Arriving

From 5.5 s people come in. The VOCs rise, and so do the temperature and the humidity: at 6.35 s the monitor reads 22.6 C, 46 %, AQI 2 GOOD, TVOC 146 ppb and eCO2 600 ppm - the RGB LED turns yellow-green. At 7.35 s it is AQI 3 MODERATE with 255 ppb, and at 8.35 s 373 ppb with eCO2 939 ppm at 23.8 C and 56 % - yellow. The pop-ups at 6.4 and 8.4 s show the same values, and the compensation keeps up: the chip is told the new humidity each second, so its readings follow the air, not the moisture.

ENS160 Proteus simulation pop-up: people arriving, AQI 2 good
Figure: People arriving.
ENS160 Proteus simulation pop-up: a full room, AQI 3 moderate, eCO2 above 1000 ppm
Figure: A full room.

A Cleaning Spray

At 9.0 s somebody sprays a cleaner near the sensor. The VOCs jump: at 9.37 s the Event log warns "AQI 5 UNHEALTHY: TVOC 2930 ppb, eCO2 1581 ppm", the monitor shows the same, the RGB LED turns red and the buzzer beeps. At 10.35 s it is still 2978 ppb and 1601 ppm. The pop-up at 10.4 s turns red, and its eCO2 line says "(bad)": over 1500 ppm, where the datasheet says ventilation is required. Notice that eCO2 jumped with the spray even though nobody breathed out any CO2 - it is estimated from the VOCs.

ENS160 Proteus simulation pop-up: a cleaning spray, AQI 5 unhealthy, TVOC over 3000 ppb
Figure: A cleaning spray.

The Window Opened

At 10.6 s the window is opened. At 11.35 s the air is AQI 4 POOR at 828 ppb, at 12.35 s AQI 2 GOOD - TVOC 179 ppb, eCO2 687 ppm at 22.8 C and 48 % - and the LED is yellow-green again. The pop-up at 13.3 s shows the room clearing and 12 results, all of them read.

ENS160 Proteus simulation pop-up: the window opened, the air clearing to AQI 2
Figure: The window opened.

The Graphs, the Event Log and the Check Page

The Graphs page plots TVOC and eCO2 as read, the AQI and the room's humidity: the spray stands out as one tall TVOC peak, while eCO2 follows the people more slowly. The Event log lists the modes, the commands, the CONFIG value, the end of the warm-up and every change of the AQI. The Check page sums up the run: VIN at 5.00 V with the 3V3 pin giving 3.30 V; PART_ID read once; OPMODE STANDARD with 12 results and 12 read; validity 0; the compensation green - "the chip uses 22.4 C / 45 % for air at 22.4 C / 45 %" after 13 TEMP_IN / RH_IN writes; and 13 AHT21 measurements with status 0x18, calibrated.

ENS160 Proteus simulation graphs: TVOC, eCO2, the AQI and the room humidity
Figure: The Graphs page.
ENS160 Proteus simulation Event log: the modes, the warm-up and the AQI changes
Figure: The Event log.
ENS160 Proteus simulation Check page after the demo run
Figure: The Check page.

The Arduino's built-in serial monitor prints the two chips' identity at start-up, then one line for each result: the time, the AHT21's temperature and humidity, the AQI and its name (or WARM-UP), TVOC, eCO2 and "ok" when the MISR checksum matches. Its times come from millis(), which starts when the sketch starts, a few hundredths of a second after the simulation does.

Arduino UNO V4.0 serial monitor in the ENS160 Proteus simulation: the identity, the warm-up, the AQI, TVOC and eCO2
Figure: The Arduino's monitor.

ENS160, CCS811, SGP40 or SCD41?

Our CCS811 Air Quality Sensor Library for Proteus covers the older chip that gives TVOC and eCO2 without an index; the ENS160 adds the AQI, four hotplates and a simpler start-up. The SGP40 in our SGP40 VOC Sensor Library for Proteus gives a raw VOC signal and leaves the index to a software algorithm on your board. For real CO2 the SCD41 in our SCD41 CO2 Sensor Library for Proteus measures it optically. And the AHT20 in our AHT20 Sensor Library for Proteus is the close cousin of the AHT21 on this module.

Try It Yourself

  • Click U1 while the simulation runs and use the chips: Clean air, People and Spray set a steady air; Humid 80 % raises the humidity.
  • Remove the ensWrite(TEMP_IN, ...) line: the chip assumes 25 C and 50 %, and when the room is humid the readings come out too high - the Check page marks the compensation.
  • Set WARMUP to 30: the AQI stays on WARM-UP much longer, the way a real chip spends its first 3 minutes.
  • Write OPMODE = 0x00 (deep sleep): the chip answers only OPMODE writes and every read returns 0.
  • Connect ADD to ground: the ENS160 moves to 0x52 at the next power-up and the sketch finds nothing at 0x53.

Ideas to Extend the Demo

  • Switch a ventilation fan through a relay at AQI 4 and back off at AQI 2.
  • Log the AQI and the eCO2 over a day and see the effect of meetings and cleaning.
  • Use the AQI to blink a reminder: "open the window".

Your Own Sketches

The demo sketch is in the zip file, and you can change it in the Arduino IDE. New to Arduino? Start with our Arduino Tutorial for Beginners. Export the compiled binary, and set the UNO's PROGRAM property to the new file. Our guide on How to get the HEX file from Arduino shows you where the file ends up.

Things to Know Before Using a Real ENS160

  • Warm-up: 3 minutes after every start, and the first hour of its life for the initial start-up - store nothing before validity 0.
  • Compensation: write the temperature and humidity every few seconds.
  • Self-heating: the AHT21 on these boards reads several degrees high while the ENS160 runs; correct it or mount a separate sensor.
  • Poisoning: silicone vapours and strong solvents can damage metal-oxide sensors.
  • Power: about 29 mA while measuring - not a sensor for a coin cell.

Troubleshooting

  • Nothing answers at 0x53: ADD is low (0x52), CS went low (SPI until the next power-up) or the supply is missing.
  • PART_ID reads 0: the chip is in deep sleep - write OPMODE = 0x01 first.
  • The AQI stays on warm-up: wait for validity 0 after OPMODE = 0x02.
  • COMMAND does nothing: commands run only in idle.
  • The MISR does not match: a byte was lost or the sketch missed a read in its own checksum.
  • The part is not simulated: TEPENS160.DLL is missing from MODELS and from the project folder.

Limitations of the Simulation

  • The register map, the modes, the commands, the validity, the MISR, the INT pin and the AHT21 protocol follow the datasheets; the board is our own drawing.
  • Our own figures: 10 ms to boot, the AHT21 ready after 100 ms, WARMUP 3 s, the AQI from the TVOC by the UBA bands in ppb, the compensation error (1 % per %RH and 0.5 % per C), the firmware 5.4.6.
  • The DEMO is a recorded meeting room in fast time.
  • Not modelled: SPI, the initial start-up hour, the raw hotplate values, the AHT21's self-heating on the board.
  • Arduino is a name of Arduino; this library is not made or endorsed by Arduino, Labcenter or the makers of the ENS160 or the AHT21.
  • Tested in Proteus 8.5 in November 2026 (the demo as shipped). Proteus 7 is not supported.

So, that was all about the ENS160 Air Quality Sensor Library for Proteus Simulation. I hope it helps you keep the air in your rooms fresh. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!


Comments

0

Join the conversation