Measurement of basic environmental data in our apartment – temperature and humidity is one of the most popular applications of commonly available sensors for Raspberry Pi (RPi), Orange Pi (OPi) and ESP8266.
Then we added ability to measure the SMOG otuside and inside and today we will deal with two new and very interesting air quality sensors.
This is the gas sensor of volatile organic compounds (source: Wikipedia):
As for the BME680 – it is not a new design, but there is not much information nor actual sensor breakout boards – except for the Adafriut or Nettigo – Wemos D1 shield for DIY enthusiast.
The Nettigo version that I’m using is also compatible with the popular implementation of ESP8266 – the Wemos D1 mini and pro. At the same time, as Nettigo notes – installing the sensor directly above ESP8266 can impact the temperature readings – because BME680 contains the temperature, humidity and pressure sensors known from the BME280.
Let’s start by modifying the sensor – if we purchased at Nettigo – we need to change the default address by shorting the appropriately marked solder pads.
We make sure that our RPi with raspbian has the I²C bus enabled:
sudo raspi-config
Go to “Advanced”, turn on the I²C bus and reboot your RPi.
Then connect the jumper cables – that’s very easy:
Install the library from: https://github.com/pimoroni/bme680:
mkdir -p BME680
cd BME680
curl https://get.pimoroni.com/bme680 | bash
Go to “examples” folder and run the example code:
cd examples
python indoor-air-quality.py
After around 5 minutes we should get the IAQ.
In order to check the sensitivity you can use cotton cloth saturated with Isopropyl alcohol, or markers (i.e. permanent) – which contain volatile compounds resembling toluene or acetone and observe the speed of detection and return to the normal state.
The reading can be interrupted by CTRL + C, then – try the other examples: read-all.py and temp-press-hum.py.
The CCS811, just like the Bosch BME680 has the ability to measure VOC (total VOC – TVOC) and the equivalent of calculated carbon dioxide (eCO2). It is therefore a very good addition to the previous sensor that allows you to verify the VOC detection. It works on the same I²C bus and can be connected in parallel with the previous sensor for RPi. Due to its consumption of about 60mW – then you should get an external supply of 3.3V with the appropriate current performance.
3,3V CSS811 to 3,3V RPi
Then we have to make a change – slow down the I²C bus so that RPi works properly with the sensor. This means that any other device connected in parallel may have a problem with the operation (not the BME680 tough):
sudo nano /boot/config.txt
Add at the end of file the line:
dtparam=i2c_baudrate=10000
Reboot your RPi, check if the 5a is displayed:
sudo i2cdetect -y 1
If the sensor has not been detected – check whether you have definitely provided the appropriate baudrate for the I²C bus and restarted your RPi.
Once we see “5a”, we can proceed to the installation:
sudo apt update
sudo apt install git build-essential python-pip python-dev python-smbus
git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
cd Adafruit_Python_GPIO
sudo python setup.py install
After installing the appropriate libraries and GPIO support for Python, we proceed to downloading and installing the library for the CSS811 sensor:
sudo pip install Adafruit_CCS811
All that is left is to install demonstration program that reads the data from the sensor. It is recommended to run it for at least 24 hours to “burn in” because it will raport inflated values at the beginning. Of course, we can treat it gently with gases, but I do not recommend sprinkling directly onto the sensor (isopropyl alcohol) – a cotton swab will be much better.
Install:
cd ~/
git clone https://github.com/adafruit/Adafruit_CCS811_python.git
cd Adafruit_CCS811_python/examples
sudo python CCS811_example.py
This should give you:
This is the marker (toluen):
The python examples are very easy to read and understand and we can use them to update sensor in domoticz or InfluxDB/Grafana just like last time.
Now I’m building this:
This is it!