text.skipToContent text.skipToNavigation

Yun Shield Dropbox Webcam

This isn’t a complicated project to build- there isn’t any soldering, but if you haven’t worked with a Linux based system before, you’re about to. The Yun Shield is effectively a small Linux based computer with WiFi, Ethernet and USB. By connecting it to an Arduino board like the Leonardo, we can get the Leonardo to tell it to take photos and upload them to Dropbox. Of course, to do this, you’ll need to set up a Dropbox account at www.dropbox.com, which is free to do, and of course, a webcam. We used our QC3203- other models might work, but have not been tested.


Yun Shield Dropbox Webcam.zip Project Folder

Shopping List:

XC4430 Leonardo
XC4388 Yun Shield

If you don’t have a webcam already:
QC3203 720p USB Webcam


A lot of the following section will be specific to your Dropbox setup, and some items (such as the AUTHTOKEN) will be unique. If you have not already done so, set up a Dropbox account and log in. What we are going to create is called an ‘App’, but it’s really just a specific folder that a project can access. Go to:


You will be prompted to log in if you are not already. Click Dropbox API:

Then App folder access:

And enter an App folder name (it says app name, but this will also be the name of folder) and click create app:

On the next page, there will be a button labelled ‘Generate Access Token’. This will give us our AUTHTOKEN when pressed:

Copy and save the generated token, but do not leave it where anyone else can see it, as this gives them full access to the App folder. You can also generate a token from the developers upload page by selecting your App name and clicking generate token.

The token is pasted into the Arduino sketch, so that the Leonardo can command the Yun Shield to upload the image to Dropbox. In the sample command below, you will also need to substitute the actual token into the placeholder.


The very first step, and about the only assembly needed, is to plug the Yun Shield into the Leonardo board, and connect the Leonardo to a computer via USB for power. We like using the Yun Shield with the Leonardo because the hardware serial port is separate to the USB serial port (unlike the Uno and Mega). Actually, a Yun Shield plus Leonardo is equivalent to the official Arduino Yun board. The following assumes you haven’t set up your Yun Shield at all. If you have trouble with setup, you can reset the Yun Shield to factory settings by holding the reset button on the Yun Shield for 30 seconds while it is powered up.

For this project to work successfully, it will at least need to have internet access via WiFi or LAN. LAN connectivity is as easy as plugging in an Ethernet cable from an internet connected router.

For WiFi, use the web setup by connecting to the ‘duinotech-xxxxxxxxxxxx’ network and going to in a browser. Log in with the ‘duinotech’ password, click the ‘System’ option and enter your WiFi network in the Wireless Parameters, then press ‘Configure & restart’. After this, the Yun Shield will be on a different IP address.

Open a console on the Yun Shield. You can either use the SSH login via your LAN using a program like ‘PuTTY’ or ‘TeraTerm’, or use the Leonardo’s serial port to talk directly to the console. To set up the Leonardo for transparent communication with the Yun Shield, use the following sketch:

#define BAUDRATE 250000

void setup() {

void loop() {
 if (Serial1.available()){Serial.write(Serial1.read());}
 if (Serial.available()){Serial1.write(Serial.read());}

The Arduino Serial Monitor will work, but is not the best program to use for this.

The following commands are only entered once, and set up the software for the webcam. Check that each command runs correctly before proceeding to the next (it might be easier and more accurate to copy and paste the lines). If you’re using a different webcam, you might need to install extra packages to make it work.

opkg update

opkg install kmod-video-uvc fswebcam

The first line downloads an up-to-date package list, and the second line installs two packages to interact with the webcam. Check that you don’t get any error messages. If you do get errors, there might be an issue with WiFi/internet connectivity. The Yun Shield is based around a version of Linux called OpenWRT, and specific command help can usually be found on the respective forums.

Another command to run now is the following:

ln -s /tmp/image.jpg /www/image.jpg

This sets up an alias to the captured image that can be viewed on the Yun Shield’s web server- after this, the image taken by the camera can be accessed via the LAN by browsing to http://YUNSHIELDIPADDRESS/image.jpg. You might even like to copy the ‘webcam.html’ file to the www folder on the Yun Shield- this is a small webpage which automatically refreshes every 30 seconds, giving you a constantly updating view of the latest image taken.

The easiest way to copy to the Yun Shield is to put the file on a USB flash drive, and insert it in the USB port on the Yun Shield.

Assuming the file is in the root of the USB flash drive, issue the following command:

cp /mnt/sda1/webcam.html /www

Plug the webcam into the USB port on the Yun Shield- you might get some diagnostic information displayed as the drivers are loaded.

From the console, you can also manually test the commands that the Leonardo is going to give the Yun Shield.

cd /tmp

Moves to the /tmp folder, which is stored in RAM. Because we do not need the captured images to be permanently stored, we save them to the /tmp folder. This has the advantage that using it does not wear out the flash storage, although being part of RAM, it is lost on reboots.

fswebcam -S 20 image.jpg

This is the command which captures the image from the webcam and saves it. If you run this command manually, you can see that the ‘image.jpg’ file has been created by executing ‘ls’ (list directory contents).

The following is the command which upload the file to Dropbox (remember to replace AUTHTOKEN with your own token):

curl --insecure -X POST https://content.dropboxapi.com/2/files/upload -- header "Authorization: Bearer AUTHTOKEN" --header "Dropbox-API-Arg: {\"path\": \"/image.jpg\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" --header "Content-Type: application/octet-stream" --data-binary @image.jpg

It looks like a complicated command, but information on its structure can be found here:


The AUTHTOKEN value will be specific to your Dropbox, and information on how to get this is in the Dropbox section.


Open the sketch file and copy your AUTHTOKEN in between the quotes on the #define AUTHTOKEN line, then upload the sketch to the Leonardo. The Serial monitor outputs some debugging information, so you can see what is happening. If there are issues with the upload not being successful, try the individual commands as listed above to see where the problem lies.

The sketch also dynamically generates a filename based on the date and time, and this replaces the image.jpg in the path element above. The sketch loops once per minute, so it’s also a simple timelapse camera in this configuration.


The sketch simply loops by default, taking a photo every minute, but the obvious next step would be to add a sensor to trigger when to take photos, and turn it into a motion activated DVR.

The Yun Shield only has one USB port because the Leonardo can only provide power for a single USB accessory. More USB accessories can be added via a powered USB hub- for example, a USB stick could be used to store local copies of the photos. You would get the Leonardo to issue a command like:

cp /tmp/image.jpg /mnt/sda1/image.jpg

And replace the second image.jpg with the timestamp variable.

It’s a bit beyond the scope of this article, but there are packages available for OpenWRT which can handle emailing, so it’s possible to create a project which can email a photo when triggered.


The code is quite long, and is included separately. Use the Yun_Dropbox_Webcam_Timelapse sketch folder for the main project.