This Python script facilitates the automated process of capturing an image on a Raspberry Pi, uploading it to a cloud storage in null-space.xyz, and then deleting the image from the local filesystem to manage storage efficiently.
-
Obtain Image URL: Initially, the script contacts an API endpoint provided by null-space.xyz to fetch a URL and necessary fields for securely uploading an image. This request includes an authorization header using an API key.
-
Capture Image: In this step, the script is intended to interface with the Raspberry Pi's camera to capture an image. This function can be replaced with different camera interaction code.
-
Upload Image: With the captured image, the script uploads it using the image URL to the designated upload endpoint.
-
Delete Local Image: The script deletes the image from the Raspberry Pi to clear storage space and keep the system ready for the next operation.
Ensure Python and pip are installed on your Raspberry Pi. Python 3 is recommended.
Install all necessary Python libraries using the provided requirements.txt
:
pip install -r requirements.txt
Insert your API_KEY from the 'Account' page on null-space.xyz at the top of upload.py
The timelapse id is up for you to decide.
crontab -e
# Add this cron job schedule to the file
*/10 4-22 * * * /usr/bin/python3 /home/pi/upload.py
# */10 = every 10 minutes, 4-22 = every hour from 4 AM to 10 PM inclusive, * * * = every day of month, every month, every day