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.
- Download the attached file - install_bme680.tar.gz
- 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.
- Log into the Raspberry Pi either using an SSH command line connection, or if using the GUI then open a terminal session.
- Run “sudo raspi-config” to open the Pi configuration tool
- 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.
- 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.
- Now reboot by entering “sudo reboot”. Log back into a terminal session after the Pi has booted up again.
- 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.
- Extract the installation files using “tar -zxvf install_bme680.tar.gz”.
- Change to the install_bme680 directory by typing “cd install_bme680”.
- 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.
- Change to the /home/pi/Sensors directory (“cd /home/pi/Sensors”)
- Edit the bme680.config file to suit your local requirements, e.g using nano:
[li][list type=decimal] - 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.
- If your MQTT server uses a different port than 1883 change the ‘port’ value in the [mqtt] section.
- If you want to use a different MQTT root topic than the default (‘bme680’) change the ‘root_topic’ value in the [mqtt] section.
- 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.
- 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.
- 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).
- 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)