The WittyPi is continuously powered by an external DC/DC step-up converter via the +5V/GND 3-pin header. Vin is connected to the 1S Li-ion battery to monitor the current battery voltage and protect against deep discharge by enforcing a low-voltage threshold. If Vin is, say, 3.5V—below the low-voltage threshold of 3.7V—the WittyPi should not wake up the Pi Zero 2W until the solar panel has charged the battery to the recovery voltage (e.g., 3.8V). However, that is not what happens. Startup and shutdown operations continue to execute according to the schedule even when Vin is disconnected (Vin approx. 0.2V) and registers R1 and R2 are set to 0x00 and 0x14, respectively.
Another WittyPi 4 Mini exhibits the same behavior.
What could be the cause of this?
Thanks Bert
The behavior is caused by the firmware's power-mode detection logic.
https://github.com/uugear/Witty-Pi-4/blob/main/Firmware/WittyPi4/WittyPi4.ino#L497
The standard Witty Pi 4 firmware considers VIN values above 5.25V to mean that the board is powered through the DC input. Any VIN value at or below 5.25V is classified as fixed 5V input mode.
A 1S Li-ion voltage such as 3.5V is therefore classified as power mode 0. In this mode, the firmware normally skips low-voltage detection.
https://github.com/uugear/Witty-Pi-4/blob/main/Firmware/WittyPi4/WittyPi4.ino#L406-L413
https://github.com/uugear/Witty-Pi-4/blob/main/Firmware/WittyPi4/WittyPi4.ino#L961-L976
Register 41 (I2C_CONF_IGNORE_POWER_MODE) can be set to 1 to make active low-voltage shutdown ignore the automatically detected power mode. However, this does not fully solve the problem because canTriggerAlarm() does not currently honor register 41 and still allows scheduled startup whenever I2C_POWER_MODE is 0.
https://github.com/uugear/Witty-Pi-4/blob/main/Firmware/WittyPi4/WittyPi4.ino#L824-L826
The standard firmware is not compatible with the Witty Pi 4 Mini + DC/DC boost converter use case. You will need to modify the firmware and flash it into your Witty Pi 4 Mini. A modification like this will work:
boolean canTriggerAlarm() {
if (powerIsOn) {
return true;
}
if (i2cReg[I2C_POWER_MODE] == 0 &&
i2cReg[I2C_CONF_IGNORE_POWER_MODE] == 0) {
return true;
}
...
You will also need to set Register 41 (I2C_CONF_IGNORE_POWER_MODE) to 1.
