Let's first code the Python script. It starts by including the required libraries from the Temboo Python SDK:
from temboo.core.session import TembooSession from temboo.Library.Dropbox.FilesAndMetadata import UploadFile
with open(str(sys.argv[1]), "rb") as image_file: encoded_string = base64.b64encode(image_file.read())
session = TembooSession('yourTembooName', 'yourTembooApp', 'yourTembooKey')
uploadFileChoreo = UploadFile(session) uploadFileInputs = uploadFileChoreo.new_input_set()
uploadFileInputs.set_AppSecret("appSecret") uploadFileInputs.set_AccessToken("accessToken") uploadFileInputs.set_FileName(str(sys.argv[1])) uploadFileInputs.set_AccessTokenSecret("accessTokenSecret") uploadFileInputs.set_AppKey("appKey") uploadFileInputs.set_FileContents(encoded_string) uploadFileInputs.set_Root("sandbox")
uploadFileResults = uploadFileChoreo.execute_with_results(uploadFileInputs)
https://github.com/openhomeautomation/arduino-yun-camera
We'll now work on the Arduino sketch. The sketch starts by including the required libraries:
#include <Bridge.h> #include <Process.h>
Process picture;
String filename;
int pir_pin = 8;
String path = "/mnt/sda1/";
Bridge.begin();
if (digitalRead(pir_pin) == true) {
filename = ""; picture.runShellCommand("date +%s"); while(picture.running()); while (picture.available()>0) { char c = picture.read(); filename += c; } filename.trim(); filename += ".png";
picture.runShellCommand("fswebcam " + path + filename + " -r 1280x720"); while(picture.running());
picture.runShellCommand("python " + path + "upload_picture.py " + path + filename); while(picture.running());
https://github.com/openhomeautomation/arduino-yun-camera
First, put the Python file at the root of the SD card, and put the SD card back into the Arduino Yun board. Then, upload the Arduino sketch to the Yun. Now, try to trigger the motion sensor, for example by waiving your hand in front of it. You should see that the webcam is being activated shortly after (for example, my webcam has a LED that turns green when it is active).
To check that the project is working correctly, after a while you can check the SD card, you should see that some pictures have been recorded: