moshe-braner / SoftRF

:airplane: Multifunctional, compatible DIY general aviation proximity awareness system
GNU General Public License v3.0
18 stars 4 forks source link

Option to shutdown when there is no external power #14

Closed moshe-braner closed 5 months ago

moshe-braner commented 2 years ago

Some glider pilots have asked for an option to mount the SoftRF device in an inaccessible place in the cockpit, connected to external USB power. When they turn off the master power, or remove the glider battery, SoftRF will also turn off if the device has no battery. But a T-Beam that has had no power for a while takes a long time to re-acquire a GPS fix. So I've added an option to have a battery in the T-Beam (only "Prime Mark II" supported by this feature), and have SoftRF turn itself off when (1) the battery voltage is below 3.9V, and (2) the device has been operating for at least an hour. The idea is that after an hour with external power the battery voltage will be back to over 3.9V. We'll see how well that works. The "Power source" setting needs to be set to "External" for that. The binary (version MB08a) is uploaded here.

speedstache commented 1 year ago

Hello Moshe, Is the external power feature expected to be working in version MB09u? I ran a tracker with MB09u version loaded down to 3.6 volts over an hour time period and didn't see a restart. I do see the selection for "External" power in the UI.

Thanks

moshe-braner commented 1 year ago

When set to run on external power but with a battery installed, it will keep running on the battery as long as still airborne. Once not airborne, it will shut down (not restart) after at least an hour of operation, once external power is turned off, if the battery voltage is below 3.9V. For now this is only implemented for the T-Beam (and the T-Echo but I don't know how to sense whether external power is off there). I tested this a long time ago, hopefully it still works.

speedstache commented 1 year ago

Thank you, that makes sense. It could be that ground testing it never gives the signal that it was airborne. I can test it more to see if it works as coded. This is on a T-beam

speedstache commented 1 year ago

Auto shutdown below 3.9 v works as long as it recognizes a flight first. Bench testing doesn't seem to do it.

Great feature!

moshe-braner commented 1 year ago

Interesting. Did you take it flying? (Or just driving?) But I don't see anything in the code that would require it to be "airborne" first. Just that it not be airborne at the time the voltage is down a bit, external power is not attached, and it's been operating for an hour. If somebody turns on the glider power for some checking and then turns it off, without flying, we do want the SoftRF device in the glider to shut down (after an hour) and not deplete its battery. Maybe I should do more testing of that here...

speedstache commented 1 year ago

Just driving this time. Maybe my testing is less conclusive than I thought but it did shut down as expected after both conditions were met. (Below 3.9 volts and one hour of uptime)

moshe-braner commented 1 year ago

I now tested that. It shut itself down after an hour (with battery voltage < 3.9) even though it was never "airborne".

But, if Bluetooth LE was active, it crashed and rebooted instead of shutting down. I will try and fix that.

Also, to be included in the next version, I've added code so that it only shuts down if it was connected to external power at some point and then disconnected. That way, if you borrow such an "installed" device for use in another glider without external power, it will keep running.