This web site uses cookies to improve your experience. By viewing our content, you are accepting the use of cookies. To find out more and change your cookie settings, please view our cookie policy. Close

How to make a Raspberry Pi solar-powered FTP server

You've set up your Raspberry Pi using our easy to follow instructions. You've had a gander at our 25 top fun things to do and now you fancy something a bit more involved. How about making a solar-powered FTP server?

You'll always have instant access to all your digital files, from anywhere with an Internet connection, and it won't cost a penny on your electricity bill.

Ordering the sun bed

We'll be using a simple custom-built £25 Raspberry Pi case, with all the right slots for its outputs, that comes with a small solar panel, a battery case and a micro-USB cable. You'll just need to supply your own NiMH rechargeable batteries.

Point your browser over here -- you'll find all the information you need to place an order via PayPal. The maker, Cottonpickers, has an eBay page as well if you're more comfortable making your purchase that way.

Static IP address

Once it's plopped through your letterbox, slot your Pi into the case and hook it up to power and a monitor. Let's start programming. The first step is to make sure the RPi has a static IP address, as we're going to have to poke a hole through our network firewall to allow incoming FTP requests.

In the RPi desktop, double-click the 'LX Terminal' icon to drop into the Terminal. To setup a static IP address, type the following:

sudo nano /etc/network/interfaces

This file controls the IP addressing for the RPi. All you need to do is scroll down slightly to the 'iface eth0' line and remove 'DHCP' and replace it with 'static'. Now, on the line directly below, enter an IP address for your RPi, along with the subnet mask and gateway. Our example looked like this, but yours will be dependent on your home network:

address 192.168.1.93
netmask 255.255.255.0
gateway 192.168.1.254

Assuming you don't know these already, you can find your IP address and router settings by consulting your router documentation, or by typing the following into a Terminal on the RPi: ifconfig -a. This will list the current IP address, netmask and gateway as configured by the router's DHCP. All you need to do then is enter the IP address and so on into the 'static' section of the file to make sure the RPi will forever boot with that unique IP addess.

After you've entered the details, exit by pressing Ctrl+X to exit, followed by 'Y' to accept the changes, then press Enter a couple of times to get to the command line. Now type:

sudo /etc/init.d/networking stop
sudo /etc/init.d/networking start

This will restart the networking components with the new IP address in place.

VNC

From the Terminal type the following, pressing Enter after each line:

sudo apt-get update
sudo apt-get install vnc-server
vncserver

When the packages have downloaded and installed, follow the instructions on-screen to setup a password, and confirm it, but answer 'No' to the view-only option.

Now that VNC is installed, we need to make sure it loads up as a service every time the RPi reboots. To do this, from the Terminal type:

sudo nano /etc/init.d/tightvncserver, and press enter

In the editor, type the following:

#!/bin/sh
# /etc/init.d/tightvncserver
# Set the VNCUSER variable to the name of the user to start tightvncserver under
VNCUSER='pi'
case "$1" in
   start)
     su $VNCUSER -c '/usr/bin/tightvncserver :1'
     echo "Starting TightVNC server for $VNCUSER "
     ;;
   stop)
     pkill Xtightvnc
     echo "Tightvncserver stopped"
     ;;
   *)
     echo "Usage: /etc/init.d/tightvncserver {start|stop}"
     exit 1
     ;;
esac
exit 0

Now press 'Ctrl+X', then 'Y' to save, followed by 'Enter' a couple of times to get you back into the Terminal. What we need to do now is edit the permissions of the script we've just created so that it's executable, do this by typing in:

sudo chmod 755 /etc/init.d/tightvncserver, and press Enter.

Finally, we need to add it to the start-up scripts, by typing:

update-rc.d tightvncserver defaults, and press Enter.

What you can do now is unplug the RPi from your monitor and locate it somewhere that has easy access to a network cable, and plenty of sunlight (for the solar cells). If you install the likes of TightVNC Viewer you should be able to point the client to '192.168.1.93:1' (or whatever your static IP address is) and have full access to the RPi and the GUI.

VSFTPD

This next part involves setting up the FTP server itself. Again it's not too difficult, and can be configured to your exact preferences later on. From the Terminal, type the following:

sudo apt-get install vsftpd, and press Enter.

Once the VSFTPD (which stands for Very Secure FTP Daemon) packages have downloaded and installed, type:

sudo nano /etc/vsftpd.conf, and press Enter.

This is the configuration file and control for VSFTPD, it allows you to set all sorts of restrictions and policies, so some care is advised. To start with though, we would recommend altering the following lines within the script, either by un-hashing, or typing in 'YES' or 'NO':

Anonymous_enable=NO
Write_enable=YES
Local_enable=YES
Ascii_upload_enable=YES
Ascii_download_enable=YES

The full explanation can be found within the hashed comments in the script itself, but they will suffice for our little project for now. When ready, rave the changes to the script as before.

Finally, reboot the RPi to bring everything you've done so far into effect. To do this, make sure you're in the Terminal, and type:

sudo reboot, and press Enter.

Access external hard drive via FTP

We like to make things easy, so here's our method of accessing an external hard drive attached to one of the RPi's USB ports, via an FTP client.

First, you can hook up an external USB drive to your PC and format it as NTFS, with the volume labelled FTP. When that's complete, plug it in to the RPi and via VNC click 'Yes' to view the drive from within the File Manager.

Make a note of the address of the hard drive -- in our case it came out as /media/FTP. To test FTP access, install an FTP client such as FileZilla and enter the connection details:

192.168.1.93/media/FTP, replacing the IP address with your own static RPi address.

Username: pi, replace this with the username you set VSFTPD with (default is pi).

Password: raspberry, replace this with user's password (if other than pi).

With luck, you should now have access to the external USB hard drive, via FTP, internal to your own network.

External access

The final part of this project involves granting external FTP access to the RPi. This is also the most ambiguous of the steps, as it all depends on the make and model of your router. For example, on the basic BT model I used it's a simple case of selecting FTP from the pre-defined applications, and assigning it to the internal IP address of the Raspberry Pi.

Yours may be completely different, however. That being the case, please consult your router's documentation, or Google the model and see if there's already an FTP external access tutorial out there.

Comments 16

Add your comment

anonymous's avatar

anonymous 7 December, 2012 22:46

I want to get a Raspberry Pi but I'm scared :(

anonymous's avatar

anonymous 8 December, 2012 18:51

Hey "anonymous" , please visit my site Raspberry-Pi-Buy.com. I sell starter packages with everything you need to get started included a preloaded sd card. Also, we can answer any questions you may have about the Pi. Thanks. Raspberry-Pi-Buy.com

anonymous's avatar

anonymous 9 December, 2012 06:38

With the power consumption of around 400mA (as reported by users of RPi model B), a solar battery supplying a little over 300mA (as per specs) under full sun is kinda useless.

anonymous's avatar

anonymous 9 December, 2012 08:51

Very good idea !!!
Good work.

anonymous's avatar

anonymous 9 December, 2012 19:05

This will be a nice setup for the Raspberry Pi model A which removes Ethernet and one of the two USB ports. According to testing the Model A will use between 90mA and 143mA vs 110mA and 352mA for the Model B.

http://www.raspberrypi.org/phpBB3/viewtopic.php?p=164893

Excuse me if I missed it, but is the hard drive in this setup being powered by the Raspberry Pi USB port? I can't see this setup lasting very long.

anonymous's avatar

anonymous 10 December, 2012 12:05

Great project :) But do you have any battery management? Overloading and deep discharging batteries will kill them quickly.

anonymous's avatar

anonymous 11 December, 2012 18:55

Solar panels available for cheap on ebay (should cost less than $5 to get 5v 1A).

http://www.techiesinfo.com/solar-panel-electricity

anonymous's avatar

anonymous 12 December, 2012 02:32

This is very cool, but why do you use something as boring as FTP?

You should check out using a WebDAV server, such as BarracudaDrive for RSP:
http://barracudadrive.com/RaspberryPi.lsp

anonymous's avatar

anonymous 14 December, 2012 20:39

4 NiMH rechargeable batteries means 4*1.2V=4.6V when fully charged, right?
Is that ok for the Pi?

anonymous's avatar

anonymous 14 December, 2012 20:40

I mean 4*1.2V=4.8, of course! :)

anonymous's avatar

anonymous 17 December, 2012 20:21

A fully charged NiMH cell is more like 1.3V, so the max is something like 5.2V. It'll survive. Cheap batteries will sag badly under load, though. Also you will probably not get to use full capacity down to 1.0V per cell (4.0V output!) so the forum post talking about 3000mAh is a hoot.

anonymous's avatar

anonymous 17 December, 2012 20:35

This is more on configuring the R-Pi for a speculative use case, because that hardware ain't ever going to work in an unattended manner. Though NiMH batts generally survive C/10 charging indefinitely, the hardware does not appear to have any battery management smarts, deep discharge would be an issue, so it needs manual attention. It's just a hobbyist plaything; speculating on making it a solar-powered FTP server is a bit rich and is not deserved by the hardware.

anonymous's avatar

anonymous 27 December, 2012 01:13

I had all kids of weird USB problems with the Raspberry Pi version 2 board.
I stumbled across a site (RPiPS.com) that has an add on power supply for the Pi. I plugged that bad boy in and now I have zero power problems. I am even running a USB passport drive, USB hub, wireless mouse, USB wireless adapter and keyboard all off of the PI’s USB ports. This is awesome!!!

anonymous's avatar

anonymous 3 January, 2013 20:59

Hey,

thats really great. I did a similar project with my Raspberry Pi. I buildt a greenIt Home-Server. I described it here:
http://ownservices.dtdns.net/it_project_miniserver_en

I will backlink this page, it fits great to my topic.

Greetz

anonymous's avatar

anonymous 3 January, 2013 20:59

Hey,

thats really great. I did a similar project with my Raspberry Pi. I buildt a greenIt Home-Server. I described it here:
http://ownservices.dtdns.net/it_project_miniserver_en

I will backlink this page, it fits great to my topic.

Greetz

anonymous's avatar

anonymous 10 January, 2013 02:59

Just to answer some of the questions posted here. The NiMh battery box you see in this project ($10 from cottonpickers, or $15 for Lithium Ion version or $29 for 6 cell Lithium Ion version), has a built in charger powered by the USB from the solar panel, and also outputs 5v to USB (to power the Pi or charge your cell phone or anything else USB). It doesn't matter if the batteries are 5.5v or 4.5v, it'll always put out 5v over the USB. The built in charger for the battery box (powered from the solar panel) provides the perfect current and voltage to safely charge the NiMh (or Li-Ion) batteries, as well as provides deep discharge/low voltage protection. Think of it as a battery backup/UPS for the Pi. Any spare current during the day not used for powering the Pi goes into charging the batteries. As soon as it gets dark enough that the solar panel can't provide enough juice to power the Pi, it starts borrowing power from the batteries. The next morning it'll switch to solar power and start charging the batteries again. cottonpickers has much more powerful solar panels available (I use his $139 dual folding panel to power my Pi, which is mounted in a tree and streams two cameras over 3G for tracking animals). He can build you a quad panel, or custom design something that puts out whatever power you need!

Post your comment

Log in with your CNET UK or Facebook account to post a user review, or click Join to create an account

Your email will not be displayed with your comment

Copy the letters and numbers to prove that you're human. You won't have to do this if you log in or register

Your comment must comply with the Terms of Use

About CBS Interactive

Copyright © 2013 CBS Interactive Limited. All rights reserved.