To make it sense of the gas resistance from the BME680 you need the precompiled Bosch BSEC library. It’s easier to run on the pi than the Arduino. If you want I can post later how to get to work on the esp via platformio IDE.
Without the Bosch library the BME680 is running like a BME280 with meaningless gas readings.
Here is how I got to get the BME680 running using Bosch BSEC Arduino Library on Platformio IDE.
-
Create a project for the board that you are going to use.
-
Copy the https://github.com/BoschSensortec/BSEC-Arduino-library/
-
Copy the files from BSEC-Arduino-library/src to your src folder on Platformio IDE.
-
Copy the files from BSEC-Arduino-library/examples/basic_config_state/ also to the src folder (bsec_serialized_configurations_iaq.cpp and bsec_serialized_configurations_iaq.h)
-
Copy the source code from the https://github.com/BoschSensortec/BSEC-Arduino-library/blob/master/examples/basic_config_state/basic_config_state.ino to your main.cpp
-
Download the latest library at https://www.bosch-sensortec.com/en/bst/products/all_products/bsec
-
Copy the libalgobsec.a file for the ESP8266 to the folder lib on your platformio project.
-
Add this line at the end of your platformio.ini
build_flags = -L/Users/USER/Documents/PlatformIO/Projects/BSEC_BME680/lib/ -lalgobsec
Hopefully, it will build. I know it sounds complicated but is less than changing your Arduino IDE to use precompiled libraries.
Thanks! Will soon give it a try.
I gave it a try, but I’m stuck at point 7 and 8. I couldn’t find a platformio file, but maybe that’s the platform you are using from https://platformio.org/ ?
I also tried to follow the steps at https://github.com/BoschSensortec/BSEC-Arduino-library/, but got stuck at 4. Modify the platform.txt file , the lines in it I should change differ from what they say there. I’m also not sure what platform.txt I should edit, I have a very small one in C:\Program Files (x86)\Arduino\hardware and one in C:\Program Files (x86)\Arduino\hardware\arduino\avr
I did some more testing yesterday by the way, Iwas working from my home office, so I was able to see what the sensors reported when I closed the door and window.
8:00 : started working with window & door closed
11:30 Oped window and door
13:00 Closed window
ccs811: Seemed to have picked up all changed nicely
IAC core C: Same pattern, only reporting much higher values
I hope these values are not the real co2 values, because that would be quite unhealthy according to this table:
SGP30: Same pattern again, little bit lower than the cc811. Goes back to 400 when the CO2 concentration is on the low side
MH-Z14a: Same story again :), only did not pick up what happened around 17:00 (I actually can’t remember what I did at that time, I think I was in and out of the room a few times.
BME680: Ok, no c02 values here, I just plotted the resistance values, higher is better in this case. I also picked up the same changes, so that’s good, but it died just before 16:00 (worked again after a ESP reset)
I did notice that the IAC core C and ccs811 sometime drift off to way too high values. I seem to get the best “real co2” results from the MH-Z14a, but that’s not really surprising since it works in a much different way than the other 4. The good news is that all are capable of giving you a general idea of the indoor air quality.
I eventually want to be able to install a air quality sensor in every room in the house, not sure yet which one it’s going to be (and with what other sensors I’m going to combine it, for instance with a dust sensor)
I’m using with Atom. You need to create a new project on Platformio IDE.
But honestly, you seem more used to the Arduino IDE. Then follow the BSEC-Arduino guide.
On step 4 is the plataform.txt file that is in C:\Program Files (x86)\Arduino\hardware\arduino\avr
If you are using a 8266 you will need step 5. The address to the file on windows seems to be:
C:\Users\USERNAME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\tools\sdk\ld\eagle.app.v6.common.ld
https://scottsnowden.co.uk/esp8266-arduino-text-will-not-fit-in-region-iram1_0_seg-error/
The data look interesting. Hopefully, I can run some tests with the CS811 and the BME680 this week.
A thanks, didn’t know we where talking about a different IDE, seems like a interesting one too, have to look into that some day
I’m now still trying to get it working with the Arduino IDE, I’ve made some progress. I turned out the platform.txt I had to modify was located in C:\Users<username>\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1
After modifying that, I edited eagle.app.v6.common.ld, that was located in C:<username>\Erik\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\tools\sdk\ld to add libalgobsec.a and copied libalgobsec.a to my BSEC library location in C:\Users<username>\Documents\Arduino\libraries\BSEC-Arduino-library-master\src\esp8266
I also had to modify bme680_defs.h , I had to change:
/** BME680 I2C addresses */
#define BME680_I2C_ADDR_PRIMARY UINT8_C(0x76)
#define BME680_I2C_ADDR_SECONDARY UINT8_C(0x77)
into
/** BME680 I2C addresses */
#define BME680_I2C_ADDR_PRIMARY UINT8_C(0x77)
#define BME680_I2C_ADDR_SECONDARY UINT8_C(0x76)
I’ve now been able to get the basic sample compiled and it is returning some values.
Temperature and humidity seem to be ok, but for IAQ I constantly get 25 and a accuracy of 0, so I have to look into that, maybe it needs a burn in time or something.
The accuracy and the values will change once it has enough data. The basic_config_state.ino saves on the data on the EEPROM.
The history BSEC considers for the automatic background calibration of the IAQ in days. That means changes in this time period will influence the IAQ value.
- 4days means BSEC will consider the last 4 days of operation for the automatic background calibration.
- 28days, means BSEC will consider the last 28 days of operation for the automatic background calibration.
On basic_config_state.ino
#define STATE_SAVE_PERIOD UINT32_C(360 * 60 * 1000) // 360 minutes - 4 times a day
There is more info on the pdf from Bosch. I haven’t really look into. Also, at least on Linux there are different modes for the 1.8v (closed cube) and the 3.3v.
It is different than the most sensor that just gives you the right data. The temperature tracking is really good however it does not comes calibrated from the factory. Mine are usually higher than other factory calibrated temperature sensors. I still need to find on their documentation how to adjust the temperature delta.
Just change:
iaqSensor.begin(BME680_I2C_ADDR_PRIMARY, Wire);
to iaqSensor.begin(BME680_I2C_ADDR_SECONDARY, Wire);
then you don’t need to change bme680_defs.h.
I’m considering opening a topic about the BME680 since I don’t believe the implementation that we have on Home Assistant is the best one.
Found this thread - I found these sensors that calculate “eco2”, “equivalent” co2 and this seems to be the only reasonable discussion comparing them to actual co2 sensors. The only sensor you’re testing here that’s actually a co2 sensor is the MH-Z14a, correct? The other three are “equivalent”?
I’m guessing the other sensor picks up other gasses. Could you try this experiment: At the sensors, put a glass of alcohol (wine, rubbing alcohol, etc). See if they think this is co2? It should register as tvoc, but it should not register as co2.
Hi Mirar,
Sorry for my very late reply
unfortunately I don’t have my test setup running anymore, so I can’t easily do that test.
The MH-Z14a was indeed the only “real” co2 sensor. Since it gave me the most consistent results, I eventually wend with that sensor and created a board for it:
!On top of the board the mh-z14a can be placed:
and together they can fit in this housing:
Unfortunately the thing still has a few flaws:
- The co2 sensor stops reporting values after a while. Sometimes after a hour, sometimes after several days
- the si7021 sensor I combined it with to report humidity and temperature is giving much too high temperature values, possibly because of the proximity to the ESP8266
Hi - Thanks a lot… this code worked great with a Wemos D1 Mini (adjusted the pin) - getting great reading after 24 hours - and connected to home assistant via MQTT.
However, I am having trouble with the sensor code in configuration.yaml
mqtt:
broker: 192.168.0.87
port: 1883
Sensors
sensor:
- platform: mqtt
name: “CO2”
state_topic: “ccs811/co2”
qos: 0
unit_of_measurement: ‘PPM’
Any help? Sorry really don’t understand the json syntax… and/or how it translates to the sensors in the UI.
Thanks
Does anyone have a wiring schematic for the IAQ-core C and the ESP8266 (I’ve got one of these laying around: AliExpress NodeMCU esp8266 CH340
On Erik’s GitHub page the schematic is still a ToDo
Edit:
Did some Googling so I’ll save whoever comes across this post the hassle:
In the code SDA=4, this is D2 on the NodeMCU v3 board (source)
SCL=5, this is D1 on the board
3V3 connects to 3V on NodeMCU
GND with G
So basically:
IAQ Pin 1 - unconnected
IAQ Pin 2 - NodeMCU D1
IAQ Pin 3 - NodeMCU G (any is OK)
IAQ Pin 4 - NodeMCU D2
IAQ Pin 5 - unconnected
IAQ Pin 6 - NodeMCU 3V
Hint: you can sample these parts for free on the AMS website if you’re lucky.