Hi my name is Antonio Anaya, I’m at this moment visiting Guadalajara developing the monitoring and control systems of the MITEF Mexico OpenAg city farm project. I’ll explain the architecture that I used here as the first version the system. I doesn’t know nothing about the official food computers developments but I have some experience with my first projects 3 years ago.
The challenge here consist in deploy a remote controlled system over SSH.
As we don’t have an internet connection available (temporally), I decided to use an android phone as internet access point but also as a time-lapse camera and a local lan wired network.
We can control an android smartphone using Android Developer Bridge and basic linux shell/bash scripting.
So first we need to install the dba and the dependencies. I just made this on raspbian:
sudo apt-get install android-tools-adb
Simultaneously in the hardware aspect, we need to unlock the developer options in our android smartphone simply by accessing the “Settings” menu selecting the “About device” and tapping multiple times the “build number” part. Now we can access the developer options and select USB debugging function, just checking the square.
We should connect the android smartphone by a USB wire connection to the Raspi and wait for the response of the connection and selecting always accept connections by this computer (Raspi).
Now We can use the adb shell console by:
sudo su adb shell
So the sequence of actions to take a photo is this:
input keyevent 26 //awake the screen input keyevent 82 // unlock the screen am start -a android.media.action.IMAGE_CAPTURE //open the camera input keyevent 27 // pulse the take photo button input keyevent 21 //move the cursor to the cancel-save bar input keyevent 22 // move to the save option input keyevent 23 // pulse the save option input keyevent 26 //block and sleep the screen
So we can use this sequence to program our android to take a photo, but in order to do that we’ll use crontab and a bash script in our rapi executed every 5 minutes to create a time lapse.
first the basic script.
#!/bin/bash sleep 3 && adb shell input keyevent 26 && adb shell input keyevent 82 && adb shell am start -a android.media.action.IMAGE_CAPTURE && sleep 3 && adb shell input keyevent 27 && sleep 3 && adb shell input keyevent 21 && sleep 1 && adb shell input keyevent 22 && sleep 1 && adb shell input keyevent 23 && adb shell input keyevent 26
You can write this using nano and saving it as you decided, I named my script “photo.sh”. After save the script we can use crontab in our raspi to manage automatic scripts as demons.
sudo su and
crontab -e We’ll begin the rewrite of our tasks at reboot. At the first time the program will ask for a text editor, after that we’ll be at the list of task programmed on our raspi and add
*/5 * * * 1-7 /<theactualubicationofYOURscript>/photo.sh this means "every 5 minutes of every minute of every our of every day from monday to sunday and saving the changes.
Now we’ll have our usb attached smartphone activated to take photos by our Raspi. I decided to post the photos in twitter so after that I just install the IFTTT applet and made and recipe to twit every new photo in the android.
Results here: https://twitter.com/Pretorian_PF/media
Second part tomorrow.