I wanted to check the status lights and, more importantly, shade levels on the solar panels during test 5. Doing so required some python coding, generating an SSH key, a 3D Printed camera arm, an extra long camera cord, and a Pi Camera v2.1.
This post will show you how to update recorduptime.py to take a photo and upload that photo and update uptime every 30 min. Also, because I am on WiFi and bandwidth is free, I will be uploading the photos twice. The first photo file will have a timestamp. The other will overwrite the existing file on the server. This way, it’s easier to view the photos. Later the photos can be used to make a time-lapse. Maybe I will get fancy and have a PHP script that will make the time-lapse for us.
The program also uses SCP to upload the files to Mission Control, because of that there is a little bit of setup involved to get the trust working between the two.
- Get the stuff from where ever you want.
- Enable the Pi Camera interface on the Rover Pi Zero by starting the Raspberry Pi Software Configuration Tool (raspi-config)
sudo raspi-config
Scroll down to Interfacing Options and press enter Press enter for Pi Camera Left Arrow for Yes and enter Enter again for OK Tab Twice and enter twice to exit Raspberry Pi Software Configuration Tool (raspi-config) Note: your Pi may reboot.
- Time to generate our SSH Key and login into MissionControl without a password.
ssh-keygen is used to generate your public key, once generated we will install that key on Misson Controlssh-keygen
Press Enter for the location and the passwords
- Now that we have a key, it’s time to copy it to Mission Control.
Note: you will need to change the IP address to your correct IP address.ssh-copy-id pi@172.16.42.99
Enter the password for your pi user on Mission Control.
- Now it’s time to test it.
ssh 'pi@172.16.42.99'
You should be logged right in without using a password.
Exit
Exit will disconnect you from mission control. Note: If you are running recorduptime.py at startup, you will need to do steps 3-5 as root.
- Create image folders on Mission Control and on the Rover Pi.
Login to mission control and type:mkdir /var/www/html/images
On the Rover Pi make an images directory in the pi user’s home.
cd mkdir images
- Now we need the picamera module for Python3
sudo apt-get update sudo apt-get upgrade sudo apt-get install python3-picamera
- Here is the updated recorduptime.py
from picamera import PiCamera import urllib.request import socket import os import time import datetime camera = PiCamera() camera.resolution = (2592, 1944) gw = os.popen("ip -4 route show default").read().split() s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect((gw[2], 0)) ipaddr = s.getsockname()[0] while True: uptime = os.popen("awk '{print $1}' /proc/uptime").readline() with urllib.request.urlopen('http://172.16.42.99/RecordUptime.php?Hostname='+ socket.gethostname() +'&IP='+ s.getsockname()[0] +'&UpTime='+ uptime) as response: html = response.read() camera.start_preview() time.sleep(2) filename = ('/home/pi/images/' + datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S") + '.jpg') camera.capture(filename) camera.stop_preview() os.system("scp " + filename + " pi@172.16.42.99:/var/www/html/images/") os.system("scp " + filename + " pi@172.16.42.99:/var/www/html/images/image.jpg") time.sleep (1800)
After restarting your Raspberry Pi Zero W, login to Mission Control and check and check the /var/www/html/images folder for images. Once you see image.jpg and one with the timestamp you are ready to start looking at the latest image from your Pi Camera.
https://neo.aeris.com/pricing/
I love the Mojave desert!
We use the Data Plan above with good results.
Let me know if you have a better source.
Thanks,
Mike Fleming
Managing Partner
Magnum Asset Protection, LLC
Thank you for the link, I checked them out and reached out.
At this point, I am not quite ready for a data plan. I need to get Solar charging and driving started. But it is coming together.