Skip to content

software-trizzey/simple_auto_camera_raspberrypi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Simple Automated Raspberry Pi Camera

Raspberry Pi Demo

Overview

Simple rust program that captures images on a Raspberry Pi.

Running program

Note: This was tested using a Raspberry Pi 4 Model B Rev 1.4 and Ardu Camera

  1. Clone repo to Raspberry Pi git clone https://github.com/software-trizzey/simple_auto_camera_raspberrypi.git
  2. Navigate to project cd simple_auto_camera_raspberrypi
  3. Build program cargo build --release
  4. Run production version ./release/simple_auto_camera_raspberrypi.bin

Assuming the camera is set up correctly and no errors are encountered, a new image should appear in the static directory.

Transfer images from Raspberry Pi to the host machine via ssh

Run command below on host machine:

scp -r  [pi_username]@[raspberrypi_ip_address]:[path_to_program_on_pi]/simple_auto_camera_raspberrypi/static [directory_on_host_machine]

Example:

scp -r  pi@[ip-address-redacted]:/home/pi/Projects/simple_auto_camera_raspberrypi/static ~/Desktop/pi-images/

Automating the camera via Systemctl

Note: This will run the program every 30 minutes. Adjust the OnCalendar value (ex. OnCalendar=hourly or every minute: OnCalendar=*:0/1) in the timer file for a different interval.

  1. Build the Rust Program
cargo build --release
sudo cp target/release/simple_auto_camera_raspberrypi /usr/local/bin/simple_auto_camera_raspberrypi
  1. Create the Service File
sudo nano /etc/systemd/system/run_camera.service

File Content:

[Unit]
Description=Run Raspberry Pi Camera
After=network.target

[Service]
ExecStart=/usr/local/bin/simple_auto_camera_raspberrypi
Restart=on-failure
Environment="DISCORD_URL=<your_discord_server_url"
WorkingDirectory=/home/pi/Projects/simple_auto_camera_raspberrypi

[Install]
WantedBy=multi-user.target
  1. Create the Timer File
sudo nano /etc/systemd/system/run_camera.timer

File Content:

[Unit]
Description=Run Raspberry Pi Camera Every 30 minutes

[Timer]
OnCalendar=*:0/30
Persistent=true

[Install]
WantedBy=timers.target
  1. Start and Enable the Timer
sudo systemctl daemon-reload
sudo systemctl enable run_camera.timer
sudo systemctl start run_camera.timer

Note: You can manully test the service using sudo systemctl start run_camera.service

  1. Verify the Timer
systemctl list-timers --all
  1. Check Service Logs
journalctl -u run_camera.service

References:

  • This project provides an API for our program to interact with the raspberry pi camera.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages