Hello everyone.
For my setup I'm using a Witty Pi 4 connected directly to a 2S battery which is charged by a solar panel. When the system has power, it restarts on schedule with the extra capacitor to stabilise the microcontroller voltage. It also starts as expected when the battery is disconnected and then reconnected ("default ON"). While the system normally restarts after the voltage drops below the low voltage threshold and then returns to the recovery voltage, this does not always happen. I've had several cases during testing where the battery voltage was very low (around 6V) and the voltage recovered above the recovery voltage threshold, but the system didn't restart. As my setup can be buried in snow for several weeks/months, this can unfortunately happen, even if the system is switched off before the battery is empty.
Is there any way to explain/fix this problem? My only idea is that it could be caused by a brown out.
Thanks for your help!
Eagleshot
Please tell me if I miss something, but with B.O.D. enabled and current firmware I can currently either:
* Turn on the default power mode - which may cause a boot loop because the battery does not have enough power.
* Turn off the default power mode - the system may also potentially never wake up again because the low-voltage shutdown was not triggered.
Just to reiterate why I need this functionality or an alternative to (re)boot reliably after a power loss (which in my opinion is not a very specific use case and will benefit all users): I am building a timelapse camera system for my client and have in total bought about 15 Witty Pi 4s for testing and our first 'production' systems which we want to put in the field in the next weeks. If our first systems works reliably, I would have planned to expand our operation and potentially make many more systems, all of them with a Witty Pi inside. However if the camera doesn't restart, no matter if the reason is an edge-case or not, it's basically game-over as we can't restart them manually. As I generally really like the Witty Pi I would love to help you implement and test a fix. But if I have to implement and test a custom firmware completely myself anyway, I might aswell spend that time looking for alternative that works out of the box.
Regards,
Eagleshot
@eagleshot enabling B.O.D. is to protect the data stored in the MCU. B.O.D reset is the last defence of data in EEPROM and it should not be used as part of functional logic.
The "default power ON" option is for users who power Witty Pi with rather stable voltage, when the power is on, it can at least finish booting the Pi.
The low-voltage threashold and recovery threshold are for users who power Witty Pi with battery. By setting these two thresholds properly the battery will not be over-discharged and no B.O.D. reset should be triggered.
The B.O.D reset is to protect the data from unexpected power failure, that the device loses power suddently. This should not happen/can be prevented, and the device automatically recover from B.O.D reset should not be considered by Witty Pi either. B.O.D. reset is there to make sure the data in EEPROM will not get damaged in case such disaster happens.
In your case, you can set default power OFF, and set under-voltage and recovery thresholds accordingly. So if B.O.D reset happens, the device will not startup until the battery voltage exceed the recovery threshold.
When the B.O.D reset happens, the MCU is powered with lowever than 2.7V -- how can you let a 7.4V battery to over-discharge to such level?
the system may also potentially never wake up again because the low-voltage shutdown was not triggered.
This is not ture. You can check the conditions for recovery here: https://github.com/uugear/Witty-Pi-4/blob/main/Firmware/WittyPi4/WittyPi4.ino#L373-L375
If low-voltage threshold is not configured, it doesn't require the low-voltage shutdown was triggered beforehand.
When low-voltage threshold and recovery threshold are both configured, you can still set I2C_CONF_IGNORE_LV_SHUTDOWN to 1 to make sure the recovery will take place when voltage is high enough.
Thank you very much for this clarification - this clears up alot of my questions! 😀
The only reason why I originally turned the "default power On" option on on all my cameras is because I used a different system (a Witty Pi 4 mini with an external DC/DC converter and the battery voltage connected to Vin) and it wouldn't always restart after a power disconnect so I assumed it was necessary. As I've seen now in the source code you sent, the startup only seems to be triggered when the power is connected via the DC input, which I do with the Witty Pi 4, so the "default Power mode" is not required anymore. So my whole feature request/assumptions obviously don't make any sense with that knowledge - sorry!
When the B.O.D reset happens, the MCU is powered with lowever than 2.7V -- how can you let a 7.4V battery to over-discharge to such level?
Well obviously the battery voltage itself does not go below anywhere near 2.7 V, but a brownout was the only plausible Idea I had for this behaviour of the system (not turning on again after a very low battery charge). My assumption was that because of the low battery charge and the system running, the MCU didn't get enough, but still a little bit of power (similar to the old MCU power supply/capacitor issue). But I'm not really an electronics expert, so it could also be something else.
When low-voltage threshold and recovery threshold are both configured, you can still set I2C_CONF_IGNORE_LV_SHUTDOWN to 1 to make sure the recovery will take place when voltage is high enough.
Sorry, I dont completely understand this. Wouldn't the system continually reboot if the voltage is high enough since the I2C_CONF_IGNORE_LV_SHUTDOWN, and the I2C_POWER_MODE are both 1 and I have set a recovery voltage? Or do I have to set it back to 0, after booting up the raspberry pi - so it would force the system to restart once when the voltage is high enough after a complete power loss? 🙂
@eagleshot if low-voltage threshod (I2C_CONF_LOW_VOLTAGE) is configured, the firmware does expect a low-voltage shutdown before peforming the recovery. This is not convinient for some use cases, so we provide I2C_CONF_IGNORE_LV_SHUTDOWN to override this behavior. Once I2C_CONF_IGNORE_LV_SHUTDOWN is set to 1, the recovery will always take palce when input voltage is higher than recovery threshold. In your case you can just set I2C_CONF_IGNORE_LV_SHUTDOWN to 1 and then forget it.