Hi,
I'm using a witty pi 4 for a timelapse project.
The Witty Pi was working fine when I started my project.
We've recently added a UPS to manage the charging of the battery by the solar panel, and to keep track of the battery's charge level.
The UPS works well, and I get the values back via the I2C.
However, I've noticed that the Witty Pi no longer switches on my RPi.
In fact, when, via wittyPi.sh, I configure an earlier start-up than the current one, when I switch off the RPi, it restarts automatically, which is the normal behavior.
On the other hand, when, via wittyPi.sh or via a Python script that sends the info to the Witty over the I2C, I set my startup to a later time, when I switch off the RPi (via cli or via the witty button), the Witty never restarts my RPi.
Do you have any idea where the problem might be coming from?
Best regards
In fact, when, via wittyPi.sh, I configure an earlier start-up than the current one, when I switch off the RPi, it restarts automatically, which is the normal behavior.
This is not the normal behavior of Witty Pi 4. Witty Pi 4's alarms are implemented in firmware, and if you check the firmware source code, you will see there is only a 2-second window that allows the MCU to trigger the alarm. If the time passed more than 2 seconds, the alarm will simply be ignored (and hence no startup as scheduled).
However, if you scheduled a startup in a future moment that is very close to the current time, there is chance that the scheduled startup alarm gets triggered when your Pi is still on, in such case Witty Pi 4 will indeed restart your Pi immediately after the shutdown. This is called "alarm 1 delay" in the firmware.
If your Witty Pi 4 doesn't wake up your Pi as scheduled, you can check these facts:
- Is your Witty Pi 4 still gets powered when the startup is suppose to happen? The white LED on Witty Pi 4 should blink if the board is powered.
- Was the startup scheduled at a right time? You can check it in the wittyPi.log file, or via the wittyPi.sh script.
- Did the system have correct time? This can be checked in log file or via the wittyPi.sh script.
Thank's for the details about first part.
I will made some check tomorrow (don't have the device right now), but in my memories, I've setted the scheduled startup to 28 00:30:00 when it was 01:00:00 and it restarted immediately after shutdown.
For the principal problem,
- Yes the white LED blinks continuously when the device is off,
- I've made some different try past night, I always set the scheduled startup after the actual time, via the Python script i made, or via wittyPi.sh, always same problem
- Time was sync a few time with network time
I've checked the 2 last points in wittyPi.log when I was working on it past night, and everything seemed fine, I'll do some test tomorrow morning and I'll upload the result of wittyPi.log.
Hi,
I've started my device this morning, at 10:01,
My python script set the scheduled startup at 12:00,
I've shutdown the device at 03:50pm, and it automatically restarted, there is the log :
[2023-08-29 10:01:28] Firmware ID: 0x26 [2023-08-29 10:01:28] Firmware Revison: 0x01 [2023-08-29 10:01:30] Current Vout=5.16V, Iout=0A [2023-08-29 10:01:32] System starts up because the button is clicked. [2023-08-29 10:01:39] Send out the SYS_UP signal via GPIO-17 pin. [2023-08-29 10:01:40] Pending for incoming shutdown command... [2023-08-29 10:01:45] File "schedule.wpi" not found, skip running schedule script. [xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.13) is started. [xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi Model B Plus Rev 1.2 [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... [2023-08-29 15:51:13] Done :-) [2023-08-29 15:51:13] Firmware ID: 0x26 [2023-08-29 15:51:14] Firmware Revison: 0x01 [2023-08-29 15:51:15] Current Vout=5.16V, Iout=0A [2023-08-29 15:51:18] System starts up because of the scheduled startup got delayed. [2023-08-29 15:51:18] Maybe the scheduled startup was due when Pi was running, or Pi had been shut down but TXD stayed HIGH to prevent the power cut.
My python script has scheduled startup at 16:20,
When I check on wittyPi.sh, it's well scheduled ( 5. Schedule next startup [29 16:20:00] )
And it automatically restarted on shutdown
[xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.13) is started. [xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi Model B Plus Rev 1.2 [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... [2023-08-29 16:03:55] Done :-) [2023-08-29 16:03:55] Firmware ID: 0x26 [2023-08-29 16:03:55] Firmware Revison: 0x01 [2023-08-29 16:03:57] Current Vout=5.16V, Iout=0A [2023-08-29 16:03:57] System starts up because of the scheduled startup got delayed. [2023-08-29 16:03:57] Maybe the scheduled startup was due when Pi was running, or Pi had been shut down but TXD stayed HIGH to prevent the power cut.
At 16:08, I've set schedule startup to 16:15 via wittyPi.sh, (29 16:15:00),
It shutdown well (without restarting), but it doesn't start at 16:15:00,
So I startup it myself, and there is the log :
[xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.13) is started. [xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi Model B Plus Rev 1.2 [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... [2023-08-29 16:17:55] Done :-) [2023-08-29 16:17:55] Firmware ID: 0x26 [2023-08-29 16:17:56] Firmware Revison: 0x01 [2023-08-29 16:17:57] Current Vout=5.16V, Iout=0A [2023-08-29 16:17:59] System starts up because the button is clicked.
Do you need more details to help me?
I also need to know that a raspberry recently died on this device, I don't know why, it was during UPS testing by my customer.
Is it possible that the Witty Pi died at the same time?
Best regards
I've started my device this morning, at 10:01,
My python script set the scheduled startup at 12:00,
I've shutdown the device at 03:50pm, and it automatically restarted
If you want the device to startup at 12:00, you need to make sure the device has been turned off before 12:00, otherwise it is called "startup alarm delayed" and you can see this message in the log:
System starts up because of the scheduled startup got delayed
However in the log I noticed your Witty Pi 4 has firmware revision 0x01. All Witty Pi 4 firmware with revision lower than 0x05 have a bug that may cause incorrect "startup alarm delayed" situation. If you did shutdown the device before the scheduled startup time and yet the device still immediately restarted and said the scheduled startup got delayed, then most probably it was due to this bug. It is recommended to upgrade the firmware to revision 0x05, which you can download here in GitHub. You may follow this document to upgrade the firmware.
If you want to know more about this bug in the firmware, you can read on.
The problem comes from the getTimestamp() function, more specifically from the calculation of "hours * 3600”.
long getTimestamp(byte date, byte hours, byte minutes, byte seconds) { return date * 86400 + hours * 3600 + minutes * 60 + seconds; }
In this function, "date * 86400" has no problem because 86400 is already bigger than 65535 and the compiler automatically treat it as long type, “minutes * 60” has no problem because both numbers and their product are less than 65535. “hours * 3600” however, has both numbers smaller than 65535 while their product may be bigger than 65535. When saving their product into an integer type (2 bytes), the data overflows and we get wrong result. For example, 20 * 3600 will get 6464 instead of 72000.
We thought the only way to get the same “timestamp” for two different moments is to take the same date and time in two different months. However due to the existence of this bug, we can actually get the same “timestamp” for two moments within the same day — as long as the time difference is 18:12:16 (63356 seconds).
Assume the current time is T, alarm 1 time is A1 and alarm 2 time is A2. This bug can only happen when (A1 - 65536) is within the range (T, A2).
This bug has been fixed in Witty Pi 4 firmware revision 0x05.
Hello,
I ordered some DuPont wires and received them yesterday.
I've updated the firmware, and so far it seems to be working fine.
I'm going to run a few tests throughout the day and will report back later this evening.
We were having the same problem for a similar project. I looked and noted we were running firmware revision 0x03, and upgraded, and this got us past the first couple startups. However, it eventually stopped turning back on after about 14 hours. Ours is supposed to turn on every 10 minutes, with python script handling the shutdown. I turned it back on at 08:31 with a button press.
- [2023-09-28 06:30:24] Schedule next startup at: 2023-09-28 06:40:00
[xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.13) is started.
[xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi 4 Model B Rev 1.5
[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...
[2023-09-28 06:40:19] Done 🙂
[2023-09-28 06:40:19] Firmware ID: 0x26
[2023-09-28 06:40:19] Firmware Revison: 0x05
[2023-09-28 06:40:19] Current Vout=5.31V, Iout=0.62A
[2023-09-28 06:40:19] System starts up because scheduled startup is due.
[2023-09-28 06:40:24] Send out the SYS_UP signal via GPIO-17 pin.
[2023-09-28 06:40:24] Pending for incoming shutdown command...
[2023-09-28 06:40:24] Skip scheduling next shutdown, which should be done externally.
[2023-09-28 06:40:24] Schedule next startup at: 2023-09-28 06:50:00
[xxxx-xx-xx xx:xx:xx] Witty Pi daemon (v4.13) is started.
[xxxx-xx-xx xx:xx:xx] Running on Raspberry Pi 4 Model B Rev 1.5
[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...
[2023-09-28 08:31:18] Done 🙂
[2023-09-28 08:31:18] Firmware ID: 0x26
[2023-09-28 08:31:18] Firmware Revison: 0x05
[2023-09-28 08:31:18] Current Vout=5.32V, Iout=0.6A
[2023-09-28 08:31:18] System starts up because of the scheduled startup got delayed.
[2023-09-28 08:31:18] Maybe the scheduled startup was due when Pi was running, or Pi had been shut down but TXD stayed HIGH to prevent the power cut.
[2023-09-28 08:31:23] Send out the SYS_UP signal via GPIO-17 pin.
[2023-09-28 08:31:23] Pending for incoming shutdown command...
[2023-09-28 08:31:23] Skip scheduling next shutdown, which should be done externally.
[2023-09-28 08:31:24] Schedule next startup at: 2023-09-28 08:40:00
Please, any insight here would be really appreciated.