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

Microsoft release email services to replace Hotmail

Today Microsoft released its new email service to replace its Hotmail brand. This new streamlined Metro interface design looks good and functions well so far. You can use your existing Microsoft account to log in and then choose an email alias (i.e. for your new email address. Here are several articles that discuss Goodbye, Hotmail; Hello, [REVIEW]  Outlook Is a Completely New, Feature-Filled Webmail Service from Microsoft Go Get Your @Outlook Email Address Quick Before Someone Else Does I will post links to more articles and reviews as they appear.

Tiny Wow - Tools That Solve Your Files Problem - Convert to/from many file formats [Shared]

A nice collection of quick, online tools, to convert to and from a variety of file types. Just the site to keep in mind when you need to shuffle one type data into a new system. — Douglas TinyWow & Your Privacy Don't you love finding a great online tool-set that claims to be free, let's you build and interact the way you want, only to be denied access if you don't pay for an account(or sign up for an account). Our site is free. We don't limit. We don't even take sign-ups. Might we take sign-ups one day? Sure, we probably will(but not any time soon). When we do go down that route, what we will NOT do is trick you into spending your time using our tools, only to be denied access before you can download what you have just spent your precious time creating. TinyWow is free. We don't have ads, we don't sell data. We currently have no plans to monetize. Why offer these tools for free? We operate two tech websites: Alphr & TechJunkie. We thought our use

TechIQ Gift Guide #15: Sams Teach Yourself Wordpress 3 in 10 minutes

#15 Sams Teach Yourself Wordpress 3 in 10 minutes Chuck Tomasi , fellow Friends in Tech member and co-author of Podcasting for Dummies , along with another Friends in Tech member and podcasting partner, Kreg Steppe , have a new book out that would be a great gift for anyone interested in blogging and New Media. Wordpress is my first recommendation when someone wants to get started with blogging, but it can be a little intimidating. It is very powerful and with power comes complexity. That said, this book can help to jumpstart your Wordpress knowledge and help you be productive. There is also a companion podcast to the book, Wordpress in 10, available from the author's web site. From "Sams Teach Yourself WordPress in 10 Minutes gives you straightforward, practical answers when you need fast results. By working through its 10-minute lessons, you’ll learn everything you need to build great blogs with WordPress and, and reach any audience by web brows