HowTo: Adding FTP To The Ubiquiti AirCam Mini

Unfortunately the Ubiquiti AirCam Mini doesn’t, out of the box, allow you to FTP images from the camera to a remote server.

Ubiquiti AirCAM Indoor Mini IP Camera – 720p H.264

We can however fix that though in this instance we’re looking at sending single frames, not streamed video. The AirCam has something in common with many Ubiquiti products, it runs Linux. This means we can compile applications and use ssh and scp. For those that find compilation a bit daunting, at the bottom of this post, there’s a link to a tarball containing all the files you need to get this working. Just read the post so you know what’s going on.

One of the first things you may have noticed is that there’s no FTP client on the AirCam Mini. Somewhat annoying but we can change that fairly simply. You need to make sure you have a development environment setup on your Linux PC. Notice we’re adding the arm version of gcc too. If you’re using Ubuntu you can use the following command, you may be prompted for your root password.

Once those tools are installed we need to get a copy of the ncftp source code. Look at the section titled ‘Download NcFTP Client‘ and select the one marked NcFTP Client x.x.x source code (.tar.gz package), where x.x.x is 3.2.5 at the time of writing.

Once downloaded extract the tarball, change directory to the source and run the configure script with extra parameters

This with check for various dependencies for the build process. You’ll need to satisfy any specific issues that crop up. Now ncftp isn’t really setup for cross compiling so we need to make a slight change to the Makefile that the configure script created. Edit the Makefile and you should see something like this

The file will contain more, this is just a snippet of the top, the part we’re interested in. Just under the line

add

Note that we’ve deliberately truncated the file name to exclude the ‘gcc’ part for the arm compiler executable. Now change the lines that starts CC= and STRIP= so that they read

and

Save the file, it should look something like this

We can now start the build process. Type

and hit return, the build process should start and you should see lots of files compiling

You may find that the compilation ends with something like

Don’t worry about this, although it’s an oddity since we’ve disabled ncurses in the configure. You would probably solve this by installing ncurses-devel or a similar package. In reality it doesn’t matter to us because, if you look a few lines further up your screen you should see

Since ncftpput is what we’re interested and we have a compiled executable, we can copy this to the AirCam. The AirCam default username and password are ubnt obviously you’ll want to change that password at some point. Copy the ncftpput binary to your AirCam

Replace [ip-address] with the ip address of your AirCam, also note that the colon (:) at the end of the line is required. Type the password for your AirCam when prompted.

ssh into your AirCam

again replacingwith the ip address of your AirCam. This time, there’s no colon (:) at the end of the line. Again, enter your password when prompted.

The ‘more’ program is used by ncftpput to display its help screen, if you don’t need the help then you can skip this part. The AirCam Mini doesn’t have the more program so we need to supply one which this simple script will do. Save the file as ‘more’ and you’re nearly done.

We need to make this script executable, so

Next we need a script to actually do the FTP for us, create a new file and put the following in it

Replace the

keywords with the values appropriate for the target server you are trying to FTP to and save the file as send_file. The file needs to be made executable so

You can test to see if this will FTP an image for you to your server by using

You should find a file called snap.jpeg on your server if everything went well.

It’s all very well having this working by copying files to your AirCam Mini but it would be so much better if we didn’t have to copy everything to it after each reboot. So, lets make the AirCam Mini boot with our configuration and settings and automatically start the FTPing of images.

First of all we need to create a file called rc.poststart this will be run by the AirCam boot scripts after all the system startup processes have completed. The script will create a directory /etc/crontabs, copy a cron definition file to it and then start the cron daemon.

The file needs to be executable so

We also need a crontab file so the crond process knows to run our send_file script, edit a file called ubnt and add

and save it. If you now do an ‘ls’ on your AirCam you should see

Right now, everything you’ve done will be lost if your AirCam reboots. We need to stop that. Create another file and put the following in it

save the file and call it ‘save‘. Again we need to make this script executable, so

When you run this script a backup, that is restored at boot, will be created and saved to flash. Now each time you boot the AirCam, your files will be restored, rc.poststart will run and you should start seeing images been sent via FTP to your server at 1 minute intervals.

To run the script use

You should see some output resembling

I’ve added a tarball (aircam_ftp.tar.gz) with the files required for those that don’t want to go through the compile process. You can extract the contents, edit send_file changing the details for your server and scp the files to your AirCam.

It’s worth noting your AirCam will still function as normal, you can still connect to its web interface and make configuration changes. It’s more than likely that you will need to redo the above process if you flash a new version of the firmware on your camera.

If you have any questions or comments please leave them below.

 

Update : WARNING If you upgrade your AirCam to firmware 1.2 you will no longer be able to do this.

15 Comments

  1. fab says:

    Hi, thanks for your effort in this project,
    i would buy some aircam device but i need the upload feature..
    there is a way to downgrade the firmware version, in case is 1.2 or more ?
    alternatively did you find a solution for modern firmwares?
    thanks

  2. Uli2000 says:

    I have tried it out and it works but if i call the save scipt the following message appears :

    AirCam.v1.1.5# ./save
    Found Active on[1] …
    Found Backup1 on[2] …
    Buffer too small.
    Compression failed

    any solution ?

    thanks

    • Uli2000 says:

      now it works – i did a reboot and send all files again to the aircam without running any script before. Then running ./save again without any error und did a reboot. All Files are still on the aircam and all works very well.

      Thanks to AndyP – Great work

  3. Prohu says:

    Since I am using Centos, could you please send me a cross compiled version of ncftpput?

    Many thanks in advance,

    Prohu

  4. Prohu says:

    Sorry I have found it! thanks!!

  5. Prohu says:

    ./send_file: line 5: ncftpput: not found

    this is the error message i got after having copied all the files into the aircam..

    • AndyP says:

      Have you tried using the tarball from the link in the article?

    • Prohu says:

      Finally I succeeded!
      Nevertheless now I face the following problem, I suggested to the cam owner to reset the cam by pushing the rear button as since a while he has changed the router and the cam was not sending the images to the server anymore. I fear the reset erased the “patch”.
      Any hint?

  6. from a shell:
    sudo nano /bin/aircamtowunderground.sh

    Add the script. Change the username and variables.

    #!/usr/bin/expect -f

    # purpose: sending image to wunderground
    # add to “crontab -e” : */5 * * * * /bin/aircamtowunderground.sh >/dev/null 2>&1
    # connect via scp
    spawn scp “ubnt@AIRCAMMINIIP:/tmp/snap.jpeg” /tmp/snap.jpeg
    #######################
    expect {
    -re “.*es.*o.*” {
    exp_send “yes\r”
    exp_continue
    }
    -re “.*sword.*” {
    exp_send “PASSWORD\r”
    }
    }

    # ftp image from camera to wunderground
    spawn ncftpput -u USER -p PASSWORD webcam.wunderground.com / /tmp/snap.jpeg

    expect eof
    exit

  7. Prohu says:

    Can I reset the cam pushing the rear button and keeping the “patch” anyhow?

  8. ian says:

    Even easier – use Security Monitor Pro to capture from the camera and FTP. All built in along with motion detection, e-mail alerts and much more.
    http://www.deskshare.com/video-surveillance-software.aspx

    • LinITX Trainer says:

      True, except it requires an additional computer. Our solution means the camera can be installed, on it’s own, with no other hardware and provide a regular FTP upload to a webcam website. Which is what the client needed in this case.

Leave a Reply