Total Volatile Organic Compounds (TVOC) are a group of compounds present in the air (VOC), these are emitted from everyday activities, which are colourless and some odourless and some are toxic. TVOC monitoring is an efficient way to detect exposure to toxic VOCs. For example, applied to home monitoring, higher TVOC level may require ventilation on your room.
![](https://www.randomdiyprojects.it/wp-content/uploads/2022/06/air_quality_sensor_08.jpg)
This parameter can be measured using a CCS811 sensor, which is a gas sensor that detect a wide range of Volatile Organic Compounds (VOCs) and equivalent carbon dioxide (eCO2), mainly for indoor air quality monitoring.
![](https://www.randomdiyprojects.it/wp-content/uploads/2022/06/air_quality_sensor_CCS811-1.jpg)
The CCS811 can be connected with a Wemos D1 ESP8266 module and to Home Assistant using a few ESPHome code lines.
Wiring diagram
![](https://www.randomdiyprojects.it/wp-content/uploads/2022/06/air_quality_sensor_CCS811_wiring-1024x572.jpg)
ESPHome code
It’s based on the ccs811 sensor platform. Official documentation (LINK)
esphome:
name: air-quality-sensor
esp8266:
board: d1_mini_lite
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "8bd619f3f098c60427d9ffd802422226"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
i2c:
sda: D2
scl: D1
sensor:
- platform: ccs811
eco2:
name: "eCO2"
id: ccs811_eco2
tvoc:
name: "Total Volatile Organic Compound"
id: ccs811_tvoc
address: 0x5A
update_interval: 60s
Sensor Calibration
Calibrating Baseline
The sensor needs some calibration at first boot, so follow this steps:
o have consistent values, you need to specify a static baseline value (the calibration factor). To do this, first let the sensor boot up with no baseline set and let the sensor calibrate itself. After around 20-30 minutes you can then view the remote logs on the ESP. The next time the sensor is read out, you will see a log message with something like baseline=0xA483.
- Startup the sensor
- Open LOG window from your ESPHome Dashboard
- The log will show state 0.000
![](https://www.randomdiyprojects.it/wp-content/uploads/2022/06/air_quality_sensor_02.jpg)
- Wait around 15 minute until the log will to show something similar to baseline=0x147F
![](https://www.randomdiyprojects.it/wp-content/uploads/2022/06/air_quality_sensor_03.jpg)
- Copy that value and paste it in your code sensor section
- Save and Re-Install the code
![](https://www.randomdiyprojects.it/wp-content/uploads/2022/06/air_quality_sensor_04.jpg)
Home Assistant Integration
- Go to Settings – Integration menu
- The new device should automatically be available
- Click CONFIGURE and add it to your HA instance
![](https://www.randomdiyprojects.it/wp-content/uploads/2022/06/air_quality_sensor_05-1.jpg)
- Two new entities will be available
![](https://www.randomdiyprojects.it/wp-content/uploads/2022/06/air_quality_sensor_06.jpg)
- If you like it, you can create a Gauce card
![](https://www.randomdiyprojects.it/wp-content/uploads/2022/06/air_quality_sensor_07.jpg)