BME 280 Usermod - Thermal Shutdown?

Some might know that I’m building a project where I’d like to minimize the potential of being a fire hazard.

I saw the BME 280 mod, and since I have a couple laying around, I figured that I’d give modding the mod a shot. Unfortunately I need a bit of assistance…

This is what I was thinking:

  1. Add a variable to enable thermal shut down.
  2. Add a variable to store the shutdown temperature.
  3. Use those variables for the json configuration
  4. Toggle brightness from x to 0 (turn off) if the current temperature is greater than or equal to the shutdown temperature.
  5. Toggle brightness from 0 to whatever x was (turn on), if the current temperature is less than the shutdown temperature.

Anyway, it sort of does what I want, but the state doesn’t remain stable. If the temperature triggers shutdown, it goes off but the state then toggles every 4 - 6 seconds.

This is what I have:

image

This is what the Usermods page looks like:

Maybe there’s a better command? I couldn’t find “On” or “Power”.

try offMode=true , this will do the same as pressing the power button in the UI. maybe there is a function you can call instead of just setting offMode.

I tried that, but it reacts the same. I see why:


and my inner if statements around 246 toggled it on and off as long as the temperature is above the threshold…

No problem. So I thought…
I added a variable (ThermalShutdownTriggered) that is (should be?) true if the temperature threshold is exceeded, and false when it dips below that and (a new variable for) a hysteresis so the lights don’t flap. It seems however that ThermalShutdownTriggered is never set to true, but I cannot tell.

I tried adding some Debug statements, and looked on the serial monitor, but don’t see anything. If I were programming for my PC, I could just let the debugger run and step through my code, but I don’t see any options for that. Is there a document that explains how?

Here it is. Maybe it’s blatantly obvious to someone else. :smiley:

image

what is the serial output when you enable the debug messages?

This is all I get:
image

In the [common] section of platformio.ini I have this set

you can use Serial.print() and Serial.println() instead, they work even without debug enabled.

Thank you! I should have thought of that…

I will give it a try tomorrow.