Hi, I picked up a zero2go omini rev2 to see if it could work for a project of mine. The behavior goals for me are:
1) would like to have two voltage inputs to the board, one on Input B and one on Input C, where Input B is used as a start signal only, and Input C supplies input power.
2) the board only starts the pi only if Input B is above a configured threshold (say > 5V).
After reading the manual, and reviewing the high level circuit diagram in the manual, I'm unsure if this is possible. I can tell out of the box the system is not built to let me select which input governs the start behavior, instead having the highest voltage of the inputs used. What I couldn't tell is if the power to the Pi is governed through purely electrical circuitry (thus not likely allowing me to pick one input for the start logic), or if the MCU has control over it (and thus hopefully I can change behavior in the firmware to let me pick Input B to control start). I tried looking over the firmware and I'm really not a good programmer, so am uncertain if what I want is possible via modification (though I'm still looking at it).
Is it possible to modify the firmware to gain the behavior above, where power/start-up for the Pi is only triggered/connected based on one of the three voltage inputs compared to the configured threshold?
I forgot one other goal:
3) while system is in off state (Pi is powered down and input voltage B is below threshold) the system draws minimal power from Input C
After staring at the firmware and getting some better understanding it does appear the firmware controls the comparison of input voltages, and the power to the Pi. So with that key piece I think I have some rough ideas on how some of the goals are possible:
1) for shutdown behavior modify loop() so voltage comparison for shutdown is only looking at vb (could just change "float vmax = vb;").
2) for startup behavior modify sleep() so it doesn't care about the button, and only watches vb for startup
not sure I understand how to do 2 yet. I have zero arduino experience. It looks in sleep() there is some interrupt driven behavior with the button that wakes up the cpu, does a voltage check, and starts up only if the voltage comparison is good. I see a sleep_cpu call that I'm guessing is to reduce power draw, and I'm guessing that's broken by the interrupt triggered I'm guessing via the button. I could call the sleep_cpu still, but I'm not sure how then to wake periodically for a voltage check, or if that's even the smartest idea to keep power consumption low. Could the awakening of the cpu be ADC triggered?
Zero2Go's firmware is rather simple (compares to Witty Pi's).
Your ideas are basically correct, and you just need to have things done correctly.
The sleep_cpu() function puts the MCU into sleep mode, for saving energy.
The MCU will be waken up by watchdog timer with a fixed interval. Although the watchdog interrupt routine function does nothing, the wakening will happen for every 1, 2, 4 or 8 seconds (share the setting for blinking LED). The sleep_cpu() function will return in such case, do some checkings, if no action need to be done, it goes back to sleep by calling sleep_cpu() again.
You will need to setup your Arduino IDE for compiling the new firmware. You may read this page for the how-to: https://github.com/uugear/Witty-Pi-3/wiki/How-to-compile-the-firmware It is for Witty Pi 3 but I believe it also works for Zero2Go's firmware.
Considering you are new to Arduino, it is recommended to test your new firmware without attaching Raspberry Pi on it. You can use multimeter to confirm the input and output voltages, make sure the logic is correct before using it with Raspberry Pi.