Problem with my code or the library?

I set up an environmental sensor based on the ESP8266 and the BME680 with the official Bosch library.
Unfortunately, I experience crashes as soon as my IAQ value reaches 255.

This is my code:

void loop() {
  if ( { // If new data is available
    INTERVAL(120000) {
      Serial.print("Activating Wifi: ");


      wait(100); // loop calling shorter delays() and the mqtt handle function
      Serial.print("Deactivating Wifi: ");
      WiFi.mode( WIFI_OFF );

const char* mqtt_topic_temp      = MQTT_TOPIC_BASE "temp";
const char* mqtt_topic_hum       = MQTT_TOPIC_BASE "hum";
const char* mqtt_topic_pres      = MQTT_TOPIC_BASE "pres";
const char* mqtt_topic_gas       = MQTT_TOPIC_BASE "gas";
const char* mqtt_topic_iaq       = MQTT_TOPIC_BASE "iaq";
const char* mqtt_topic_siaq      = MQTT_TOPIC_BASE "siaq";
const char* mqtt_topic_co2       = MQTT_TOPIC_BASE "co2";
const char* mqtt_topic_breathVoc = MQTT_TOPIC_BASE "breathVoc";
const char* mqtt_topic_time      = MQTT_TOPIC_BASE "time";

char pubchar[20];

void publishBME(PubSubClient &pubsubclient, Bsec &bme) {
  dtostrf(bme.temperature-1.3, 1, 2, pubchar);
  if(!pubsubclient.publish(mqtt_topic_temp, pubchar, true)) {
    Serial.println("Send error");

  dtostrf(bme.humidity, 1, 2, pubchar);
  if(!pubsubclient.publish(mqtt_topic_hum, pubchar, true)) {
    Serial.println("Send error");
  dtostrf(bme.pressure/1000.0, 1, 4, pubchar);
  if(!pubsubclient.publish(mqtt_topic_pres, pubchar, true)) {
    Serial.println("Send error");

  dtostrf(bme.gasResistance/1000.0, 1, 3, pubchar);
  if(!pubsubclient.publish(mqtt_topic_gas, pubchar, true)) {
    Serial.println("Send error");

  dtostrf(bme.staticIaq, 1, 3, pubchar);
  if(!pubsubclient.publish(mqtt_topic_siaq, pubchar, true)) {
    Serial.println("Send error");

  dtostrf(bme.iaq, 1, 3, pubchar);
  if(!pubsubclient.publish(mqtt_topic_iaq, pubchar, true)) {
    Serial.println("Send error");

  dtostrf(bme.co2Equivalent, 1, 3, pubchar);
  if(!pubsubclient.publish(mqtt_topic_co2, pubchar, true)) {
    Serial.println("Send error");

  dtostrf(bme.breathVocEquivalent, 1, 3, pubchar);
  if(!pubsubclient.publish(mqtt_topic_breathVoc, pubchar, true)) {
    Serial.println("Send error");

  itoa(millis(), pubchar, 10);
  if(!pubsubclient.publish(mqtt_topic_time, pubchar, true)) {
    Serial.println("Send error");

wait() is just loop calling shorter delays() and the mqtt handle function.
INTERVAL is this.
The wifi is only briefly activated for thermal reasons. I don’t have the hardware connection for deep sleep on the PCB and I don’t think it is necessary for thermal reasons.

bme.iaq is a float. 255 or 256 should not matter inside the MQTT string, so I would say the first AND latest point where anything could crash is dtostr. Is there anything I should know about that, or can I safely file an issue with the library?

or can I safely file an issue with the library

Just noticed, they have their issue tracker disabled. Way to go, Bosch >:(

Do the Bosch examples compile OK ?

Compiling is not the issue here. Everything compiles fine. It even runs fine and reports values. Until someone sleeps in that room, causing the IAQ to reach 255. Then the ESP reboots, as I see by the millis() MQTT output.
My code that get called during that time is very simple. I can really see only one line, which is the one with dtostr, in which 255 or 256 would matter in my code.

So either the Bosch lib is being stupid and has some quite nasty overflow of an uint8 (which I possibly cannot debug because I have to link closed-source code for this library), or (the Arduino/ESP-Arduino) dtostr function is being stupid,
or I am being stupid for not seeing other places where stuff could go wrong.

If 255 (very unhealthy, health alert) is a realistic value for one person after a few hours sleeping in a 20m^2 room that had a constant 25-30 before, or why CO2 estimation skyrockets when I open the window in a house next to the forrest, hundreds of meters away from the next major road and then drops in an apartment with virtually no plants are question that I prefer not to discuss before the other thing is solved.

Compiling is not the issue here. Everything compiles fine.

Well, the code you posted certainly doesn't compile, it's incomplete. So, no one else can test it. That will work towards minimizing the help you get.

Start with the BME680 examples. Do they crash? If not, then the problem is certainly with your code.

Then, divide and conquer. Cut out everything from your code but the BME680 stuff. Drop the WiFi, MQTT, etc. Does that crash? If not slowly add stuff back in until it does.

i.e. Use basic software debugging techniques.

Well, the code you posted certainly doesn't compile, it's incomplete. So, no one else can test it. That will work towards minimizing the help you get.

I did expect something like a caveat when using dtostr (which is the ONLY line of my code that has contact with that value, and to show that, there are a few lines from my code posted), or maybe someone who had a similar problem with the Bosch library. Not more, not less.
I didn't really expect that anyone would build his own ESP8266-BME680 sensor, flash my code and then sleep in a 20m^2 room for 6h to make this effect happen, so I cut it down to the relevant parts.
That is why I specifically asked that question. I don't need nor want to the type of help where I am taken by my hand and guided through a systematic search all over the place.

Since I will soon (PCB where just cleared by custom today) switch over to ESP32, and given how hard it is to reproduce, even I am not willing to hunt this down with more effort than that.