User Tools

Site Tools


atmos:citation:instruments:usb_camera_automation:home

In order to have the camera take a picture every minute you need to setup the cron job.

1. Go to the linux terminal and use the command crontab -l to see a list of crontabs currently running.

2. After confirming if any other crons are running you can create one by using the command crontab -e . After this is done you will have to choose the text editor choose vim.

3. Once in the cron tab section scroll to the bottom of the file and click i to enter edit mode. This will be seen at the bottom left corner of the terminal. Then enter the command “* * * * * cd /home/pi/Desktop/pi-camera-latests && ./save-img-usb.sh” to have the camera run every minute. Then exit edit mode by pressing the escape. To save and exit press :wq and press enter. The job is now active and every minute it will take a picture. This job should be tested before deploying to ensure the camera is taking a picture. After testing you can go back into the cron job and use # to comment out the line and save it again so it isn't running while not in the field. When ready to deploy you can simply uncomment the line.

For more information on cron jobs in linux you can look at this link https://www.geeksforgeeks.org/crontab-in-linux-with-examples.

4. Next you will need to get setup the folder you will be sending the data to in AWS. To do this you will need the key added to the pi-camera-latest folder. To get the key talk to Dr. Delene.

Once you have the key you need to place this inside the pi-camera-latest folder.

5. Now you will ssh into the aws instance using the command below *note if your key is different you may need to change the MetTrailer.pem to the corresponding key.

ssh -i MetTrailer.pem ec2-user@ec2-3-89-34-59.compute-1.amazonaws.com

6.Once in the aws instance create a folder using the command mkdir TIMMS-SN00XXX where the XXX corresponds to your serial number.

7. After this is done you need to setup a file that will remove the images from the AWS Server

While in the folder in the terminal use the command vim TIMM-SN00XXX-rm.sh
Then input the below into the file
rm /home/ec2-user/TIMMS-SN00200/202*.jpg

Save the file by exiting insert mode and pressing :wq and pressing enter

8. Now a cron job will need to be created to run the remove action on the AWS Server.

To create a new cron from the terminal in aws input crontab -e

then input the below cron job adjusting for your serial number

*/4 * * * * /home/ec2-user/TIMMS-SN00XXX/TIMM-SN00XXX-rm.sh

Save the cron job by exiting insert mode and inputting :wq

9. Once the AWS folder and cron job are created you will need a folder created in Calgary, the und on site server that holds the images. You may not have access to this so the instructions may be for someone with access that can help you.

This can be done by copy pasting from one of the other tims the download-image.sh file Below is an image with details on what needs to be changed in this file for each new TIMM.

10. Go into the transer-remove.sh file in a text editor on the rasberry pi and edit the location to the newly created one in aws then setup a cron to have this run every 2 minutes.

11. Once you have the crons running with the person who has access to calgary ensure they are getting the images. Once confirmed you can turn these off until its time to deploy.

atmos/citation/instruments/usb_camera_automation/home.txt · Last modified: 2024/03/26 21:35 by 127.0.0.1