[Solved] WittyPI4 More flexibility in low voltage threshold?
Hello we are using the excellent WittyPi4 HAT in combination with our own developed HAT and the RaspberryPI4B.
Sometimes we want to use a 12V battery as power supply and taking advantage of the WittyPI4 functionality of having a flexible DC-Converter. To ensure that we do not deplete the battery too much and potentially damage it while doing so, we want to take advantage of the low threshold guard the WittyPI4 provides. But we noticed that the input voltage either because of spikes in the RaspberryPI4B or our own HAT causes the battery input voltage to sometimes drop by up to 0.2V for a very short time period (couple of milliseconds). Unfortunately this short spike seems to always trigger the low voltage threshold immediately and powers off the system.
So we wonder if there is a way to have more flexiblity in when the low voltage threshold is triggered (for example if the voltage drops below the threshold for a substantial period (e.g 1 second)). We checked the manual but couldn't find anything in that direction!
If physcially prevent (or smooth) such spikes is not feasible to you, the only remaining option is to modify the firmware because there is currently no such an option implemented.
You will need to look into the processLowVoltageIfNeeded() function: https://github.com/uugear/Witty-Pi-4/blob/main/Firmware/WittyPi4/WittyPi4.ino#L908-L924
This function gets called every second, so you may use a counter to count how many times the voltage drops under the threshold, and only do the shutdown when the counter exceed a certain value.
Be reminded that the current firmware has almost used up the program space of ATtiny841, it may not be that easy to add a lot of logic into it.
Thank you for your answer we managed to physically solve it in the end