Pinterest Stumbleupon Whatsapp
Advertisement

You’ve had success with your latest Raspberry Pi project. Perhaps you’re using it to create photos, music, or even video? Whatever the case, at some point you’re going to want an easy way to get the data off the Pi’s SD card and onto your PC’s HDD.

This can be tricky.

With virtually no support from cloud services, the answer comes in the form of removable media, email, and local network tricks. If you’ve ever had to copy data to or from a Raspberry Pi and run into problems, these five methods should help you out in future.

1. Send Data via Email

This is probably the most obvious option — it’s certainly the first thing I tried. By accessing the Raspberry Pi’s default email client (Claws Mail as of the PIXEL desktop version of Raspbian Jessie Upgrade Raspberry Pi's Raspbian OS With the PIXEL Desktop Environment Upgrade Raspberry Pi's Raspbian OS With the PIXEL Desktop Environment Since its release in 2012, the Raspberry Pi's Raspbian operating system has had a few revisions, but the desktop environment had remained largely the same. Pixel changes that. Read More ), it’s a simple task to setup your email account, add an attachment, and send the data.

You might prefer to access Gmail via the Chromium web browser — either option is fine.

Advertisement

How you send the email is up to you. If you’re using Gmail, you’ll be able to save the message as a draft. Then when you sign into Gmail on your main PC, it will be there. Otherwise, if you’re using an email client, just email it to your own address, or a second email account you have access to.

If you don’t have a second email account but have a Facebook account, then you have a Facebook email account. In a squeeze, send the data to this.

2. Access Cloud Storage in the Browser

Another obvious-but-slow option is to access one of your cloud accounts and sync data this way. Unfortunately, no well-known cloud services offer apps for the Raspberry Pi, so your best bet is to upload your files via the Chromium browser.

But which service should you use?

Dropbox and Box are both available via the browser, but are slow. OneDrive and Google Drive, meanwhile, can barely be used. We’d suggest sticking to whichever you find the most useful.

3. Use a USB Drive

Another sensible choice is to use a USB drive. Simply insert a formatted drive into a spare USB slot in your Raspberry Pi, and wait for it to appear in the Raspbian file manager. If you’re using an older Pi or a Raspberry Pi Zero Getting Started with Raspberry Pi Zero Getting Started with Raspberry Pi Zero Whether you bought a magazine with one glued to the front, or found a kit online, the chances are you're now the proud owner of a $5 computer: the Raspberry Pi Zero. Read More and are short of USB ports, then it’s time to employ a USB hub. While a standard USB hub will be fine for a USB flash device, note that a powered hub will be needed for devices that will draw power from the Pi.

With the USB drive inserted, it should automatically mount. If not, you’ll need to mount it manually. Begin by finding its unique ID:

ls -l /dev/disk/by-uuid/

Typically you’ll find an entry called sda1 (although this may differ), so keep a note of the name before proceeding.

Next, create a mount point. This is essentially a directory that will display the contents of the drive.

sudo mkdir /media/usb

(You don’t have to call it “usb” but it helps.)

Next, ensure the Pi user owns the folder. Otherwise, you won’t be able to view the contents!

sudo chown -R pi:pi /media/usb

You can then mount the drive with:

sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi

Once you’re done, you can easily copy files to the USB drive and, after safely ejecting, copy them to your main computer. To manually unmount use:

sudo umount /media/usb

4. Send and Receive Data With SCP

A little complicated to get working, the idea with this is that you can use the command line to send and receive data between your Raspberry Pi and your PC.

A command called scp (Secure Copy Protocol) makes this possible. To use it, you’ll first need to establish an SSH connection to your Raspberry Pi Setting Up Your Raspberry Pi For Headless Use With SSH Setting Up Your Raspberry Pi For Headless Use With SSH The Raspberry Pi can accept SSH commands when connected to a local network (either by Ethernet or Wi-Fi), enabling you to easily set it up. The benefits of SSH go beyond upsetting the daily screening... Read More . This works best for Linux, as Windows users will need to install an SSH client to make it work. Once connected, in Linux, type:

scp pi@192.168.0.15:file.txt

This uses the scp command, identifies the device and the default username, and specifies the name of the file. The file.txt document will be transferred from the Pi to your computer’s Home directory.

To copy file.txt to your Pi, use:

scp file.txt pi@192.168.0.15:

(That : at the end is very important!)

Again, the home directory is the destination. To change this, specify a different directory, such as:

scp file.txt pi@192.168.0.15:subdirectory/

This method is similar to the ADB push command used to send data to and from an Android device How to Use ADB and Fastboot on Android (and Why You Should) How to Use ADB and Fastboot on Android (and Why You Should) Learning to master ADB and Fastboot can make your Android experience a whole lot better. Read More  when flashing a new ROM or rooting.

5. The Best Option: SFTP

If you have a good FTP client that has support for the secure SFTP, then this is perhaps the best option to grab data from your Raspberry Pi. For this, the flexible, open source FileZilla project FileZilla - Why This FTP Client Triumphs Over Its Competitors FileZilla - Why This FTP Client Triumphs Over Its Competitors Portable apps make you independent. Stored on a USB stick or in your Dropbox folder, all your essential tools will be at your fingertips wherever you go. You won't have to install anything either. Read More is a good place to start. You can download a copy from filezilla-project.org.

SFTP stands for SSH File Transfer Protocol, so as long as SSH is enabled on your Raspberry Pi (typically via the raspi-config screen) you can use SFTP for pushing and pulling files in the GUI.

With FileZilla running, open File > Site Manager, and click New Site. From here, enter the IP address of your Raspberry Pi in the Host box (or just raspberrypi.local if you have Bonjour services running).

Continue filling the form, selecting SFTP – SSH File Transfer Protocol for the Protocol and Normal for the Login Type. Enter the current Raspbian username and password for User and Password (by default this is pi and raspberry). You might want to click Rename to give the connection a descriptive name — this is particularly useful if you use FileZilla regularly.

As long as the Pi is already booted, you can click Connect to begin the connection. In FileZilla, the local device (your PC) is represented on the left, with the remote computer (your Raspberry Pi) on the right. You’ll need to browse through the directories on both sides to find the source and destination files. Once you’ve done this, you can copy files from your Raspberry Pi by dragging them to the left pane, or right-clicking and selecting Download.

(To copy files to the Pi, simply move them from left to right.)

Although a little fiddly to setup, we reckon SFTP is the best solution for transferring files to and from your Raspberry Pi.

Do you find transferring data between your PC and a Raspberry Pi troublesome? Have you tried any of these methods or do you have a trick of your own? Tell us in the comments!

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Getgood
    March 9, 2017 at 10:48 pm

    Why don't you makeuseof disqus and get rid of this shit comment section.

  2. Doc
    March 9, 2017 at 6:07 pm

    Can't believe the simplest options (popping the Pi's (micro)SD card into a card reader, or accessing a shared network folder, either on the Pi or on a desktop machine) were not discussed. :p

    • Derp
      March 9, 2017 at 10:41 pm

      Because it's too obvious derp..

    • Derp
      March 9, 2017 at 10:43 pm

      "Dropbox and Box are both available via the browser, but are slow. OneDrive and Google Drive, meanwhile, can barely be used. We’d suggest sticking to whichever you find the most useful."
      Is #2 for reals? Use cloud but it's slow and or "can barely be used". Does Google not have a drive app you can run on the pi instead of using a browser?