BME680 air quality sensor

Hi all, I picked up a cheap BME680 air quality sensor from Pimoroni, and have added it to HA below. From Pimoroni:

The gas reading in the BME680 should be sensitive to a wide range of different gases, like methane and other volatile organic compounds (VOCs), carbon monoxide, ethanol, human breath and sweat, and more, so you can really have some fun creating fart detectors or even a crude breathalyser!

This could be useful if you live in Sussex, England, and want to avoid noxius sea air..


I’m now using the BME680 with a micropython board, and have integrated it into my leak sensor rig:

I got one of those sensors, too. Since the calculation of the AQI is not documented in Bosch’s papers, I checkt the implementation of pimoroni… it seems to me that their AQI calculation is wrong as it will always lead to values around 100%…

It divides by gas_baseline which is avg of the last 50 values. So you’ll end up having values around nearly 1 every time. According to some other guy, the BME680 provides gas resistance values between 50ohm (lower limit for bad air) and 50000ohm (highest value - perfect air). This is something the implementation of pimoroni isn’t taking into account.

Mine appears to have died, looking into it

I’ve found an other library which is using Bosch’s prorietery library for the BME680 to calculate IAQ. Check this out:

Well I noticed that the sensor stops working after nearly 60 minutes. I’m investigating now, what the reason is… A simple restart fixes the issue but there must be a source for the issue.

1 Like

I found a solution. It seems that the heater is somehow dying after about an hour. I check if there was a result delivert within 10 minutes and if not, I simply call the sensor to init again. With this setup its pretty stable for about a day now.

That’s interesting, il take a look at the algo

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

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

AQ calculation still uses the Pimorini algorithm but it is run in a separate thread on a 1 second interval to prevent the degradation in gas resistance sampling when this is run on the event loop due to infrequent updates.

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.



Great work! Can it be used with a Hassio instance? Cheers

I don’t see why not but don’t have any experience with

Place it in your custom_components/sensor directory in your .homeassistant folder of the homeassistant user on the instance and configure as per the examples on the

So the Pimorini calculation is dependant on a continuous read out that is stabilized during the burn in time (5 minutes is the default I set but is configurable).

The idea is that it reads for the burn in time then takes the last 50 readings and averages them to get the baseline. This essentially means that it assumes that, during initialization, the air quality is perfect. It then uses that baseline and reducing gas resistance means that the VOC gas has increased. It uses that as a ratio of 75% gas to 25% humidity (configurable in config) with an ideal humidity specified (40% default but again configurable).

It is by no means an ideal measurement but if you do your calibration when you feel the air is clear you will see changes in air quality if VOC content or humidity changes.

I don’t think there is any way to get an accurate air quality measurement without lab based calibration and I think that would be specific to each and every sensor manufactured. I believe the Bosch algorithm has some curve calculations but I think this will only improve accuracy not make it accurate without calibration. At any rate, no way to tell without disassembly of their code which is prohibited in their license.

If anyone has some fancy math that they think will work better, I am more than willing to try to implement it.

1 Like

As I said there is a different lib that brings Bosch’s propriatary lib. They did some calibration in their labs.

1 Like

As I mentioned above, I believe the C-Library helps to improve the accuracy by using some curve calculations (probably considerably). It will never be completely accurate without actually baselining each sensor individually.

The Issue is that that library is a C binary that is only distributed for specific platforms. There is certain licensing agreements required to use it and distribute it.

Without going into the licensing side of things, which could be problematic, the issue of requiring, detecting and distributing multiple binary blobs does not fit with the current HomeAssistant component model and would also limit usage to specific systems and glibc versions.

I want to get this component into the main dev branch soon. I have cleaned up the code and the only thing remaining is to write the documentation. Using the C-Library is out of scope for the effort I am currently working on. Maybe in future I can work out some way that this can be manually configured as an additional option but for now, having some relative Air Quality is better than no AQ and no support for the other sensors on this package.

1 Like

Pull request into dev branch of Home Assistant code base. Passed all tests, documentation written, just pending review and merge.

1 Like

BME680 Sensor Component was included in the Home Assistant 0.6.2 release.

1 Like

Hi All,
Is this sensor running on same pi as Home Assistant or on a remote pi? I would like to have either another pi or ESP NodeMCU type device to take measurements and send via MQTT.
Just wondering what the best approach would be or more importantly, how have you successfully implemented it?

Thanks in Advance!

The BME680 it’s a tricky sensor and the python libraries are not so good.
I was able to get Bosch BSEC code on both ESP32 and on the Raspberry Pi.

Is actually quite simple to compile it in C.

Does anyone have suggestions on how to mqtt to home assistant?

1 Like


Thanks @robmarkcole
What I’m trying to MQTT is the data generated using the Bosch BSEC library and

It’s on C and uses precompiled libraries from Bosch.

The big advantages are that It returns IAQ Indoor Air Quality value instead of that strange kind of meaningless % and uses the measures to of self-calibrate itself and increase accuracy.
The results seem to look better than the ones from the python libraries. I might run two sensors and see how they behave.