eCO2 sensor, thermometer, hygrometer with OLED display.
about the project
The CCS811 HDC1080 eCO2 temperature, humidity and VOC air quality sensor module CJMCU-8118 offers the advantage that several relevant parameters of the indoor air quality can be monitored in one board. The measured temperature and humidity readings also help to obtain more precise eCO2 readings.
We show the determined values on the one hand on a 1.3 inch OLED display. On the other hand, we transmit them to the Home Assistant via MQTT.
With the CCS811 sensor, the eCO2 concentration (equivalent calculated carbon dioxide) is measured in a range from 400 to 8192 ppm (parts per million) and the TVOC concentration (Total Volatile Organic Compound) in a range from 0 to 1187 ppb (parts per billion ) measured. According to the data sheet, the sensor reacts to alcohols, aldehydes, ketones, organic acids, amines, aliphatic and aromatic hydrocarbons. The eCO2 concentration is therefore only an approximation and can vary slightly from the actual CO2 concentration depending on other substances present in the room air.
The HDC1080 sensor measures temperature and humidity. Since the two sensors (CCS811 and HDC1080) are installed on the same board, and the CCS811 sensor develops heat when measuring, the measured temperature can deviate by a few degrees from the actual temperature. The fewer measurements the CCS811 sensor performs per period, the smaller the temperature deviation. However, the distances between the measurements should not be too far apart, as the CCS811 first carries out a calibration after starting and we would like to determine the precise eCO2 values as quickly as possible. We have therefore decided in this tutorial to carry out a measurement every 10 seconds and to store a correction factor of 0.5 degrees for the thermometer in the Arduino sketch.
The CCS811 sensor has a burn-in time of up to 48 hours, during which the values can still fluctuate. We should allow around 20 minutes for the calibration after the start and ventilate it completely once during this time.
Disclaimer: This is a kit for hobbyists who are enthusiastic about IOT. No responsibility can therefore be assumed for the functionality of the air quality measurement. For a precise CO2 measurement, we recommend using an appropriate CO2 measuring device from a specialist manufacturer.
The following components are required for assembly:
- WeMos D1 mini NodeMCU
- CCS811 HDC1080 eCO2 temperature, humidity and VOC air quality sensor module CJMCU-8118
- 1.3 inch OLED display module 128x64
- 400 hole breadboard / breadboard
- 40pin jumper cable - 10cm - Male to Male
The complete set of components in our shop:
Solder the D1 Mini NodeMCU
So that the "D1 Mini NodeMCU" can be plugged into the breadboard, it must first be soldered to the pin strips.
Please make sure that the pin strips are soldered on at right angles so that they later also fit the breadboard. To do this, you can first solder a pin to each pin strip and after it has cooled down, put everything on the breadboard (do not plug it in yet) to check whether it fits. If OK, the other pins can then simply be soldered. If it is not yet OK (wrong angle), the angle of the pin bar can be easily corrected by heating the already soldered pin.
Solder the CJMCU-8118
Analogous to the previous description, we solder the pin strip to the CJMCU-8118 sensor module.
Solder the OLED display
Analogous to the previous description, we solder the pin strip to the OLED display module.
In the next step, all components are placed on the breadboard.
The cabling takes place as follows:
- Yellow: D1 Mini D3 on CJMCU8118 WAK
- Blue: D1 Mini D2 on CJMCU8118 SDA and on OLED SDA
- Green: D1 Mini D1 on CJMCU8118 SCL and on OLED SCK
- Black: D1 Mini G to CJMCU8118 GND and to OLED GND
- Red: D1 Mini 3V to CJMCU8118 VCC as well as to OLED VDD
The following Fritzing diagram gives a good overview.
If the components are wired incorrectly and the NodeMCU is connected to the PC, this can damage the PC's USB port. Therefore, we first test by connecting the NodeMCU to a classic USB charger or a power bank with a USB cable. If nothing gets too hot there, that's a good sign.
Download and install the Arduino IDE
We need the Arduino IDE, which can be downloaded for free here: https://www.arduino.cc/en/Main/Software
It's even easier on Windows PCs, where the Arduino IDE can be installed via the Microsoft Store.
Add ESP 8266 board
First, add the following "Additional Board Administrator URL" to the default settings: http://arduino.esp8266.com/stable/package_esp8266com_index.json
To do this, we proceed as follows:
1. We call up the default settings:
2. We add the URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json
Install "ESP8266" board
To do this, we navigate to "Tools -> Board -> Board Manager".
Now we search for "ESP8266" and install the board.
Select "Generic ESP8266 Module" as the board
To do this, we proceed as follows:
1. We navigate via "Tools -> Board -> ESP8266 Boards"
2. We select "Generic ESP8266 Module" as the board
Select upload speed
Under "Tools -> Upload Speed" we select 115200.
We need the following Arduino libraries:
The libraries "ESP8266WiFi.h ","SPI.h "and" Wire.h "are automatically available by selecting the" Generic ESP8266 Module "as a board (see previous step).
We install the other libraries as follows:
We can install the required libraries under “Tools -> Libraries”.
1. We search for "PubSubClient" and select Nick O'Leary's library and click on "install":
2. We search for "U8g2" and select Oliver's U8g2 library and click on "Install".
3. We search for "ClosedCube_HDC1080" and select the ClosedCube library and click on "Install".
4. We install the ccs811.h library from Marteen Pennings manually, as it is not available via the library manager. See instructions in the "Installation" section at https://github.com/maarten-pennings/CCS811. So we first download the complete ZIP archive from the project page on GitHub.
Then we install it in the Arduino library manager using the "Add .ZIP library" function.
5. We search for "ArduinoJson" and select the Benoit Blanchon library and click on "install":
Copy the Arduino sketch from GitHub
Now we call up the following Arduino sketch from GitHub and copy it into a new sketch in our Arduino IDE using "Copy / Paste":
Now we have to add individual information to the Arduino sketch (see comments in the sketch), e.g. for
- WLAN access data
- MQTT server data
Please read all comments in the sketch carefully.
Upload the Arduino sketch to the NodeMCU
Now we connect our air quality sensor to our computer using a USB cable.
Then we select the relevant USB interface (e.g. COM3 or COM4) via "Tools -> Port".
Now we click on "Sketch -> Upload" and if there are no more errors in the sketch, it can be successfully uploaded and we can now use our "air quality sensor".
For the basic setup of Home Assistant, see https://www.home-assistant.io/getting-started/.
We designed the Arduino Sketch to support Home Assistant's MQTT Discovery functionality. As a result, the sensor is automatically recognized by Home Assistant and the data transmitted via MQTT can be displayed directly in the dashboards. To activate the MQTT Discovery function in Home Assistant, see https://www.home-assistant.io/docs/mqtt/discovery/.
The sensor data can be displayed in the Home Assistant dashboards in different ways.
If you click on the respective card, a history is displayed:
Other smart home systems
Thanks to the use of the MQTT protocol, it should also be possible to connect to all other smart home systems that support MQTT. However, due to the large number of different systems, we cannot guarantee this. To connect to other smart home systems via MQTT, please consult the documentation for the respective smart home systems.
The CCS811 calibrates itself automatically. However, we recommend ventilating completely at least once a day so that the sensor can redetermine the eCO2 zero point.
Optional: Firmware upgrade of the CCS811
If desired, the firmware of the CCS811 sensor can be upgraded to version 2.0. For more information see https://github.com/maarten-pennings/CCS811/. We ask for your understanding that we cannot accept any liability for the externally linked content.
Frequently asked questions
The eCO2 values of the NEO-IOT-Kit-6 differ from the eCO2 values of the NEOE-IOT-Kit-1 or other CO2 measuring devices.
- The two kits have different sensors and different programming. With both kits, the determined eCO2 values are approximate values and not precise CO2 measurement data. See mentioned at the beginning of this tutorial.
The Arduino program code does not work and an error message appears in the Arduino IDE
- Automatic translation from English to German is activated in some browsers. As a result, the Arduino program code on GitHub is automatically translated into German and is therefore displayed incorrectly. In this case, please deactivate the automatic translation before copying and transferring the Arduino program code.
Disclaimer - all information without guarantee:
The information contained in this tutorial (contribution) has been researched and compiled to the best of our knowledge and belief. However, mistakes can happen to us too. And something can also go wrong during the implementation of the tutorial or the content can be misunderstood. We cannot therefore accept any liability for any damage caused by following this tutorial. We are continuing to develop our tutorials. If something is inconsistent or unclear, please let us know so that we can correct or add to the point concerned. Thanks very much.