Let's try to address one problem at a time ...
I can manually schedule a shutdown to take place after a minute or two in the UWI ...
I don't know what WittyPy L3v7 exactly does at the designated time, but after a number of seconds the green LED on the Pi Zero 2 board just goes off. That is not how a Pi is supposed to behave at shutdown. The green LED should blink 10 times to show the shutdown has completed. I could check the SD card for the 'dirty bit', but I haven't yet.
Power cut delay is set at maximum of 25 seconds.
And just because UWI is what I use for scheduling the shutdown as a test, I must add as a second point that every time the Pi starts up again, UWI is not running, not accessible. I have to run the diagnose script every time before I can open that HTML page again. So the UWI server doesn't start by itself ...
(uwi.conf has the correct IP. If I change IP to hostname, diagnose.sh will change it back to the IP address.)
I am using a 3000 mAh LiPo battery just because I read that the MCU might crash if the battery voltage drops too fast. Maybe the MCU doesn't crash now, but it does NOT detect Low Voltage either on this Pi Zero/WittyPi if I pull the power supply (official Raspberry PS). The Pi doesn't shut down when on battery only even though the Low Voltage setting is 4.2 V, or whatever lower value I tried. The DC voltage keeps falling below the limit and nothing happens. I didn't want to wait until the Li-battery is totally depleted.
BTW, I have nice and positive comparison material:
A Pi4B with an SSD and a WittyPi L3v7 on the very same table. Same settings. It shuts down when I pull the plug, power is removed from the Pi after shutdown is completed and when I restore AC power the Pi starts up after the delay set in the wittypi settings. All 'according to the book'. It has a similar battery, but uses more current as a Pi4B with an external SSD. This one is currently doing PiHole DNS, with Unbound and Chrony NTP server and client (cron re-enables chrony 15 seconds after @reboot ...)
The PiZero runs 32 bit bookworm without desktop. Access by SSH.
The Pi4B 64 bit bookworm with desktop (occasionally I use realVNC to access this one).
Ps. both root and boot partitions of the PiZero SD card were 'dirty' after the scheduled shutdown ...
@arjenr Your description already mentioned 3 different issues:
1. Ungranceful shutdown/direct power cut: the green LED didn't blink 10 times already indicates it was not a graceful shutdown, which means the "sudo shutdown -h now" was not executed. The firmware wants to shutdown the Pi and it pulls down GPIO-4 for a short moment, the daemon.sh should catch this pull-down event and execute the shutdown comand. It didn't. The possible reason coud be unreliable connection on GPIO-4, GPIO-4 pin is faulty, wiringPi was not correctly installed etc. After reboot you may run "gpio readall" and check if all GPIOs are in correct state.
2. UWI not auto start/not accessible: if you are sure the IP address in uwi.conf is correct (diagnose script doesn't change the IP value), then you need to check the system log and see why this registered service didn't start. Maybe you can try reinstall UWI if the sevice was disabled unintentionally. A more commonly seen problem is the IP address of Pi actually changes and the UWI server was initialized with an incorrect IP address. BTW, since you are still debugging things, it is not recommended to use UWI. Using the wittyPi.sh script is better for this purpose.
3. Low voltag threshold doesn't work: maybe don't need to mention but I want to remind that you need to connect 3.7V Li-Po battery (not a power bank that has 3.7V battery inside) to Witty Pi 4 L3V7 to make use of the low voltage threshold. If you connect a power bank to USB-C 5V connector, its voltage will not be monitored. Even if you have a 3.7V battery connected at the same time, its voltage will not be monitored as well: it will be charged, but the device is using the USB 5V as power source, not the battery.
You're on the right track, I am ashamed to admit.
I remember finding the header pins strangely hard to solder on the PiZero 2, when I got it last week. I wondered if it is the solder - from China - or the iron - a miniature Sequre and later a Weller - and I also tried to use soldering paste (for SMD electronics!). I wondered if it is the pins or the holes or what ... At least one pin looks suspicious, poorly soldered. I have done a lot more than one Pi Zero header soldering ...
All Pi4B's come with the headers soldered on already, and it works perfectly with the WittyPi.
I'd say beware of Pi Zero's as it will mostly be the client that has had to solder the header him- or herself...
Having now had a close look at my soldering work on the Pi Zero2 I should to be ashamed of it. I'll redo it.
(I once built an Elecraft amateur radio shortwave transceiver ( https://elecraft.com/products/k2-the-classic-hf-transceiver-full-kit) with probably more than a thousand parts to be soldered. Two weeks of diligence and it was done. Worked right away, so yes, I can solder ... That was with excellent Philips solder wire, which I later gave away with all the rest, when we moved to a small apartment ...)
I'll follow up with the outcome after I am done.
It was not in the soldering work, since it still doesn't work after carefully redoing them all.
Using gpio readall, I could see GPIO-17 going HIGH to 1 when I press the wittypi button. The white LED goes on and off again. Nothing else happens. Pi keeps running.
Before pressing, when the Pi is running normally, GPIO-4 is HIGH and GPIO-17 is LOW. Both are inputs.
I can shut the Pi down by the shutdown command in the terminal, of course. After that I will have to press the button long to make the red LED go off, because the power is not cut. The green LED flashes 10 times, but both wittypi green and red LED stay on.
Cutting AC Power makes the witty pi's green led go off, but when I reconnect AC power, the Pi won't start up. Just the charging LED comes on, not even the green one.
A normal press of the button makes the white one come on for a few seconds, but nothing else happens.
After a long press the red one goes off, the green one comes on and then if I press another time, the Pi will start up.
I read about the long press in a forum message I think. I assume it resets the MCU.
It looks to me that there's something really amiss with the GPIO inputs. Some days ago on that Pi I used an RTC module designed for Rpi according to the printed text on the board. It is not only connected to 3,3 V, but also to 5 V from the header and uses the same GPIO pins. It could be responsible for destroying an input ...
I suppose I'll have to buy a NEW Pi Zero 2 W, but this time I'll buy one with a header already soldered to avoid more problems. They seem to be available now.
(It took me a while to find out what pins (in readall output) are meant with what. The numbering is terribly messy. WiringPi was abandoned by its maker and supposed to gradually go away, but now it's back and the numbering mess continues to haunt unsuspecting users. I used BCM numbering here, like WittyPI docs, even though WittyPi uses WiringPi, which I know to use different numbering as can be seen also in the readall output table.)
2. UWI not auto start/not accessible: if you are sure the IP address in uwi.conf is correct (diagnose script doesn't change the IP value), then you need to check the system log and see why this registered service didn't start. Maybe you can try reinstall UWI if the sevice was disabled unintentionally. A more commonly seen problem is the IP address of Pi actually changes and the UWI server was initialized with an incorrect IP address. BTW, since you are still debugging things, it is not recommended to use UWI. Using the wittyPi.sh script is better for this purpose.
The uwi service seemed to be disabled, although systemctl status uwi didn't show enabled or disabled. The status output looked strange to me. Different from what I am used to see when I check a service's status.
After enabling (sudo systemctl enable uwi) it I restarted the Pi Zero and sure enough the uwi service was OK. I have no idea why it was disabled. I did remove the WittyPi board earlier and uninstalled the software as per the instructions at 5.3 in the manual. Later I reinstalled the software because I put the wittypi L3v7 back on. Maybe the uwi.service being apparently disabled was a leftover from removing the UWI software.
The uwi.log shows that after rebooting, the first attempt to start uwi service always fails. Perhaps that's normal.
pi@PiHole3:~ $ sudo systemctl status uwi.service ● uwi.service - LSB: UUGear Web Interface initialize script Loaded: loaded (/etc/init.d/uwi; generated) Active: active (running) since Sun 2024-09-22 00:12:35 CEST; 19min ago Docs: man:systemd-sysv-generator(8) Tasks: 7 (limit: 494) CPU: 11min 29.993s CGroup: /system.slice/uwi.service ├─777 /home/pi/uwi/websocketd --address=192.168.1.63 --port=8000 --staticdir=/home/pi/uwi /home/pi/uwi/messa> └─789 /bin/bash /home/pi/uwi/messanger.sh sep 22 00:12:34 PiHole3 systemd[1]: Starting uwi.service - LSB: UUGear Web Interface initialize script... sep 22 00:12:35 PiHole3 uwi[409]: Starting UWI server... sep 22 00:12:35 PiHole3 systemd[1]: Started uwi.service - LSB: UUGear Web Interface initialize script. pi@PiHole3:~ $ cat uwi/uwi.log Running command: /home/pi/uwi/websocketd --address=192.168.1.63 --port=8000 --staticdir=/home/pi/uwi /home/pi/uwi/messanger.sh Sun, 22 Sep 2024 00:12:35 +0200 | INFO | server | | Serving using application : /home/pi/uwi/messanger.sh Sun, 22 Sep 2024 00:12:35 +0200 | INFO | server | | Serving static content from : /home/pi/uwi Sun, 22 Sep 2024 00:12:35 +0200 | INFO | server | | Starting WebSocket server : ws://192.168.1.63:8000/ Sun, 22 Sep 2024 00:12:35 +0200 | INFO | server | | Serving CGI or static files : http://192.168.1.63:8000/ Sun, 22 Sep 2024 00:12:35 +0200 | FATAL | server | | Can't start server: listen tcp 192.168.1.63:8000: bind: cannot assign requested address UWI server started failed, try again... Running command: /home/pi/uwi/websocketd --address=192.168.1.63 --port=8000 --staticdir=/home/pi/uwi /home/pi/uwi/messanger.sh Sun, 22 Sep 2024 00:12:40 +0200 | INFO | server | | Serving using application : /home/pi/uwi/messanger.sh Sun, 22 Sep 2024 00:12:40 +0200 | INFO | server | | Serving static content from : /home/pi/uwi Sun, 22 Sep 2024 00:12:40 +0200 | INFO | server | | Starting WebSocket server : ws://192.168.1.63:8000/ Sun, 22 Sep 2024 00:12:40 +0200 | INFO | server | | Serving CGI or static files : http://192.168.1.63:8000/ Sun, 22 Sep 2024 00:12:59 +0200 | ACCESS | session | url:'http://192.168.1.63:8000/' id:'1726956779674834785' remote:'192.168.1.2' command:'/home/pi/uwi/messanger.sh' origin:'http://192.168.1.63:8000' | CONNECT UWI server is started with pid=777 pi@PiHole3:~ $
Of course next I started wondering if there's a wittypi service and what is its status. I have the one Pi4B also with a WittyPi L3V7, which runs fine as far as I can see. So it's easy to compare.
First the status of wittypi service on the good machine:
pi@PiHole2:~ $ sudo systemctl status wittypi ● wittypi.service - LSB: Witty Pi 4 initialize script Loaded: loaded (/etc/init.d/wittypi; generated) Active: active (running) since Sun 2024-08-25 19:35:45 CEST; 3 weeks 6 days ago Docs: man:systemd-sysv-generator(8) Tasks: 3 (limit: 446) CPU: 809ms CGroup: /system.slice/wittypi.service ├─ 531 /bin/bash /home/pi/wittypi/daemon.sh └─1545 gpio -g wfi 4 falling aug 25 19:35:49 PiHole2 sudo[1067]: root : PWD=/ ; USER=root ; COMMAND=/usr/bin/date -s @1726955146 aug 25 19:35:49 PiHole2 sudo[1067]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0) sep 21 23:45:46 PiHole2 sudo[1067]: pam_unix(sudo:session): session closed for user root sep 21 23:45:46 PiHole2 wittypi[531]: Done :-) sep 21 23:45:46 PiHole2 wittypi[531]: Firmware ID: 0x37 sep 21 23:45:46 PiHole2 wittypi[531]: Firmware Revison: 0x07 sep 21 23:45:46 PiHole2 wittypi[531]: Current Vout=5.19V, Iout=0.73A sep 21 23:45:46 PiHole2 wittypi[531]: System starts up because it previously reboot. sep 21 23:45:51 PiHole2 wittypi[531]: Send out the SYS_UP signal via GPIO-17 pin. sep 21 23:45:52 PiHole2 wittypi[531]: Pending for incoming shutdown command... pi@PiHole2:~ $
Looks neat.
Next the end of the wittyPi.log file on the good machine:
... [2024-09-21 12:38:18] Done :-) [2024-09-21 12:38:18] Firmware ID: 0x37 [2024-09-21 12:38:18] Firmware Revison: 0x07 [2024-09-21 12:38:18] Current Vout=5.18V, Iout=0.62A [2024-09-21 12:38:18] System starts up because the button is clicked. [2024-09-21 12:38:23] Send out the SYS_UP signal via GPIO-17 pin. [2024-09-21 12:38:23] Pending for incoming shutdown command... [2024-09-21 12:38:24] File "schedule.wpi" not found, skip running schedule script. [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [xxxx-xx-xx xx:xx:xx] System: Debian GNU/Linux 12 (bookworm), Kernel: Linux 6.6.47+rpt-rpi-v8, Architecture: arm64 [xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi 4 Model B Rev 1.5 [xxxx-xx-xx xx:xx:xx] RTC offset register has value 0x75 [xxxx-xx-xx xx:xx:xx] Seems RTC has good time, write RTC time into system [xxxx-xx-xx xx:xx:xx] Writing RTC time to system... [2024-09-21 23:45:46] Done :-) [2024-09-21 23:45:46] Firmware ID: 0x37 [2024-09-21 23:45:46] Firmware Revison: 0x07 [2024-09-21 23:45:46] Current Vout=5.19V, Iout=0.73A [2024-09-21 23:45:46] System starts up because it previously reboot. [2024-09-21 23:45:51] Send out the SYS_UP signal via GPIO-17 pin. [2024-09-21 23:45:52] Pending for incoming shutdown command... [2024-09-21 23:45:52] File "schedule.wpi" not found, skip running schedule script. pi@PiHole2:~ $
Looks good to me, too.
Then the same stuff from the PiZero with WittyPi L3v7 board, which has been causing trouble.
The enabling attempt before rebooting:
pi@PiHole3:~ $ sudo systemctl status wittypi ○ wittypi.service - LSB: Witty Pi 4 initialize script Loaded: loaded (/etc/init.d/wittypi; generated) Active: inactive (dead) Docs: man:systemd-sysv-generator(8) pi@PiHole3:~ $ sudo systemctl enable wittypi wittypi.service is not a native service, redirecting to systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable wittypi pi@PiHole3:~ $ sudo systemctl status wittypi ○ wittypi.service - LSB: Witty Pi 4 initialize script Loaded: loaded (/etc/init.d/wittypi; generated) Active: inactive (dead) Docs: man:systemd-sysv-generator(8) pi@PiHole3:~ $
The service remains dead.
Next I rebooted this Pi Zero 2.
pi@PiHole3:~ $ sudo reboot Broadcast message from root@PiHole3 on pts/1 (Sun 2024-09-22 00:43:33 CEST): The system will reboot now! pi@PiHole3:~ $ Connection to pihole3.mdnet closed by remote host. Connection to pihole3.mdnet closed. arjen@NUC10i5:~$ ping pihole3.mdnet ... arjen@NUC10i5:~$ ssh -o VisualHostKey=yes pi@pihole3.mdnet ... Linux PiHole3 6.6.47+rpt-rpi-v7 #1 SMP Raspbian 1:6.6.47-1+rpt1 (2024-09-02) armv7l ... Last login: Sun Sep 22 00:14:53 2024 from 192.168.1.2 pi@PiHole3:~ $ cat wittypi/wittyPi.log
After enabling the wittypi service and rebooting:
[xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [xxxx-xx-xx xx:xx:xx] System: Raspbian GNU/Linux 12 (bookworm), Kernel: Linux 6.6.47+rpt-rpi-v7, Architecture: armhf [xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi Zero 2 W Rev 1.0 [xxxx-xx-xx xx:xx:xx] RTC offset register has value 0x77 [xxxx-xx-xx xx:xx:xx] Seems RTC has good time, write RTC time into system [xxxx-xx-xx xx:xx:xx] Writing RTC time to system... [2024-09-15 23:42:44] Done :-) [2024-09-15 23:42:44] Firmware ID: 0x37 [2024-09-15 23:42:44] Firmware Revison: 0x07 [2024-09-15 23:42:44] Current Vout=5.25V, Iout=0.64A [2024-09-15 23:42:44] System starts up because it previously reboot. [2024-09-15 23:42:49] Send out the SYS_UP signal via GPIO-17 pin. [2024-09-15 23:42:49] File "schedule.wpi" not found, skip running schedule script. [2024-09-15 23:42:49] Pending for incoming shutdown command... [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [xxxx-xx-xx xx:xx:xx] System: Raspbian GNU/Linux 12 (bookworm), Kernel: Linux 6.6.47+rpt-rpi-v7, Architecture: armhf [xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi Zero 2 W Rev 1.0 [xxxx-xx-xx xx:xx:xx] RTC offset register has value 0x77 [xxxx-xx-xx xx:xx:xx] Seems RTC has good time, write RTC time into system [xxxx-xx-xx xx:xx:xx] Writing RTC time to system... [2024-09-16 00:40:32] Done :-) [2024-09-16 00:40:32] Firmware ID: 0x37 [2024-09-16 00:40:32] Firmware Revison: 0x07 [2024-09-16 00:40:32] Current Vout=5.19V, Iout=0.55A [2024-09-16 00:40:32] System starts up because it previously reboot. [2024-09-16 00:40:37] Send out the SYS_UP signal via GPIO-17 pin. [2024-09-16 00:40:37] File "schedule.wpi" not found, skip running schedule script. [2024-09-16 00:40:37] Pending for incoming shutdown command... [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [2024-09-18 14:12:32] White LED duration set to 50! [2024-09-18 15:44:33] Power cut delay set to 15 seconds! [2024-09-18 22:20:02] Set to "Default ON"! [2024-09-18 22:20:26] Low voltage threshold set to 4.2V! [2024-09-18 22:22:18] Clearing low voltage threshold... [2024-09-18 22:22:18] done :-) [2024-09-18 22:22:44] Clearing recovery voltage threshold... [2024-09-18 22:22:44] done :-) [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [2024-09-20 16:04:17] Copying "on_5m_every_20m.wpi" to "schedule.wpi"... [2024-09-20 16:04:17] Running the script... [2024-09-20 16:04:17] Schedule next shutdown at: 2024-09-20 16:05:00 [2024-09-20 16:04:18] Schedule next startup at: 2024-09-20 16:20:00 [2024-09-20 16:04:18] Done :-) [2024-09-20 16:08:09] Power cut delay set to 25 seconds! [2024-09-20 16:08:30] Copying "on_5m_every_20m.wpi" to "schedule.wpi"... [2024-09-20 16:08:30] Running the script... [2024-09-20 16:08:31] Schedule next shutdown at: 2024-09-20 16:25:00 [2024-09-20 16:08:31] Schedule next startup at: 2024-09-20 16:40:00 [2024-09-20 16:08:32] Done :-) [2024-09-21 15:32:56] Power cut delay set to 10 seconds! [2024-09-21 15:47:39] Power cut delay set to 20 seconds! [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. pi@PiHole3:~ $ sudo systemctl status wittypi ● wittypi.service - LSB: Witty Pi 4 initialize script Loaded: loaded (/etc/init.d/wittypi; generated) Active: active (exited) since Sun 2024-09-22 00:44:05 CEST; 53s ago Docs: man:systemd-sysv-generator(8) CPU: 358ms sep 22 00:44:04 PiHole3 systemd[1]: Starting wittypi.service - LSB: Witty Pi 4 initialize script... sep 22 00:44:04 PiHole3 wittypi[438]: Starting Witty Pi 4 Daemon... sep 22 00:44:04 PiHole3 wittypi[454]: Witty Pi daemon (v4.21) is started.
I took a bit more history from the wittyPi.log, which shows that days ago the log gave a lot more information than it does at the end, when it just informs the user that the daemon started. Nothing about the OS this time. I changed the Power cut delay two times today in the afternoon. True. But there's nothing about a schedule which I set this evening. Shut down was around 19 hrs. and reboot at 21 hrs. after I had come back to this cottage. Those events did happen, IMO, but there's nothing about it in the log. Yesterday's schedule tests were logged. I also rebooted this Pi Zero2 many times on the 21st., but nothing in the log ... Odd.
If I hadn't seen the status output from the other machine and just checked the very end of this log, I might have thought, all hunky dory. The daemon started. Great. But actually there's a lot missing.
OK, more on the PiZero2 ...
I got the wittypi service running finally. I had to stop it first, then start.
pi@PiHole3:~ $ sudo systemctl stop wittypi pi@PiHole3:~ $ sudo systemctl status wittypi ○ wittypi.service - LSB: Witty Pi 4 initialize script Loaded: loaded (/etc/init.d/wittypi; generated) Active: inactive (dead) since Sun 2024-09-22 01:18:05 CEST; 2s ago Duration: 34min 375ms Docs: man:systemd-sysv-generator(8) Process: 30051 ExecStop=/etc/init.d/wittypi stop (code=exited, status=0/SUCCESS) CPU: 14ms sep 22 00:44:04 PiHole3 systemd[1]: Starting wittypi.service - LSB: Witty Pi 4 initialize script... sep 22 00:44:04 PiHole3 wittypi[438]: Starting Witty Pi 4 Daemon... sep 22 00:44:04 PiHole3 wittypi[454]: Witty Pi daemon (v4.21) is started. sep 22 01:18:05 PiHole3 systemd[1]: Stopping wittypi.service - LSB: Witty Pi 4 initialize script... sep 22 01:18:05 PiHole3 wittypi[30051]: Stopping Witty Pi 4 Daemon... sep 22 01:18:05 PiHole3 wittypi[30051]: /etc/init.d/wittypi: regel 25: kill: (549) - Proces bestaat niet sep 22 01:18:05 PiHole3 systemd[1]: wittypi.service: Deactivated successfully. sep 22 01:18:05 PiHole3 systemd[1]: Stopped wittypi.service - LSB: Witty Pi 4 initialize script. pi@PiHole3:~ $ sudo systemctl start wittypi pi@PiHole3:~ $ sudo systemctl status wittypi ● wittypi.service - LSB: Witty Pi 4 initialize script Loaded: loaded (/etc/init.d/wittypi; generated) Active: active (running) since Sun 2024-09-22 01:18:18 CEST; 3s ago Docs: man:systemd-sysv-generator(8) Tasks: 3 (limit: 494) CPU: 403ms CGroup: /system.slice/wittypi.service ├─31285 /bin/bash /home/pi/wittypi/daemon.sh ├─31392 sudo timedatectl set-ntp 0 └─31393 timedatectl set-ntp 0 sep 22 01:18:17 PiHole3 wittypi[31262]: Starting Witty Pi 4 Daemon... sep 22 01:18:17 PiHole3 wittypi[31285]: Witty Pi daemon (v4.21) is started. sep 22 01:18:17 PiHole3 wittypi[31285]: System: Raspbian GNU/Linux 12 (bookworm), Kernel: Linux 6.6.47+rpt-rpi-v7, Archit> sep 22 01:18:17 PiHole3 wittypi[31285]: Running on Raspberry Pi Zero 2 W Rev 1.0 sep 22 01:18:17 PiHole3 wittypi[31285]: RTC offset register has value 0x77 sep 22 01:18:17 PiHole3 wittypi[31285]: Seems RTC has good time, write RTC time into system sep 22 01:18:17 PiHole3 wittypi[31285]: Writing RTC time to system... sep 22 01:18:18 PiHole3 sudo[31392]: root : PWD=/ ; USER=root ; COMMAND=/usr/bin/timedatectl set-ntp 0 sep 22 01:18:18 PiHole3 sudo[31392]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0) sep 22 01:18:18 PiHole3 systemd[1]: Started wittypi.service - LSB: Witty Pi 4 initialize script. pi@PiHole3:~ $
Now checking a short button press ...
[2024-09-21 15:32:56] Power cut delay set to 10 seconds! [2024-09-21 15:47:39] Power cut delay set to 20 seconds! [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [xxxx-xx-xx xx:xx:xx] System: Raspbian GNU/Linux 12 (bookworm), Kernel: Linux 6.6.47+rpt-rpi-v7, Architecture: armhf [xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi Zero 2 W Rev 1.0 [xxxx-xx-xx xx:xx:xx] RTC offset register has value 0x77 [xxxx-xx-xx xx:xx:xx] Seems RTC has good time, write RTC time into system [xxxx-xx-xx xx:xx:xx] Writing RTC time to system... [2024-09-22 01:18:17] Done :-) [2024-09-22 01:18:17] System was previously shut down because of low-voltage. [2024-09-22 01:18:17] Firmware ID: 0x37 [2024-09-22 01:18:17] Firmware Revison: 0x07 [2024-09-22 01:18:17] Current Vout=5.25V, Iout=0.34A [2024-09-22 01:18:17] System starts up because scheduled startup is due. [2024-09-22 01:18:22] Send out the SYS_UP signal via GPIO-17 pin. [2024-09-22 01:18:22] File "schedule.wpi" not found, skip running schedule script. [2024-09-22 01:18:22] Pending for incoming shutdown command... [2024-09-22 01:21:40] Shutting down system because button is clicked or GPIO-4 is pulled down. [2024-09-22 01:21:40] Halting all processes and then shutdown Raspberry Pi... [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. pi@PiHole3:~ $
Looks distinctly better. The shutdown was announced in the terminal and logged in wittyPi.log as well:
[2024-09-21 15:32:56] Power cut delay set to 10 seconds! [2024-09-21 15:47:39] Power cut delay set to 20 seconds! [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. [xxxx-xx-xx xx:xx:xx] System: Raspbian GNU/Linux 12 (bookworm), Kernel: Linux 6.6.47+rpt-rpi-v7, Architecture: armhf [xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi Zero 2 W Rev 1.0 [xxxx-xx-xx xx:xx:xx] RTC offset register has value 0x77 [xxxx-xx-xx xx:xx:xx] Seems RTC has good time, write RTC time into system [xxxx-xx-xx xx:xx:xx] Writing RTC time to system... [2024-09-22 01:18:17] Done :-) [2024-09-22 01:18:17] System was previously shut down because of low-voltage. [2024-09-22 01:18:17] Firmware ID: 0x37 [2024-09-22 01:18:17] Firmware Revison: 0x07 [2024-09-22 01:18:17] Current Vout=5.25V, Iout=0.34A [2024-09-22 01:18:17] System starts up because scheduled startup is due. [2024-09-22 01:18:22] Send out the SYS_UP signal via GPIO-17 pin. [2024-09-22 01:18:22] File "schedule.wpi" not found, skip running schedule script. [2024-09-22 01:18:22] Pending for incoming shutdown command... [2024-09-22 01:21:40] Shutting down system because button is clicked or GPIO-4 is pulled down. [2024-09-22 01:21:40] Halting all processes and then shutdown Raspberry Pi... [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.21) is started. pi@PiHole3:~ $
The Pi did not stay halted after the button press, but restarted right away. It will have something to do with current setting.
Things look a LOT better than until this evening.
Both essential services had become disabled, which I cannot explain ...
As the functioning of GPIO pin 4 was questioned I ordered a new Pi Zero 2 W and with a header soldered on because I started to doubt my soldering skills during this debugging ... It'll end up as a spare. Or I could set it up as the second DNS server on either LAN; some like it like that.
Hopefully the recount of this troubleshooting is useful to some users. How one slowly circumnavigates towards the solution.
One problem left. wittypi service doesn't stay active (running) like on my good Pi4/wittyPi.
I have to stop and start the service after every reboot.
As I have set it, the system should shut down, when AC power goes away and now it does. The Pi also starts up with the set delay.
I have not observed the 10 blinks of the Pi's own green LED. Power to the Pi is cut apparently.
As the wittypi service doesn't stay active (running) after reboot, it will quickly mess things up, I suppose, if you do not realize.
pi@PiHole3:~ $ sudo systemctl stop wittypi pi@PiHole3:~ $ sudo systemctl start wittypi pi@PiHole3:~ $ sudo systemctl status wittypi ● wittypi.service - LSB: Witty Pi 4 initialize script Loaded: loaded (/etc/init.d/wittypi; generated) Active: active (running) since Sun 2024-09-22 01:45:11 CEST; 4s ago Docs: man:systemd-sysv-generator(8) Tasks: 3 (limit: 494) CPU: 442ms CGroup: /system.slice/wittypi.service ├─12171 /bin/bash /home/pi/wittypi/daemon.sh ├─12453 sudo timedatectl set-ntp 0 └─12467 timedatectl set-ntp 0 sep 22 01:45:10 PiHole3 wittypi[12160]: Starting Witty Pi 4 Daemon... sep 22 01:45:10 PiHole3 wittypi[12171]: Witty Pi daemon (v4.21) is started. sep 22 01:45:11 PiHole3 wittypi[12171]: System: Raspbian GNU/Linux 12 (bookworm), Kernel: Linux 6.6.47+rpt-rpi-v7, Archit> sep 22 01:45:11 PiHole3 wittypi[12171]: Running on Raspberry Pi Zero 2 W Rev 1.0 sep 22 01:45:11 PiHole3 wittypi[12171]: RTC offset register has value 0x77 sep 22 01:45:11 PiHole3 wittypi[12171]: Seems RTC has good time, write RTC time into system sep 22 01:45:11 PiHole3 wittypi[12171]: Writing RTC time to system... sep 22 01:45:11 PiHole3 sudo[12453]: root : PWD=/ ; USER=root ; COMMAND=/usr/bin/timedatectl set-ntp 0 sep 22 01:45:11 PiHole3 sudo[12453]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0) sep 22 01:45:11 PiHole3 systemd[1]: Started wittypi.service - LSB: Witty Pi 4 initialize script. pi@PiHole3:~ $ Broadcast message from root@PiHole3 (Sun 2024-09-22 01:45:27 CEST): The system will power off now! Connection to pihole3.mdnet closed by remote host. Connection to pihole3.mdnet closed. arjen@NUC10i5:~$ ping pihole3.mdnet ... arjen@NUC10i5:~$ ssh -o VisualHostKey=yes pi@pihole3.mdnet ... pi@PiHole3:~ $ sudo systemctl status wittypi ● wittypi.service - LSB: Witty Pi 4 initialize script Loaded: loaded (/etc/init.d/wittypi; generated) Active: active (exited) since Sun 2024-09-22 01:17:06 CEST; 19s ago Docs: man:systemd-sysv-generator(8) CPU: 390ms sep 22 01:17:05 PiHole3 systemd[1]: Starting wittypi.service - LSB: Witty Pi 4 initialize script... sep 22 01:17:05 PiHole3 wittypi[429]: Starting Witty Pi 4 Daemon... sep 22 01:17:05 PiHole3 wittypi[445]: Witty Pi daemon (v4.21) is started. pi@PiHole3:~ $
Maybe a power cut delay of 20-25 sec is just not long enough. I never see the 10 blinks, although I supposed the power cut delay only starts counting down after the Pi has halted.
If I issue a manual 'sudo shutdown now' in a terminal, it takes my PiZero close to 25 seconds to actually blink 10 times & halt.
I started from scratch with a clean Raspberry Pi OS image (32-bit bookworm, 'Lite', i.e. no desktop) on another high quality SD card.
First installed WittyPi software and checked the essential WittyPi functions (button stop & start; power loss shutdown & start upon return of 5V USB power), plus the status of services like wittypi, uwi (and later also chrony).
WittyPi settings had apparently been stored in the WittyPi module itself as they came back just as I had had them last before changing the SD card.
Proceeded to first update & upgrade the OS itself. Next I installed chrony (NTP client only for now) and testing the above mentioned essential functions at every phase.
As there's still little extra software installed, booting and most important shutdown is quick. The maximum Power Cut delay of 25 seconds is ample.
On the earlier SD card the following in addition to the above mentioned were installed and in use: PiHole, Unbound, RPI-Clone, rSnapshots, zRAM, Mutt.
zRAM makes log files go to RAM memory in compressed form, but decompresses them and copies them to disk before the Pi can shut down. This probably takes an appreciable amount of time. I haven't timed it separately, though.
WittyPi documentation states that the power cut delay starts running from the shutdown command ... With the previous SD card observations of shutdown times of the 'fully' installed PiHole server suggest that the maximum of 25 seconds may well be too short for a Pi Zero 2 with a extra software. A hard power cut can easily damage files being written at the time, which could have been the cause for the problems I had with the earlier installation/SD card.
I would suggest a higher maximum power cut delay, at least 60 seconds. Another UPS HAT, PiJuice, allows for at least 60 seconds. (there's probably a reason why the power cut delay doesn't start from the moment shutdown has ended)
THE GOOD NEWS: So far it appears that the newly installed Pi Zero 2 with WittyPi 4 L3V7 behaves as it is supposed to, just like its Pi4B sibling which has a comparable amount of software installed and actually operates as the DNS and local NTP server for my LAN. Something along the line must have damaged the previous installation/OS (I did have Gnome Disk utility on my desktop workstation remove the dirty bit many times).