Rather than saving the captured image in an SD card, we can automatically upload the image to Flickr. In the next section, we will learn how to do this with Flickr and Temboo cloud service.
Follow these steps to create a Flickr account:
Copy and paste the API Key and Secret into a notepad, if you think it will be easy for your reference later.
That's it for the moment. Later, you have to again visit the Flickr website, so don't sign out from Flickr. To access Flickr services, we have to create a Temboo account and make some configurations.
Temboo provides normalized access to 100+ APIs and databases. It provides code-based, task-specific code components called Choreos that can be used with the Arduino language to simplify the complex tasks such as uploading images to Flickr, sending SMS, sending Twitter tweets, and many more.
Let's look at how to create a new Temboo account, so you can use this account for experimenting with Temboo and Arduino.
Now, we are ready to create our first Choreo. To do this, we need to complete a series of configurations and processing steps with Temboo.
In the top-right of the Temboo web page, click on LIBRARY. The LIBRARY page will appear. Under the CHOREOS pane (listed in the left-hand side of the page) go to Flickr | OAuth by clicking on the down arrow signs, and finally, click on InitializeOAuth.
First, enable IoT Mode, as shown in the following screenshot:
Then, configure the form as shown in the following steps:
The following listing of information is extracted from the preceding output. The information will differ according to your setup.
http://www.flickr.com/services/oauth/authorize?oauth_callback_confirmed=true&oauth_token=7215xxxxxxxxxxxxxxxxxxxxx951&oauth_token_secret=af287xxxxxxxc6b5
3991fb6b-xxxxxxxxxxxxxxx-b83e453d2ec4
af287xxxxxxxc6b5
Finally, you have successfully authorized your app.
Perform the following steps to finalize OAuth:
In this section, you will learn how to generate the photo upload sketch. To achieve this, you need to perform the following steps:
TembooAccount.h
inside the TembooAccount
folder.B04844_04_02.ino
can be copied from the Chapter 4
code folder. Also, modify the API key values according to your Flickr and Temboo accounts.The Arduino sketch for the B04844_04_02.ino
file is:
/* Setup shield-specific #include statements */ #include <SPI.h> #include <Dhcp.h> #include <Dns.h> #include <Ethernet.h> #include <EthernetClient.h> #include <Temboo.h> #include "TembooAccount.h" // Contains Temboo account information byte ethernetMACAddress[] = ETHERNET_SHIELD_MAC; EthernetClient client; int numRuns = 1; // Execution count, so this doesn't run forever int maxRuns = 10; // Maximum number of times the Choreo should be executed void setup() { Serial.begin(9600); // For debugging, wait until the serial console is connected delay(4000); while(!Serial); Serial.print("DHCP:"); if (Ethernet.begin(ethernetMACAddress) == 0) { Serial.println("FAIL"); while(true); } Serial.println("OK"); delay(5000); Serial.println("Setup complete. "); } void loop() { if (numRuns <= maxRuns) { Serial.println("Running Upload - Run #" + String(numRuns++)); TembooChoreo UploadChoreo(client); // Invoke the Temboo client UploadChoreo.begin(); // Set Temboo account credentials UploadChoreo.setAccountName(TEMBOO_ACCOUNT); UploadChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); UploadChoreo.setAppKey(TEMBOO_APP_KEY); // Set Choreo inputs String APIKeyValue = "0c62beaaxxxxxxxxxxxxxxxe3845ca"; UploadChoreo.addInput("APIKey", APIKeyValue); String AccessTokenValue = "7215xxxxxxxxxxxxxxxxxxxxxx7b8e01"; UploadChoreo.addInput("AccessToken", AccessTokenValue); String AccessTokenSecretValue = "d95exxxxxxxfddb7"; UploadChoreo.addInput("AccessTokenSecret", AccessTokenSecretValue); String APISecretValue = "7277dxxxxxxxx7d696"; UploadChoreo.addInput("APISecret", APISecretValue); String URLValue = "https://www.arduino.cc/en/uploads/Main/ArduinoEthernetFront450px.jpg"; UploadChoreo.addInput("URL", URLValue); // Identify the Choreo to run UploadChoreo.setChoreo("/Library/Flickr/Photos/Upload"); // Run the Choreo; when results are available, print them to serial UploadChoreo.run(); while(UploadChoreo.available()) { char c = UploadChoreo.read(); Serial.print(c); } UploadChoreo.close(); } Serial.println(" Waiting... "); delay(30000); // wait 30 seconds between Upload calls }
In the previous step, we successfully uploaded an image, which is in a remote server, on Flickr. Now, we are going to upload an image on Flickr, which is captured by the camera.
To do this, first we need to convert the image binary data stream to the base 64 stream.
Download the base64.h
library from https://github.com/adamvr/arduino-base64 and extract it inside to the Libraries
folder.
Copy and paste the B04844_04_03.ino
code from the sketches folder of this chapter and upload it on your Arduino board.
For every 30 seconds, your camera will capture an image and upload on Flickr.
Adafruit TTL serial camera has built-in motion detection capability. Using the VC0706 library, we can capture and upload the detected image to the Flickr. Here, we have used more similar code implementation as explained in the previous section of Motion Detection.
B04844_04_04.ino
from the Chapter 4
code folder. Verify and upload the code on your Arduino board.Let's look at some important points in motion detection that are related to the Arduino sketch.
To enable the motion detection functionality on the VC0706 Camera module, you can use the following code line and set the parameter to true
. The default is false
. Note that the cam
is the object of the VC0706
class.
cam.setMotionDetect(true);
The motion is detected by the following function and it will return true
when the motion is detected by the camera module.
cam.motionDetected();
18.118.163.158