Wemos D1 mini + BME680 + BSEC/IAQ + MQTT

Hello folks,
past couple of days I’ve been tweaking my sketch for my personal setup with bunch of Wemos D1 minis around the house and BME680 sensors attached to them.

As I wanted fully “official” BSEC and IAQ data to be gathered and calculated, I’ve been reusing some bosh codes and some other codes around. Which none of them was complete package.
I found quite harsh to get BSEC working from various sources over the internet, and mine is now working reliable so I wanted to do some share :wink:

needed libraries:

  • ArduinoJson (5.x) - it’s not compatible with 6.x
  • PubSubClient
  • Uptime-Library
  • bsec
    (from bosh generic or bosh-arduino) , bosh is currently down, I can provide my own if wanted

note: there is a need to copy bsec_serialized_configurations_iaq.c and bsec_serialized_configurations_iaq.h and bsec_iaq.config to the /Arduino/libraries/bsec root as for some reason BOSH haven’t put them there … and therefore their examples aren’t working :wink:

note2: it will not run on devices with 1MB Flash, as bsec is pretty big, so something like wemos is needed, but basically any esp8266 based units with enough flash would work.

note3: sensor is connected to 0x77 (SECONDARY, eg. without SDO to GND) if you use 0x76 change it in main program

Sketch folder contains main file and settings.h file which is basically ontly thing you need to adjust for your needs. If you are going to use more than one (as me) unit, this is very handy as you are changing just one line to make another unit in another room :wink:

Following program reads and adjust sensor and IAQ accurancy itself and after reaching 3 (calibrated) state it will save itself to EEPROM so when you restart or whatever your Wemos, it will recalibrate after reboot quite quickly.
As well BSEC is recalibrating itself while running so each 6 hours (configurable) it will save new state etc.
Each 2 mins (configurable) it will report to the MQTT broker to the topic home/your-device-config-name/climate/BME680 data from sensor in JSON format, which then can be easily integrated to OH (which I’m not going to explain in here).

MQTT output looks like this:

home/kitchen/climate/BME680 {"Uptime":"1T4:43:59","Temperature":25.6,"Humidity":57.7,"Pressure":978.8,"Gas":185.03,"IAQ":62.7,"sIAQ":82.3,"IAQ_Accuracy":3,"CO2e":822.671,"bVOC":1.188,"rawTemperature":25.7,"rawHumidity":57.3}

Progam maintain wifi and mqtt connection, reconnects as needed etc. So it’s fully autonomous and quite reliable in terms of IAQ.
It’s meant to be indoor, but I guess it can be used as outdoor (not yet tested) as well.

From observation of running BME680 and BME250 2cm from each other, it’s likely needed to add 1.3f temp offset to BME680 as build in heat compensation is not enough.
Your results might vary, but I’ve ran 5 BME680 and 3 BME280 at same place at same time without any heat from other chips and resuls are almost exactly the same 1.3-1.5 degree :wink:

Feel free to comment / update / hint following sketch

#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include "uptime.h"
#include "bsec.h"
#include "bsec_serialized_configurations_iaq.h"
#include "settings.h"

WiFiClient wifiClient;
PubSubClient client(wifiClient);

#define STATE_SAVE_PERIOD  UINT32_C(iaq_save_period * 60 * 60 * 1000)
#define MQTT_REPORT UINT32_C(mqtt_publish_period * 60 * 1000)
char wifi_hostname[50];
char mqtt_topic[100];

// Helper functions declarations
void checkIaqSensorStatus(void);
void errLeds(void);
void loadState(void);
void updateState(void);

// Create an object of the class Bsec
Bsec iaqSensor;
uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0};
uint16_t stateUpdateCounter = 0;
uint16_t stateUpdateMqtt = 0;

String output;

// Entry point for the example
void setup(void)
{
  // uniq name, topic, etc
  sprintf(wifi_hostname, "iot-wemos-%s",device);
  sprintf(mqtt_topic, "home/%s/climate/BME680",device);

  EEPROM.begin(BSEC_MAX_STATE_BLOB_SIZE + 1); // 1st address for the length
  Serial.begin(115200);

  setup_wifi();
  client.setServer(mqtt_server, 1883);
  Wire.begin();

  // set address
  iaqSensor.begin(BME680_I2C_ADDR_SECONDARY, Wire);
  // set offset
  iaqSensor.setTemperatureOffset(temp_offset);

  // useless info
  output = "\nBSEC library version " + String(iaqSensor.version.major) + "." + String(iaqSensor.version.minor) + "." + String(iaqSensor.version.major_bugfix) + "." + String(iaqSensor.version.minor_bugfix);
  Serial.println(output);
  Serial.println("");
  
  checkIaqSensorStatus();

  // set proprietary BOSH config
  iaqSensor.setConfig(bsec_config_iaq);
  checkIaqSensorStatus();

  // check EEPROM
  loadState();

  // subscribe to data from sensor
  bsec_virtual_sensor_t sensorList[10] = {
    BSEC_OUTPUT_RAW_TEMPERATURE,
    BSEC_OUTPUT_RAW_PRESSURE,
    BSEC_OUTPUT_RAW_HUMIDITY,
    BSEC_OUTPUT_RAW_GAS,
    BSEC_OUTPUT_IAQ,
    BSEC_OUTPUT_STATIC_IAQ,
    BSEC_OUTPUT_CO2_EQUIVALENT,
    BSEC_OUTPUT_BREATH_VOC_EQUIVALENT,
    BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE,
    BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY,
  };

  iaqSensor.updateSubscription(sensorList, 10, BSEC_SAMPLE_RATE_LP);
  checkIaqSensorStatus();
}

void setup_wifi() 
{
  delay(50);
  Serial.println();
  Serial.print("Connecting to SSID: ");
  Serial.print(ssid);
  WiFi.hostname(wifi_hostname);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  // disable AP mode which is for some unknown reason ON by default
  WiFi.softAPdisconnect (true);

  Serial.println("connected!");
  Serial.print("IP: ");
  Serial.println(WiFi.localIP());
}

void reconnect()
{
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("MQTT connection...");
    // Attempt to connect
    if (client.connect(wifi_hostname))
    {
      Serial.println("connected!"); \
    }
    else
    {
      Serial.print("failed");
      Serial.print(client.state());
      Serial.println(", try again in 5 seconds");
    }
    // Wait 5 seconds before retrying
    delay(5000);
  }
}

// Function that is looped forever
void loop(void)
{
  uptime::calculateUptime();
  
  // wifi disconnected
  if (WiFi.status() != WL_CONNECTED){
    setup_wifi();
  }
  // MQTT disconnected
  if (!client.connected()){
    reconnect();
  }
  client.loop();
  {
    unsigned long time_trigger = millis();
    if (iaqSensor.run()) { // If new data is available

      output = "";
      output += " Temperature: " + String(iaqSensor.rawTemperature) + " (" + String(iaqSensor.temperature) + ")";
      output += ", Pressure: " + String(iaqSensor.pressure / 1e2);
      output += ", Humidity: " + String(iaqSensor.rawHumidity) + " (" + String(iaqSensor.humidity) + ")";
      output += ", Gas:" + String(iaqSensor.gasResistance / 1e3);
      output += ", IAQ:" + String(iaqSensor.iaqEstimate) + " (" + String(iaqSensor.staticIaq) + ")";
      output += " (" + String(iaqSensor.iaqAccuracy);
      output += "), CO2e:" + String(iaqSensor.co2Equivalent);
      output += ", bVOC:" + String(iaqSensor.breathVocEquivalent);
      
      Serial.println(output);
     
      updateState();

      // MQTT publish every (n) minutes
      if (stateUpdateMqtt * MQTT_REPORT < millis()) {

        StaticJsonBuffer<300> jsonBuffer;
        JsonObject& root = jsonBuffer.createObject();
        
        root["Uptime"] = String(uptime::getDays()) + "T" + String(uptime::getHours()) + ":" + String(uptime::getMinutes()) + ":" + String(uptime::getSeconds());
        root["Temperature"] = decimals(iaqSensor.temperature,1);
        root["Humidity"] = decimals(iaqSensor.humidity,1);
        root["Pressure"] = decimals((iaqSensor.pressure / 1e2),1);
        root["Gas"] = decimals((iaqSensor.gasResistance / 1e3),2);
        root["IAQ"] = decimals(iaqSensor.iaqEstimate,1);
        root["sIAQ"] = decimals(iaqSensor.staticIaq,1);
        root["IAQ_Accuracy"] = iaqSensor.iaqAccuracy;
        root["CO2e"] = decimals(iaqSensor.co2Equivalent,3);
        root["bVOC"] = decimals(iaqSensor.breathVocEquivalent,3);
        root["rawTemperature"] = decimals(iaqSensor.rawTemperature,1);
        root["rawHumidity"] = decimals(iaqSensor.rawHumidity,1);
        
        // use it as JSON
        char data[300];
        root.printTo(data, root.measureLength() + 1);

        // mqtt report
        client.publish(mqtt_topic, data);
        Serial.println("MQTT Publish");
        stateUpdateMqtt++;
      }
    } else {
      checkIaqSensorStatus();
    }
  }

}

// Helper function definitions
void checkIaqSensorStatus(void)
{
  if (iaqSensor.status != BSEC_OK) {
    if (iaqSensor.status < BSEC_OK) {
      output = "BSEC error code : " + String(iaqSensor.status);
      Serial.println(output);
      for (;;)
        errLeds(); /* Halt in case of failure */
    } else {
      output = "BSEC warning code : " + String(iaqSensor.status);
      Serial.println(output);
    }
  }

  if (iaqSensor.bme680Status != BME680_OK) {
    if (iaqSensor.bme680Status < BME680_OK) {
      output = "BME680 error code : " + String(iaqSensor.bme680Status);
      Serial.println(output);
      for (;;)
        errLeds(); /* Halt in case of failure */
    } else {
      output = "BME680 warning code : " + String(iaqSensor.bme680Status);
      Serial.println(output);
    }
  }
}

void errLeds(void)
{
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(100);
  digitalWrite(LED_BUILTIN, LOW);
  delay(100);
}

void loadState(void)
{
  if (EEPROM.read(0) == BSEC_MAX_STATE_BLOB_SIZE) {
    // Existing state in EEPROM
    Serial.println("Reading state from EEPROM");

    for (uint8_t i = 0; i < BSEC_MAX_STATE_BLOB_SIZE; i++) {
      bsecState[i] = EEPROM.read(i + 1);
      //Serial.println(bsecState[i], HEX);
    }

    iaqSensor.setState(bsecState);
    checkIaqSensorStatus();
  } else {
    // Erase the EEPROM with zeroes
    Serial.println("Erasing EEPROM");

    for (uint8_t i = 0; i < BSEC_MAX_STATE_BLOB_SIZE + 1; i++)
      EEPROM.write(i, 0);

    EEPROM.commit();
  }
}

void updateState(void)
{
  bool update = false;
  if (stateUpdateCounter == 0) {
    /* First state update when IAQ accuracy is >= 3 */
    if (iaqSensor.iaqAccuracy >= 3) {
      update = true;
      stateUpdateCounter++;
    }
  } else {
    /* Update every STATE_SAVE_PERIOD minutes */
    if ((stateUpdateCounter * STATE_SAVE_PERIOD) < millis()) {
      update = true;
      stateUpdateCounter++;
    }
  }

  if (update) {
    iaqSensor.getState(bsecState);
    checkIaqSensorStatus();

    Serial.println("Writing state to EEPROM");

    for (uint8_t i = 0; i < BSEC_MAX_STATE_BLOB_SIZE ; i++) {
      EEPROM.write(i + 1, bsecState[i]);
      //Serial.println(bsecState[i], HEX);
    }

    EEPROM.write(0, BSEC_MAX_STATE_BLOB_SIZE);
    EEPROM.commit();
  }
}


float decimals(float input, int decimals)
{
  float scale=pow(10,decimals);
  return round(input*scale)/scale;
}

and settings.h

/*
* Device Setting
*/
const char* device = "short-and-uniq-device-name"; // lowercase

// reporting periods
const int iaq_save_period     = 6; // hours
const int mqtt_publish_period = 2; // minutes

// temperature offset
const float temp_offset(0.0f);

// wifi & mqtt
const char* ssid        = "YOUR WIFI SSID";
const char* password    = "YOUR WIFI PSWD";
const char* mqtt_server = "YOUR MQTT BROKER IP";

if you find it usefull, cheers! :slight_smile:
K.

3 Likes

That’s really cool. I’m currently running on a raspberry pi, with some mix results.

Does it need to change the configurations on the Arduino IDE to compile with the libalgobsec.a like they show on the bosh github?
I was successful to get the files from bosh to work using plataformio, it’s easier I think.

I had completely different code for RPI which honesly was not working neither closely as good as this one. I recon having a lot of issues with libalgobsec … and that’s why I switched this to the wemos.

for these type of application (where you do not need much power/IO/full linux etc.) I find much more usefull arduino code + esp chip . It’s pretty easy to follow, nothing really needed for compiling and can be remotely reflashed at will…

Hello Kriznik,

I am currently playing around with the BME680 to integrate IAQ values into my Openhab installation.
I tried your sketch, but I get an error:

iaqSensor.iaqEstimate is not defined in BSEC.h

I use the BSEC libary offered in the IDE.
Can you please provide me your files to give it a try.

Thanks for your support!

Dirl

I think i do have this library

anyway, i can send you whole lib and sketch if you like

Hello Kriznik,
This would be great!
Just send them to

dirkhuawei72@gmail.com

Thanks a lot!!!

Cheers
Dirk

this link expires in 7days

zip file with sketch and bsec library, this sketch is bit older version but main part is same as I’m using now. It’s OTA enabled (so there is hardcoded IP in main sketch of my server serving firmware - edit it)

I have bit newer version including PIR sensors, but for your usecase this is it…
if anything let me know

Hello Kriznik,

thanks for the data! I tried it but I get an error back


Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200”

C:\Users\lehma\Desktop\BSEC-1.8-HTTP\BSEC-1.8-HTTP.ino: In function ‘void callback(char*, byte*, unsigned int)’:

C:\Users\lehma\Desktop\BSEC-1.8-HTTP\BSEC-1.8-HTTP.ino:100:102: warning: ‘t_httpUpdate_return ESP8266HTTPUpdate::update(const String&, const String&)’ is deprecated (declared at C:\Users\lehma\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266httpUpdate\src/ESP8266httpUpdate.h:100) [-Wdeprecated-declarations]

 t_httpUpdate_return ret = ESPhttpUpdate.update("http://192.168.178.67/" + String(update_filename));

                                                                                                  ^

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o: in function `checkIaqSensorStatus()’:

C:\Users\lehma\Desktop\BSEC-1.8-HTTP/BSEC-1.8-HTTP.ino:234: undefined reference to `Bsec::setState(unsigned char*)’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o: in function `loadState()’:

C:\Users\lehma\Desktop\BSEC-1.8-HTTP/BSEC-1.8-HTTP.ino:240: undefined reference to `Bsec::setState(unsigned char*)’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o: in function `checkIaqSensorStatus()’:

C:\Users\lehma\Desktop\BSEC-1.8-HTTP/BSEC-1.8-HTTP.ino:250: undefined reference to `bsec_config_iaq’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o:(.text.setup+0x48): undefined reference to `Bsec::begin(unsigned char, TwoWire&)’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o:(.text.setup+0x4c): undefined reference to `Bsec::setConfig(unsigned char const*)’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o:(.text.setup+0x54): undefined reference to `Bsec::updateSubscription(bsec_virtual_sensor_t*, unsigned char, float)’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o:(.text.setup+0x100): undefined reference to `Bsec::begin(unsigned char, TwoWire&)’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o: in function `setup’:

c:\users\lehma\documents\arduinodata\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2/functional:2452: undefined reference to `Bsec::setConfig(unsigned char const*)’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o: in function `setup’:

C:\Users\lehma\Desktop\BSEC-1.8-HTTP/BSEC-1.8-HTTP.ino:55: undefined reference to `Bsec::updateSubscription(bsec_virtual_sensor_t*, unsigned char, float)’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: C:\Users\lehma\Desktop\BSEC-1.8-HTTP/BSEC-1.8-HTTP.ino:60: undefined reference to `Bsec::getState(unsigned char*)’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o: in function `updateState()’:

C:\Users\lehma\Desktop\BSEC-1.8-HTTP/BSEC-1.8-HTTP.ino:60: undefined reference to `Bsec::getState(unsigned char*)’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o:(.text.loop+0x8c): undefined reference to `Bsec::run()’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o:(.text.loop+0xe0): undefined reference to `Bsec::run()’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o:C:\Users\lehma\Desktop\BSEC-1.8-HTTP/BSEC-1.8-HTTP.ino:182: undefined reference to `Bsec::Bsec()’

c:/users/lehma/documents/arduinodata/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: sketch\BSEC-1.8-HTTP.ino.cpp.o: in function `loop’:

C:\Users\lehma\Desktop\BSEC-1.8-HTTP/BSEC-1.8-HTTP.ino:187: undefined reference to `Bsec::Bsec()’

collect2.exe: error: ld returned 1 exit status

exit status 1
Fehler beim Kompilieren für das Board NodeMCU 1.0 (ESP-12E Module).

Dieser Bericht wäre detaillierter, wenn die Option
“Ausführliche Ausgabe während der Kompilierung”
in Datei -> Voreinstellungen aktiviert wäre.

I also tried it also on a Mac, but same result. Any idea?

Cheers
Dirk

I prefer ESP Easy Mega. A flasher and a bin is inside this ZIP-File.

There after you can easely flash wemos and configure all sensors or header pins by esp easy software. Its recommand that you setup a controller brocker that MQTT data will be published to it. If you need any help let me know. I have two device in use at the moment.

you have to include bsec lib so arduinoIDE knows about it … obviously it’s not :slight_smile:

Hello Kriznik,

the bsec libary is included into the IDE. I tried again with a fresh IDE and libary installation on another PC. Same result……

No idea what it could be :frowning:

Cheers
Dirk

that error tells that there is no bsec function… so your ide does not know about bsec library
in zip I’ve provided there is lib, but that lib have to be linked to ide (not sure how i’ve done it honestly… but that link i’ve posted earlier is explaining it)

Hello Kriznik,

the bsec libary is included into the IDE, see Picture. I am running out of ideas…

isnt it somehow same?

I have IDE 1.8.11 if that makes a difference … dunno

Hi Kriznik,

Thank you so moch for your files and libraries!

So basically I had some fundamental questions below, but I’ve got it figured out, so I thought I’d share my configurations with everyone.

First off, if people are facing the same issues as Dirk (as I’ve had), you can easily install an older version of Arduino which is compatible like vesion 1.8.11 < I would have added a link here but “New users can only add two links to a comment” :relieved:>

Second, I myself had the problems below:

I got the Bluedot sketches working yesterday, however I was wondering two things:

  1. Are you using the last version 2.6.3 of the Wemos board? Or are you using the 2.2.0 version as mentioned on the Bluedot website.
  2. With your files and libraries do I stilll need to follow the instructions on the bluedot website regarding the patches of the files for the 2.6.3 version? Or should I follow the very incomplete bosch information?

Follow the steps from GitHub - boschsensortec/BSEC-Arduino-library: Arduino library for BSEC to simplify integration into compatible platforms. To report issues, go to https://community.bosch-sensortec.com/t5/Bosch-Sensortec-Community/ct-p/bst_community, I’ll point out what I’ve changed

  • Step 1: Dont use the latest IDE, use 1.8.11 accessible through the link above.
  • Step 2: I’ve used the BSEC library from a few posts above by Kriznik, with exception for the libalgobsec.a file, which I’ve downloaded from Bosch’s Github (BSEC-Arduino-library/src/esp8266 at master · boschsensortec/BSEC-Arduino-library · GitHub). Kriznik’s files won’t be avaiable for long, so maybe he can point out which version it is?
  • Step 3: Don’t follow step 13 from the bluedot tutorial posted by Kriznik above. Definitely follow Boschs’s instructions for this.
  • Step 4: Doesn’t matter whether you follow Bosch or Step 9 from bluedot.

Some things about directories:

  • platform.txt is located at C:\Users\ username \AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0
  • eagle.app.v6.common.ld is located at C:\Users\ username \AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.2.0\tools\sdk\ld

Carefully read Kriznik’s first note, it’s quite an important one :slight_smile:

glad it helped and you figured it out.
I can reupload files when needed, no problems

K.

btw for OH I’m using this kind of rule to process output from this BSEC MQTT sketch
(it probaly deserves some optimalisation, but i don’t care for now :wink: )

This counts % of the airquality based on 0-500 scale of IAQ

/* airquality */
rule "Calculate AirLabels"
when
    Time cron "0 0/5 * * * ?" or
    System started
then
    var String airQ = "Err "
    var String sIAQ = "Err "
    val max = 500
    val min = 0

    val kidsroomIAQ = (Kidsroom_sIAQ.state as Number).floatValue
    val bedroomIAQ  = (Bedroom_sIAQ.state as Number).floatValue
    val kitchenIAQ  = (Kitchen_sIAQ.state as Number).floatValue
    val livingIAQ   = (Livingroom_sIAQ.state as Number).floatValue
    
    val krq = 100 - ( ( (kidsroomIAQ - min) * 100) / (max - min))
    val brq = 100 - ( ( (bedroomIAQ - min) * 100) / (max - min))
    val kiq = 100 - ( ( (kitchenIAQ - min) * 100) / (max - min))
    val liq = 100 - ( ( (livingIAQ - min) * 100) / (max - min))

    postUpdate(Kidsroom_AirQ, krq)
    postUpdate(Bedroom_AirQ, brq)
    postUpdate(Kitchen_AirQ, kiq)
    postUpdate(Livingroom_AirQ, liq)

    airQ = String::format("%.0f %%", krq)
    sIAQ = String::format("%.0f", kidsroomIAQ)
    Kidsroom_AirLabel.postUpdate(airQ + " (" + sIAQ + ")")

    airQ = String::format("%.0f %%", brq)
    sIAQ = String::format("%.0f", bedroomIAQ)
    Bedroom_AirLabel.postUpdate(airQ + " (" + sIAQ + ")")

    airQ = String::format("%.0f %%", kiq)
    sIAQ = String::format("%.0f", kitchenIAQ)
    Kitchen_AirLabel.postUpdate(airQ + " (" + sIAQ + ")")

    airQ = String::format("%.0f %%", liq)
    sIAQ = String::format("%.0f", livingIAQ)
    Livingroom_AirLabel.postUpdate(airQ + " (" + sIAQ + ")")

end

and it looks like this

1 Like

Does anyone have a working espeasy plug-in for the BME680 + BSEC?

Hi could you share the working code and binary again? i cant get this to work :frowning:

sure:

pass: openhab

This version has got PIR as well, so ditch it out if you dont want it
and on line 107 there is hardcoded my update server, so ditch that as well or change IP

  • follow my first post where is described HOW to include library and stuff

Cheers

1 Like

thanks i started from scratch and i’m getting different errorstoday. where do i find the following files:

bsec_serialized_configurations_iaq.c and bsec _serialized_configurations_iaq.h and bsec_iaq.config