BME680 Sensor Plugin

I have written a new BME680 sensor plugin for directly connected devices.

This is written in as a sensor plugin and does not require external command execution.

The default i2c_address is 0x77 which is the default for Adafruit BME680 so if you have a Pimorini board you will need to change it in the configuration.yaml to 0x76.

image

3 Likes

I have submitted a pull request to the dev branch of Home Assistant. Hopefully it will pass review and we can see this sensor platform component included as default in future releases.

https://github.com/home-assistant/home-assistant/pull/11695

2 Likes

Pull request has been accepted into Dev branch and we should see this as a standard sensor component in the next release :slight_smile:

2 Likes

Component was released in Home Assistant 0.6.2

1 Like

Thanks for this, greatly appreciated. Works like a charm in my Home Assistant install, however I can’t shake the feeling that the temperature seems a bit too high. I have a really cheap thermometer (had it for 3-4 years) standing right next to my sensor which is showing 19,7 C° while the BME680 is constantly showing 2C° more. Obviously the cheap thermometer might be wrong, however the room feels more on the cold side, so I would doubt that. The sensor is connected via cables to the RPI, so more than 15cms away and no other heat source near it. Any ideas what might be the cause?

Not sure why the temperature would be out. The sensor plugin uses the open source BME680 python library that was written by Pimorini. This value is read from the sensor but there is a default IIR filter applied which is a configurable value in the sensor configuration section. The IIR filter is used to prevent the temperature bouncing around too much.

I do do some rounding to two decimal places in the sensor plugin but that should not have a 2 degree difference. Maybe it is just a bad sensor?

Try having a play around with the IIR filter setting and see if that helps at all.

@arcur sorry to ask you, but where you had connected your sensor? a nodemcu? wemos? can u share the code and the schematic?

It’s normal for the Bosch BSEC sensors to show a higher temperature. They are not factory calibrated and they even talk about in their documentation.

Looking at a reference thermometer, we can see that our temperature is indeed a few degrees to high. Does that mean the temperature sensor inside the BME680 is inaccurate?
Actually no, it very accurately measures the temperature exactly where it is located on the board. But there also is the issue: our board as most devices contains some heat sources (e.g., MCU, WiFi chip, display, …). This means the temperature on our board is actually higher than the ambient temperature. Since the absolute amount of water in the air is approximately constant, this also causes the relative humidity to be lower on our board than elsewhere in the room.
As BSEC cannot know in which kind of device the sensor is integrated, we have provide some information to the algorithm to enable it to compensate this offset. In the simplest case, we have to deal with an embedded device with a constant workload and approximately constant self-heating. In such a case, we can simply supply a temperature offset to BSEC which will be subtracted from the temperature and will be used to correct the humidity reading as well.

From BST-BME680-AN008-46 Integration Guide - Bosch Software Environmental Cluster (BSEC)

The sensor runs hot by itself, far from any device, you need set a temperature delta.

I might be wrong but in my opinion, all the python codes for the BME680 do not deliver actual meaningful air quality metrics. Unfortunately, Bosch BSEC doesn’t offer a python library and people did they’re best to get something out. They are running as BME280 with an extra metric…

@Rodolfo_Vieira The Code is in HomeAssistant since v0.6.2. You can take a look at the main HomeAssistant repository. The library for communication with the sensor is the Pimorini BME680 library, available on PyPi.

The board I use is the BME680 package from Adafruit, connected to a Raspberry PI via I2C. You can also use the board from Pimorini but they use a different default I2C address, you just need to configure it in the configuration as per the documentation on the plugin. It is on the main Home Assistant site.

@ferazambuja OK, well it seems like an offset temperature is needed as a config parameter then. I have actually not been working on this for some time since I wrote the original component due to family and work matters. I will see if I can take a look at this perhaps next week.

Looks like the temperature offset needs to go into the main library code and not the sensor plugin as it affects the humidity also. I will need to see if the Pimorini library supports that, if not, then we will need to get a pull request in for that library to support it.

As for the air quality metrics, my implementation is based on the Pimorini example and is just as inaccurate as that is. I do provide a fair few tuning parameters for AQ in the documentation https://www.home-assistant.io/components/sensor.bme680/ but the reality is it is only ever going to be an approximation without calibration.

The issue is that only a C library is available from BOSCH and even if a wrapper was written against it, it is a commercial library and could not be distributed with the sensor. Further, each sensor would still require to be calibrated in a dedicated gas test environment due to variations in manufacturing processes to get an accurate reading, although I would be willing to bet that the Bosch C library version with an uncalibrated sensor is still more accurate than the current implementation.

In another post on this forum on the BME680 sensor I talked about maybe implementing an option to use the C library which you would have to obtain and install yourself but this is a lot of work and something I don’t have time for in the short to mid term. If anyone else wants to tackle this, I am happy for any reasonable updates and pull requests that are made. I can help do code review if the HomeAssistant devs want me to before it gets merged.

For me, the AQ readings are indicatory but acceptable. I am only using it for indoor air quality. The sensor also only measures VOC and not PM2.5 or PM10 so it will never be true AQ sensor.

You did an excellent job and I appreciate. I don’t think Bosch had DIY users in their mind and the whole C library makes it really hard.
Once I have a free time I will try to MQTT the results from the C code.
I got a good idea here:

I got it the official Bosch BSEC to MQTT :slight_smile: It’s actually easy, I wrote a guide here if you guys want to check out.

Now I will try to run two sensors side by side to compare the differences between the libraries.

@arcsur @ferazambuja : You guys are awesome, thanks for your work! Definitely going to install it as soon as I find time to let you know about any errors

Hi @arcsur, this integration was removed, do you know why? Can I find it somewhere else? Thanks

Home Assistant stopped supporting GPIO based integrations in favour of ESPHome. There is support for this sensor in ESPHome. BME680 Temperature+Pressure+Humidity+Gas Sensor — ESPHome

The old code is still available on my Github but it is very likely not compatible anymore.