Raspberry Pi - Temp/Hum/Press/Air Quality - Beta Release v0.5

This is the first release of the software to work with the BME680 chip. It comprises three parts:

A) bme680_mqtt which manages access to the BME680. It reads data from the chip and adds it to an MQTT topic.
B) bme680_processor which reads data from the MQTT topic and further processes it. It adds the processed data to a SQLite3 DB (bme680.db)
C) Web pages which display the BME680 data and charts generated from the DB.

To install the software follow these instructions.

  1. Download the attached file - install_bme680.tar.gz
  2. These instructions assume the Raspberry Pi is built, you are able to log in either using a GUI or CLI session and the Pi is able to connect to the Internet, either wired or by WiFi. It is also assumed that the BME680 is mounted on a Mikroe click board and is configured to use the I2C interface. The software will work with BME680 chips mounted on other boards, but they must use the I2C interface. This software will not work with BME680s configured to use the SPI interface.
  3. Log into the Raspberry Pi either using an SSH command line connection, or if using the GUI then open a terminal session.
  4. Run “sudo raspi-config” to open the Pi configuration tool
  5. Select “3 Interface Options” then “P5 I2C” and select “” to enable the Pi I2C interface. Click OK to return to the menu and then " to exit to the OS prompt. If prompted to reboot answer “No”. This will be done later in the process.
  6. Run “sudo apt update” followed by “sudo apt upgrade” to ensure that the operating system and installed utilities are the latest versions. The upgrade may take a little while if you haven’t upgraded recently.
  7. Now reboot by entering “sudo reboot”. Log back into a terminal session after the Pi has booted up again.
  8. Transfer the “install_bme680.tar.gz” file into the /home/pi directory on the Pi. You can use WinSCP or a similar tool to do this.
  9. Extract the installation files using “tar -zxvf install_bme680.tar.gz”.
  10. Change to the install_bme680 directory by typing “cd install_bme680”.
  11. Run the installation script “sudo ./install_bme680.sh”. This script must be run with sudo to install the various system packages needed by the software.
  12. Change to the /home/pi/Sensors directory (“cd /home/pi/Sensors”)
  13. Edit the bme680.config file to suit your local requirements, e.g using nano:
    [li][list type=decimal]
  14. In the [mqtt] section change the ‘broker’ value to the IP address (or hostname) of your MQTT broker server. This will usually be the local Pi but this can be a remote server if required.
  15. If your MQTT server uses a different port than 1883 change the ‘port’ value in the [mqtt] section.
  16. If you want to use a different MQTT root topic than the default (‘bme680’) change the ‘root_topic’ value in the [mqtt] section.
  17. The default I2C address for the BME680 on a Click Board is 0x77. If your BME680 uses a different address (usually 0x78) change the value of ‘address’ in the [bme680] section.
  18. The temperature reported by the BME680 is likely to be higher than ambient due to heating by the local circuitry. The temperature can be adjusted by changing the ‘temp_adj’ value in the [bme680] section. This is a fixed value so it’s likely that it may need to be different when the ambient conditions change. This is not currently possible. It’s best not to rely on the temperature reported by the BME680 at this time for this reason. Note: this value is in degrees Celsius.
  19. The amount of logs generated can be changed by changing the ‘logging level’ value in the [bme680_mqtt] and [bme680_processor] sections. [bme680_mqtt] affects the bme680_mqtt program which manages the BME680 chip and reads data from it. [bme680_processor] affects the bme680_processor.py program which processes the raw data from bme680_mqtt and loads it into the DB (bme680.db which is created when required).
  20. The [bme680_processor]current_settings_freq value is currently unused and is for potential future use.

[/li]
[li]Enable the two services to start on bootup by typing “sudo systemctl enable bme680_mqtt” and
“sudo systemctl enable bme680_processor”.[/li]
[li]Start the two services by typing “sudo systemctl start bme680_mqtt” and
“sudo systemctl start bme680_processor”.[/li]
[li]Change to the web directory using “cd /var/www/html/bme680”[/li]
[li]Edit the web page settings by editing 'bme680_config.js", e.g. using nano:

[ol]
[li]Change the value of “host” to match your MQTT server IP address or host. In most cases this will be the IP address of the Pi.[/li]
[li]If your MQTT server uses a port other than 9001 for the web service, change the value of ‘port’ to match the server requirements.[/li]
[li]The ‘units’ value is currently unused.[/li]
[li]If you changed the root topic name in step 13 change the value of ‘root_topic_name’ to match.[/li][/ol]
[/li]
[li]If you now browse to http://<PI_IP_ADDR>/bme680 (replace <PI_IP_ADDR> with the IP address of your Pi, you should see raw data from the sensor being displayed. This page includes links to three other web pages showing charts of the data. It will take some time before the charts are fully populated with proper data but you should start to see the initial uncalibrated data plotted within a moment or two.[/li]
[/list]

Notes about BME680 web pages:

a) On the BME680 index page a value is displayed for ‘AQI Accuracy’. This can range from 0 to 3. 0 means the sensor is going through an initial 5 minute burn-in phase. During this time the other sensor values are unlikely to be valid, and AQI is fixed at a static 25. 1 means that the sensor is going through primary internal calibration phase. During this phase the displayed values will converge to the actual physical values fairly quickly. 2 means that the primary calibration has been completed. In this phase the data should be quite accurate, but the sensor still continues to carry out internal calibration for some considerable time. 3 means that the secondary calibration is complete and the values should be very accurate. It can take many hours or even days to reach state 3 so don’t worry if it doesn’t display quickly. It will display eventually. The meaning of the other displayed values can be found in the Bosch manual for the BME680. I believe this is available without signing up to an NDA.
b) AQI has a scale of 0 to 500. The AQI Plot chart shows the meanings of the various values of AQI.
c) Two of the chart pages have been built using Plotly (https://plotly.com) and one uses chart.js (https://www.chartjs.org). Neither is a preferred solution. Both work and if you want you can develop other web pages using either tool, or indeed any other tool that can read the data.
d) You can look at the data in the DB using the sqlite3 command line tool. Install the tool using “sudo apt install sqlite3”. After installation, type “sqlite3” at a command line prompt to enter the tool. You can list all the data using “select * from raw_data;”. Please don’t modify any data, or if you do, please don’t complain the your system is broken!

Finally, the code is in beta. It still contains debug code and other unfinished code (mostly commented out). Please don’t modify the code yourself at this time because it’s highly likely to change again soon. I don’t intend releasing the source code for bme680_mqtt because you need to sign up to an NDA with Bosch to get the library code required to compile and build it. If anyone wishes, post-beta, to sign the Bosch NDA then I’ll happily release the source code on a person-by-person basis.


install_bme680.tar.gz (263 KB)

Thanks, Chris. I’ll install it today!

It installed just fine. I’m letting it ‘cook’ for a while to see the data.

Great job!

Getting the install working is a good start. By now you should probably be seeing state 2 data on the charts.

Is it ok to install this software along with the lightning software?

It’s still sitting at 1.

It’s possible it takes longer to go through the states when you first start using it. That’s a while ago for me so I can’t remember how long the first time took. Having said that, mine is still only in state 1 and I re-started it last night. Maybe it has to see a range of temperatures before it says it’s better calibrated.

It is. I have both running on my test Pi.

A couple of things to note:

  1. The units displayed on the web pages are currently fixed as metric. AQI doesn’t have units and humidity is in % so those aren’t a problem, but if you want to use the temperature or pressure you’re currently stuck with Celsius and hPa. I will look at adding conversion based on a configuration setting in the next release. Or anyone still using non-metric could start using metric :wink:

  2. The time displayed on the charts doesn’t correct for DST and might be UTC. Difficult to say for me because non-DST is UTC here. Let me know what you see on your installation and I’ll try to work out how to get it to display local time if that’s possible.

The sensitivity of the sensor amazes me. Previously I tried blowing gently towards it from a few feet away and got the AQI graph to rise as a result.

I have a 3D printer sitting next to me on the desk and before printing I clean the print surface with isopropyl alcohol (IPA). The sensor was sitting about 18 inches below the printer whilst I wiped the surface with a bit of IPA on a paper kitchen towel. You can see the effect in the AQI plot in the attached image!


Not sure about the time:


I’ll change the time from a timestamp to a proper date/time in the next release.

One other thing to check is whether you have three bme680_processes running. When I reloaded my full development environment with the new version of the BME680 software only two processes started and the data looked weird. Easiest way to make sure is do “sudo systemctl restart bme680_processor”.

So, does the BME680 give an AQI including any or all of PM10, PM2.5, ozone, sulphur dioxide, nitrogen oxides, etc., etc., right through to VOCs without telling you what the dominant pollutant is?

P.S. IPA has a different meaning for me :occasion5:

It doesn’t do particulates. There isn’t an international standard for AQI with most countries who use such an index having different definitions. This AQI is defined by Bosch and it’s different to all the others. It’s basically looking at VOCs, CO/CO2, temperature and humidity (I think that’s all but I haven’t looked at the specs for many months) and giving you an idea of air quality in the sensor location based on those values.

I haven’t tested it near the other IPA yet. I suspect that as alcohol is a VOC then it would detect it.

I’m making progress with the updates. I now have the web pages able to convert to different temperature and pressure units. The index page now has a local date/time value displayed rather than the timestamp. Next job is to try to get the charts to have local time axes.

Having gone back to look at the BME680 documentation after many months I’ve realised I’ve made a letter transcription error. The chip doesn’t give an AQI value. It gives an IAQ value (Indoor Air Quality). I guess between reading and eventual coding my mind converted IAQ to the more commonly used AQI and I didn’t spot my mistake until now :oops:

I posted in general terms yesterday because it was a long time since I’d looked at the specs, too, but I stopped short of suggesting that the IAQ number would help when watching paint dry :slight_smile:

It seems Bosch “calibrate” the sensor with particular concentrations of VOCs (0.5-15 ppm) and apportion these to IAQ 25 and 250 on the familiar 0-500 scale.

I think Purple Air experimented with a BME680 in place of the BME280 in their air quality sensors?

Beta 2 is coming along nicely. 4 things remain to complete. One is in testing, one in development with 2 to start.