Issues with Recurring Wakeup
alexjtanner opened this issue · 0 comments
alexjtanner commented
I'm new to using the PiJuice Zero and am trying to get it to wake up the Pi Zero and run a program every day at 0300 UTC. I've been having some issues. Right now, it wakes up the Pi Zero at the correct time, but the program does not run. When I boot up the Pi manually, it works, but when it is booted up by the PiJuice, the program doesn't run. The I2C-1 address is 14, the I2C-2 address is 68, and the EEPROM address is 52.
I'm using cron to start it, using
@reboot /usr/bin/python3 /home/thebeetles/Documents/wakeup_run.py
Here's the code itself:
#!/usr/bin/python3
# This script is started at reboot by cron
from picamera2 import Picamera2, Preview
import time
from gpiozero import LED
from pijuice import PiJuice
import os
# Since the start is very early in the boot sequence we wait for the i2c-1 device
while not os.path.exists('/dev/i2c-1'):
time.sleep(0.1)
pijuice = PiJuice(1, 0x14)
pijuice.rtcAlarm.SetWakeupEnabled(True)
vis = LED(17)
#visible LEDs controlled by pin 17
uv = LED(27)
#UV LEDs controlled by pin 27
picam2 = Picamera2()
camera_config = picam2.create_still_configuration()
#the camera uses the default configuration for still images
picam2.configure(camera_config)
picam2.options["quality"] = 95
#jpeg quality set to maximum
picam2.start()
os.system("sudo mv /home/pi/Pictures/* /media/pi/USBdrive1")
#move the contents of Pictures to the usb
print("photos moved")
for i in range(60):
uv.on()
#UVs are always on while this program runs.
#use appropriate safety measures for UV light.
vis.on()
time.sleep(.001)
#brief delay for flash to turn on
directory = "/home/pi/Pictures/"
title = directory + time.strftime('%b%d%H%M%S%Z') + ".jpg"
#name the picture after the time its taken
print("cheese!")
picam2.capture_file(title)
#picture is taken
time.sleep(0.1)
#flash stays on for a bit
vis.off()
time.sleep(28)
#the approximate time it should take between pictures
vis.off()
uv.off()
os.system("sudo mv /home/pi/Pictures/* /media/pi/USBdrive1")
#move the contents of Pictures to the usb again
print("photos moved")
os.system("sudo umount /dev/sda")
#unmount the usb drive
pijuice.power.SetPowerOff(60)
#remove 5V power to Pi after 60 seconds
os.system("sudo halt")
#Shut down the Pi