Saving pictures to Dropbox
Finally, we are going to make our first application using the hardware that we built. There will be two parts here: an Arduino sketch and a Python script. The Arduino sketch will be in charge of taking a picture in case motion is detected and call the Python script. The Python script will actually upload the pictures to Temboo every time it is called by the Arduino sketch.
This is the complete Arduino sketch:
// Sketch to upload pictures to Dropbox when motion is detected #include <Bridge.h> #include <Process.h> // Picture process Process picture; // Filename String filename; // Pin int pir_pin = 8; // Path String path = "/mnt/sda1/"; void setup() { // Bridge Bridge.begin(); // Set pin mode pinMode(pir_pin,INPUT); } void loop(void) { if (digitalRead(pir_pin) == true) { // Generate filename with timestamp filename = ""; picture.runShellCommand("date +%s"); while(picture.running()); while (picture.available...