Skip to main content

Arduino Life 5: Arduino Yun and ftp client/server

One of the main reasons I purchased an Arduino Yun as my first Arduino board was it’s inclusion of WiFi right out of the box. This means you can start making Internet of Things projects immediately. As I have introduced myself to Arduino, I have also looked to learn more about the Linux side of the Yun, how it bridges to the Arduino side and how I can interact with it using standard Internet tools, like SSH and FTP.

Arduino yun

An Arduino with SSH

Once the Arduino Yun is connected to a network, it is possible to use the Macintosh Terminal or other SSH client to log into the Yun and use it as you would any Linux computer.

You’ll need an SD Card on the Arduino Yun to do much with SSH or ftp access, though, as you need a place to store the files you will be uploading or creating.

Arduino ssh 1

This is fine if you just want to view files on the SD Card or other basic terminal operations, but as I was playing around, I realized i wanted to do more than use the built-in vi editor. I use a Mac OS X text editor program called, TextWrangler for a lot of things, including coding. My first thought was to use an ftp client on the Yun to connect to my local computer, so that I could push data over to the Mac from projects like my temperature, humidity and light level sensor. After many searches, it looked like there wasn’t an ftp client for the Yun, but you could install an ftp server and then access that from the Mac. I also had another user for this ftp server, which I’ll show in a moment,

Textwrangler icon

TextWrangler for Mac OS X

An ftp server for the Arduino Yun

Installing an ftp server on the Arduino Yun is actually quite simple. SSH into the Yun and execute these two commands:

opkg update
opkg install openssh-sftp-server

You may need to reset the Yun using the reset button or by cycling the power in order to get the server started. After that, it will be automatically started on each boot. You’’ll now be able to use your favorite ftp client to connect to the Yun. 

Here’s a view of the Yun’s ftp server using Cyberduck on the Mac.

Ftp screen 1

One of the reasons I was so keen to have direct file access to the Yun was that I was trying to develop a short Python program to run on the Yun, but using my ancient (i.e. 30+ year old) knowledge of vi was quite limiting. TextWrangler supports direct reading and writing of text files to any FTP server, and I have used that when editing files on my web server, so I figured there had to be a way to install an ftp server on the Yun and then use Textwrangler to write code directly onto the Arduino.

Textwrangler 1

I can read and write directly to the server using TextWrangler. This means I can write my code, click Save and then immediately switch to my Terminal window and execute the code to test it. That makes it very convenient.

Going Further - Pushing files to ftp server using Python

Of course, once you find one use for the ftp server, more are sure to follow. One of the common beginner projects for the Arduino Yun is a motion-activated security camera. You an find complete instructions in this post from Adafruit.

Wireless Security Camera with the Arduino Yun
Build your own wireless security camera using the Arduino Yun & a USB webcam!

This example using the Temboo service to forward the photos and stream video from the Yun directly to the Internet. When I was looking at the project, though, I was thinking that, since I have my own web server available, I would rather forward the photos to a directory on the server where I could view them at my leisure. This, in fact, is what sent me on the original search for an ftp client for the Yun. While I didn’t find a full-blown client, though, I did find a programatic way to ftp files to the server of your choice using a Python program. This was a little more manual, but it got the job done.

Here is my test code — with no error checking or any other niceties — but I figured you might find the example useful. Many thanks for the folks at EFFBot that provided the great — and easily modified — code which I could build on.

import datetime
import ftplib
import os
# Function to provide easy uploads of appropriate type (Text/Binary)
# Taken from
def upload(ftp, file):
ext = os.path.splitext(file)[1]
if ext in (".txt", ".htm", ".html"):
ftp.storlines("STOR " + file, open(file))
ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
# Get Date
today =
# Get Time
now =
# Build webcam capture filename in YYYYMMDDHHMMSS format
# Call fswebcam capture with resolution parameter
from subprocess import call
call(["fswebcam","-r 1280x720",fname])
# Open FTP session and change directory
ftp = ftplib.FTP(“")
ftp.login(“user", “password")
# Upload picture file
upload(ftp, fname)
# End FTP session

You might have noticed in the ftp screen shot above, this code does work. It snaps a picture from the webcam, stores it locally on the SD Card with a unique date and time--stamped name and  then uploads it to my web site. I plan on setting up this security camera as a test in one of my upcoming learning sessions and replacing the Temboo calls with this ftp script (or perhaps an improved version of it.) I’ll report back on how well it works in an upcoming post.

There is so much to learn about the Arduino world and the Arduino Yun especially. It’s obvious now that many people have wanted a board like the Yun, as Arduino has now introduced a shield that can turn an Arduino Uno — one of the most popular boards — into a functionally equivalent Arduino Yun.

Arduino Yun Shield on eBay

Arduino Yun Shield on

I hope you’ve found this edition of Arduino Life useful. Please send along your questions and comments.


Popular posts from this blog

Onion Pi makes your web traffic anonymous via Open Electronics

Hmmm, might be an easy (and relatively cheap) way to play around with Tor and learn a bit more about this anonymizing service. -- Douglas Adafruit’s Onion Pi is a Tor proxy that makes your web traffic anonymous, allowing you to use the internet free of snoopers and any kind of surveillance. Follow Adafruit’s tutorial on setting up Onion Pi and you’re on your way to a peaceful anonymous browsing experience. Tor is an onion routing service – every internet packet goes through 3 layers of relays before going to your destination. This makes it much harder for the server you are accessing (or anyone snooping on your Internet use) to figure out who you are and where you are coming from. Read Onion Pi makes your web traffic anonymous via Open Electronics * A portion of each sale from directly supports our blogs ** Many of these books may be available from your local library. Check it out! An interesting link found among my daily reading

How to Build a Raspberry Pi-Powered Digital Photo Frame via Tom's Hardware

A digital photo frame is a small screen that can sit on your desk in your office or in your kitchen displaying your favorite pictures, changing at regular intervals. The first commercial digital photo frame was introduced in the 1990s shortly after the digital camera. Digital photo frames made a comeback in popularity during 2020, perhaps because people were staying at home more. In this tutorial, we’ll turn our Raspberry Pi into a digital photo frame using MagicMirror and the GooglePhotos module. Please note, we will skip installation of the 2-way mirror in the original Magic Mirror project. Consider this project, “Magic Mirror, without the mirror.” Read How to Build a Raspberry Pi-Powered Digital Photo Frame via Tom's Hardware An interesting link found among my daily reading

On my Mac/Windows PC…Disk Inventory X/WinDirStat

Disk Inventory X | WinDirStat   There comes a time in every computer user's life when they need to figure out why their hard drive is out of space and Disk Inventory X and WinDirStat are a great help. Their operation is pretty straightforward. Look at the hard drive directory and see what is taking up the most space. Then allow the user to prune, backup or other remove these files to free up some space. Simple, effective and very, very useful when you need it. Free Previously in On My Mac... iMovie Tweetdeck Celtx Scriptwriting Software LogMeIn Kindle Reader MarsEdit Blog Editor Cyberduck Minecraft Dropbox Garageband MPEG Streamclip Google Chrome Evernote On My Mac/Windows PC is an on-going series highlighting the software (and sometimes, hardware) I use on my Mac nearly every day. Look for additional On My Mac…posts in the coming weeks! -- Douglas