Howto - BME680 on a esp8266

for those trying to get BME680 to work using BSEC proprietary software on esp8266, so that you can gather IAQ and other air quality data.
it took a bit effort to figure out how to get the BME680 to work with an ESP. it works fine with esp32. but an esp was a bit illusive on how to setup on esp. as most internet information was missing one piece of important info (MMU).
so basically download the BSEC from arduino library

then edit esp platform.txt found either in windows /appData/locals/ or as hidden folder on linux
Arduino15\packages\esp8266\hardware\esp8266"ESPVersion"
add

compiler.libraries.ldflags=

to the bottom of this section

#These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
compiler.S.extra_flags=
compiler.cpp.extra_flags=
compiler.ar.extra_flags=
compiler.objcopy.eep.extra_flags=
compiler.elf2hex.extra_flags= 

and then edit this section:


## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {build.exception_flags} -Wl,-Map "-Wl,{build.path}/{build.project_name}.map" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{archive_file_path}" {compiler.c.elf.libs} -Wl,--end-group  "-L{build.path}"

to include
{compiler.libraries.ldflags}
after {compiler.c.elf.libs}
and then save file.

Next modify MMU of your esp8266 device to 16kb cache and 48kb IRAM

then once that is done you can flash your esp8266 with BSEC library and get more IAQ data from it

such as

"Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%], Static IAQ, CO2 equivalent, breath VOC equivalent";

arduino sketch for basic publishing a JSON. it does not publish for 320000 as it waits for the device to warm. if the device is mobile use IAQ for air quality if the device is inside use StaticIAQ for air quality measurements
MQTT_IAQ_BME680.zip (2.5 KB)

1 Like

@Andre_K – from the other thread and BME680 CO2 monitor. I do not seam to have the same issue as you were having .
from your example :


and my example from my BME680

basically all my peaks were when I cooked something on the oven or stove and if I open a window it drops to norms or it self clears in an 1/2 an hour or so after i finish cooking

1 Like

Are your windows always open? It’s weird that it would always stay at baseline even in an occupied room.

no my widows are mostly closed. still currently for the most part as the days and nights are still cool ( +2c at night and + 10c during the day). on a warm day with a light breeze with window open the sensor drops into the 400s. with no one in the room with the windows close it sits at 505 to 510 with someone in the room it bounces in the 550 to 600 range… I have 2 BME680 running at the same time one with basic and one with basic-config 3s/4d ( that save data in the eeprom so if the device is restarted it suppose to back to accuracy of 3 within 5 minutes instead of 3 hours or so that you have with basic but I have not tried yet as I have not reached the 4 days yet of operation only around 3) both exhibit the same behaviour currently though basic-config shows slightly lower CO2 levels then basic … I think my ENS160+AHT21 arrive tomorrow . I will let you know how those compare to the BME680.

by the way I live quite remote so pollution would have very little impact on the readings.

here the difference between outputs between BME680 and ens160
I would say the ens160 is a bit more sensitive while the bme680 is a bit more averaged out over time.
ens160:

and the bme680 for the same time period

but the outputs are roughly the same for both device . the peak for the ens160, I solder something in my room and it peaked higher but bottomed out quicker and only had a slight rise for the later peak for cooking something . I bought an NDIR co2 detector as it was far cheaper then scd40 with much higher sensitivity and I see how that compares. it should be here in a week or so

if i open the windows the ens160 sit around 400 and then go back up to around 550 - 600 when I close the window – where the bme680 sits in the same range with the window closed but it might drop to 450 with the widow open. so i assume my air quality is what it lists 550 to 600 ranges. not sure why @Andre_K spikes so differently unless he has alot of plants in the room that give off an aroma as the day warms and pollen fragrance goes up

1 Like