Towards the end of the week, Solar Test 16 is starting to be a bit low on power. I started to see that it would check in with two power up during the day and no shutdown. That is a sign that it’s losing power before the M0 is shutting it down. It’s been overcast, raining, and snowing here in Vegas for the last few weeks. Because solar is it’s only means of recharging, not having sunlight seems to be causing an issue. I am impressed it made it 62 days, but it needs to last longer.
I could just go get it from the backyard and charge it. But, I want to see if I can save it. The plan is to modify the software to check in for commands. Just like the real rover will do. The first version of Mission control will send it a shutdown command. The thinking is that if the Pi is not running during the day, maybe the battery can catch up with charging. The M0 should start the Pi back up in the morning.
Today’s plan.
- Build a web service in mission control that gives the rover (solar test) a command to stay awake or to shut down for the day.
- Update the monitoring program, the one that sends a photo hourly, to check for what command to do. In this case “Stay running” or “Shutdown”
- Bonus goal: Display the current rover status on the mission control 7″ touchscreen.
Mission Control Code:
<?php // Set the content type header to application/json header('Content-Type: application/json'); // Define your data as an associative array $data = [ 'Power' => 'ShutDownForDay' ]; // Encode the data as JSON $json = json_encode($data); // Return the JSON data echo $json;
Addition to rover python program:
import requests import json import subprocess from picamera2 import Picamera2, Preview import time import datetime import os time.sleep (480) url = "http://172.16.40.84/StatusCheck.php" response = requests.get(url) if response.status_code == 200: data = response.json() print (data["Power"]) if data["Power"] == "ShutDownForDay": print ("Shutting down for the day") subprocess.call(['sudo', 'shutdown']) picam2 = Picamera2() camera_config = picam2.create_still_configuration(main={"size": (3280,2464)}) picam2.configure(camera_config) while True: picam2.start() time.sleep(2) filename = ('/home/bill/images/' + datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") + '.jpg') picam2.capture_file(filename) picam2.stop() os.system("scp " + filename + " bill@172.16.40.84:/var/www/html/images/SolarTest16/") #Record thumbnail image. #os.system("scp " + filename + " bill@172.16.40.84:/home/bill/images/image.jpg") time.sleep (1800)
The plan is to shut down the Pi for a few days to let the battery charging catch up.