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.

Well, that was ! fun…

First off, I got it working with a bunch of Serial.print* commands. It was a logic error. Well three or four to be honest… :wink:

I have insane amounts of problems with my IDE. It sometimes compiles a new binary, and sometimes doesn’t. I then have to change the target type. If that doesn’t help, I delete the file structure, replace the moded files, run NPM install, and have another go at it. If that doesn’t work, I have to delete the "%userprofile%.platformio directory as well. Are others having these issues, or is it my configuration?

Anyhow, this is what I changed (between “Daro Mod Begin” and “Daro Mod End”), should anyone else want to add this functionality.








1 Like

why not make it available on git so people can pull from there instead?

Because it’s not my user mod and I have no idea how…

fork it on github, create a new branch, make your changes, commit, share link.

I have no clue what that means yet, but I will look into it.

Edit 1. First look: Am I seeing that correctly that forking is making a copy of the repository, and it is only possible for the entire branch(?), not for the individual mod? ACTUALLY: Should this be a different topic?

Edit 2. If I fork the whole repository, create a new branch, change the one user mod, commit it, and share it, am I responsible for keeping everything else up to date, or will everything else not moded by me come from the original?