Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Recurring Wakeup #1084

Open
alexjtanner opened this issue Jun 11, 2024 · 0 comments
Open

Issues with Recurring Wakeup #1084

alexjtanner opened this issue Jun 11, 2024 · 0 comments

Comments

@alexjtanner
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant