Showing posts with label solder. Show all posts
Showing posts with label solder. Show all posts

Sunday, August 10, 2014

Building a RaspberryPi Time Capsule: The cheap, fast and simple guide


I am a longtime fan of Apples "Timemachine" data backup software. Having used multiple flavours of backup software on Linux and Windows, Timemachine has been by far the simplest and easiest one to use. In its simplest form, you only need to plug in a bog-standard hard drive into your Macbook to save your backups. But what if you couldn't even be bothered plugging in a USB drive? Is there a way to do it wirelessly? Good news! Apple sell a wireless backup solution, the "Time Capsule". The bad news? Its $350. There is, however, a cheaper solution.



Since the Raspberry Pi hobbyist development board came out, there have been many guides written on how to convert it into an Apple Timemachine compatible device. Although they work, I have found them to be overly complicated for what has to be done. Also, they require that the Raspberry Pi has a static IP, something that is inconvenient if you want to set up your backup on a new network when you move house, for example. Thankfully, I found one guide that offered a simpler solution. This guide removed much of the un-needed steps from the previous guides. This guide does require that you do the first preliminary backup over the network. For me, with over 300Gb of data to backup, this would have taken over 24 hours to transfer. It is much faster to do the preliminary backup over USB. As such, I have merged the two guides above into one, cheap, fast and simple Raspberry Pi - Time Capsule guide. 

Parts list

Required 

  1. SD card
  2. Raspberry Pi
  3. 3.5mm Portable Harddrive 

Optional 

  1. USB Wifi dongle 
  2. Philips screwdriver
  3. Sharp blade
  4. Mini USB cable 
  5. Soldering iron and solder

Setting up the Hard drive 

  1. Plug your USB into your Macbook. 
  2. Click on Applications - System Preferences - Time Machine. 
  3. Tell Time Machine which drive to use for backups by clicking the “Select Backup Disk…” button, selecting your newly plugged in drive, then clicking the “Use for Backup” button. 
  4. Time Machine will schedule your first backup to start in just two minutes. You will have to wait a while, as this can take a few hours. 
  5. Unplug the hard drive when done. 

Setting up and configuring the Raspberry Pi 

  1. Download the latest "Raspbian" OS image file for the Raspberry Pi. Dont download the "NOOB" version, as this will require that you use a TV to set it up. We will be using SSH in this guide. 
  2. Burn the OS image to the Raspberry Pi. If you are using OSX, use "RPi Easy SD card setup" app. This will take about 20min. Dont worry if you get an error saying "Could not eject card" at the end. It should have completed successfully. 
  3. Put the SD card in the Raspberry Pi. Connect an ethernet cable from the Raspberry Pi to your router. Power up the Raspberry Pi. 
  4. Log into your router on your internet browser and get the IP address of the Raspberry Pi. You can also get this using a TV connected to the Raspberry Pi. 
  5. Open a terminal in OSX, and ssh into the raspberry Pi. The password is "raspberry"
    $ssh pi@THEIPADDRESS 
  6. Update software on the device
    $sudo apt-get update 
    $sudo apt-get upgrade 
  7. Install the software that we will need. Netatalk is used for creating NFS shares, the others are used for reading the HFS formatted USB drive
    $sudo apt-get install netatalk 
    $sudo apt-get install hfsplus hfsutils hfsprogs 
  8. Edit the fstab file to automatically mount the usb drive on boot up
    $sudo nano /etc/fstab 
  9. Add the following lines, then ctrl + c to save and exit. Note: "sda2" was the partition on my USB drive that needed to be mounted. Yours may be sda1. Run "dmesg" to see which one you will have to mount. 
    /dev/sda2 /mnt/TimeMachine hfsplus rw,force,exec,auto,users 0 3
  10. Open up the permissions of the mount directory
    $sudo chmod 777 /mnt/TimeMachine
  11. Attempt to mount the usb drive:
    $sudo mount /dev/sda1 
    If it mounted successfully, try and write to the USB drive using "mkdir /mnt/Timemachine/testDir". Note: if you reboot the Raspberry Pi and the line in the fstab is not correct, the raspberry Pi will not boot up properly again. The easiest way to recover will be to write a new raspbian image to it. Also use the mount command to check that /dev/sda2 is mapped to /mnt/TimeMachine. Make sure that the letters rw are in the same result. This ensures that we have read/write access to the partition.
  12. Add the directory to the "Pi" user (the user that you will be logging in from your macbook with)
    $sudo chown -R pi /mnt/TimeMachine 
  13. Edit the Netatalk config file to share the Timemachine directory
    $sudo nano /etc/netatalk/AppleVolumes.default 
    Add the following line to the end, save and exit.
    /mnt/TimeMachine "Time Machine" options:tm 
  14. Restart netatalk
    $sudo service netatalk restart 
  15. Back on your macbook, a share called "raspberrypi" should appear on the left side of your finder window. If not, in finder, click on Go - Connect to server and type "afp://raspberrypi" or "afp://IPADDRESSOFRASPBERRYPI" into the address window. After you press enter, the shared directory should appear.
  16. Go into Timemachine again. Remove the previous backup disk. Click on "select disk" and select the raspberry Pi. It will prompt your for a username and password. Use "pi" for the username and "raspberry" for the password.
  17. Thats it! The macbook should recognise the previous backup and continue from there. After the previous backup over USB, the second backup over wireless should be alot faster.

Enabling wireless on the RaspberryPi Time Capsule (optional)

You can remove the requirement of having an ethernet cable between the router and the Raspberry Pi by plugging in a small usb wifi dongle into the Raspberry Pi and configuring the wireless. I used a Ralink RT5370 from ebay for this. To connect your Raspberry Pi to the wireless network, here are the steps.

  1. SSH into the Raspberry Pi over ethernet (see above). 
  2. Install the WPA wireless tools
    sudo apt-get install wpasupplicant wireless-tools 
  3. Edit the networking file to use the wpa-supplicant file for wireless configuration
    sudo nano /etc/network/interfaces
    Ensure the wlan0 section uses the following lines:
    allow-hotplug wlan0
    iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    iface default inet dhcp
    
  4. Edit the wpa-supplicant file
    sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
    Ensure that it has the following lines
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    
    network={
            ssid="YourSSID"
            psk="password"
            key_mgmt=WPA-PSK
    }
    
    
  5. Save the file, disconnect the ethernet cable, and reboot the Raspberry Pi. It should now connect to the wireless network.

Powering the Raspberry Pi off the hard drive (optional)

I did not want to have to have a separate power supply for the hard drive and the Raspberry Pi as both would be kept together at all times. As such, I looked into powering the Raspberry Pi off the supply of the hard drive. 
  1. Using a sharp knife, cut the male, full size usb connector off your mini usb cable, exposing the four wires. 
  2. Tape up the two data lines, we wont need them and we dont want them touching anything. They are normally the green and white wires. 
  3. Expose around 2mm of the conductor from the 5v (red) and ground (black) wires. Tin them with solder and the soldering iron. 
  4. Dismantle your portable hard drive. Each one will be different. For mine, I had to remove 4 screws from the underside, and slide out the harddrive and controller from one end.  
  5. Look for the four wires going from the controller to the hard drive. There should be two black, one yellow and one red. We are looking for the 5v wire (red) and either of the ground wires (black). Solder the red and black wires from the USB cable to the points on the controller board that the corresponding hard drive wires are soldered to. 
  6. Find a way to route the cable out of the portable hard drive caddy. I drilled a small hole with the screwdriver and pulled the usb cable through it. I also tied a knot in the cable on the end inside the caddy so that it would not get pulled out through the hole if it was tugged on. 
  7. Put everything back together, power up the portable hard drive, and plug in the Raspberry Pi. The raspberry Pi should power up successfully. 

Thursday, April 11, 2013

Repairing a charred/burned/broken cable on an Apple Magsafe charger

I have spoken in a previous blog post about some issues with Apple hardware design here. To briefly recap, it is of my beleif that in general, Apple hardware is very well designed. However, they often overlook functionality in favour of form, sacrificing important aspects such as durability so that "it looks nice". A good example of this is the Magsafe adapter. In a bid to improve aesthetics, Apple shortened the rubber strain-relief grommet that protects the power cable from fraying at the charger end, and the connector end to the laptop. The metal strands inside the cable gradually begin breaking from normal use until eventually, with only a few strands left carrying a large amount of current, the last few strands overheat resulting in a burning smell and the the connection breaking completely. After Apple received many complaints with regard to this problem with the original Magsafe adapter, they extended the length of the rubber on the grommet to improve the durability of the cable. However, in me experience, this wasnt enough: the cable still ends up fraying, and the hardening of the rubber in the grommet over time only aggravates the issue. They also introduces a replacement program, details of which you can find here. However, this does not cover anywhere outside of the United States.

In case you find yourself in a similar situation as I was, here is a short guide on how to repair the cable on your magsafe adapter, without having to fork out the $80 for a new one. 

First off, you will need a large pliers, a high wattage soldering iron (I used a weller 75watt), solder, some cable ties of various sizes, a drill and a small drill bit, some glue and a sharp knife. 

1. Remove the plug from the Magsafe adapter. 

Removing the plug from a Magsafe adapter
2. Apple have ultrasonically welded the two plastic shells that cover the adapter. They do this by vibrating the two halves against other at such a high rate to melt the plastic at the junction and thus sticking them together. This results in the Magsafe adapter being pretty difficult to open without making some messy cuts in opening it up. So here is a quick tip on opening them up: Flip open the cable tidy arms and insert the pliers into the gap. Then slowly and firmly open the pliers pushing the two parts of the case apart in the process.

Insert a pliers in the gap for the cable tidy 
Open the pliers, splitting the case open 

Voila! An opened magsafe adapter with very little tool marking or scratching to the plastic.

Opened Magsafe adapter

3. Now, bend some of the plastic and copper shielding back around where the cable meets the circuit board to reveal two large solder points. Make a note of where the black cable and the white cable are soldered into the board. To help you, the board should be marked "GND" near the black cable. 

Solder points for Magsafe cable. White is positive, black (GND, cable shield) is negative


4. Using a high power soldering iron, desolder the two points and gently pull the cable from the board. You may find it easier to solder the points by removing the shielding from the circuit board. I left it on here. 
Weller 75w iron
Cable successfully desoldered from Magsafe adapter


5. Taking the cable, use a sharp knife to make a cut after the break in the cable. 

Cutting the good cable from the damaged cable
The damaged part ad grommet removed from the cable


6. Now, using the pliers again, pull the old black wire, and the white wire out of the grommet.  You will be left with a hole in the grommet as shown below. 

Removing the wires from the damaged part of the cable
The grommet, with the outside insulation of the cable left


7. Now, drill a hole all the way through the grommet removing the old cable and some of the grommets plastic along the way. You should make the hole large enough to pass the cable through, as shown below. 

Drilling the outside insulation of the damaged cable from the grommet
Weaving the good cable through the now cleared hole in the grommet


8. After you have passed the cable through the grommet, it is time to prepare the cable for soldering back to the board. Using the sharp knife, remove about 20mm of rubber insulation from the cable. Further remove about 3mm of insulation from the inner white wire. Then tin the ends of both cores using the soldering iron as shown below. 


Removing some outside insulation from the good cable
"Tinning" i.e. applying solder to the exposed positive and negative cable.
 A good tip here is to twist the ends before soldering. 


9. Now, carefully solder both wires back to their respective points on the Magsafe circuit board. 

The ends of the cable correctly soldered into place
on the circuit board. 

10. Place the circuit board back into one of the plastic shells of the cover. If you have done everything correctly so far, the adapter should be able to charge your laptop as this stage. If you are comfortable testing the adapter while the cover is off, do so now. Or else continue with the guide. 

Placing the circuit board back into one of the covers


11. Using a small cable tie, wrap it around the cable as tight as you can just inside the plastic cover. This is done so that the cable cannot be accidentally pulled out of the adapter during use. 

Adding a cable tie to the good cable


12. Run the plastic grommet down the cable back into position in the plastic shell.

Placing the grommet back into the shell

13. Using some glue, make a small bead all around the perimeter of the shell. Use the glue sparingly, but cover all the edges where both halves meet. 

Adding glue to the edge of the shell


14. Press the second half of the plastic shell back onto the Magsafe adapter. Wriggle the two halves to get them into place properly, and then firmly press the two halves back together. 

Squeese the two halves together to make sure that the glue spreads. 


15. Using some large cable ties, wrap them around the Magsafe adapter and tighten them using a pliers. You will need the two halves to be very tight together as the glue dries, or else the two cable tidy arms can fall out.

Adding cable ties around the adapter to make sure that they glue together properly.


16. When the glue has dried, remove the cable ties. You should be left with a working adapter that hardly looks like it was opened at all!

The finished, now working, adapter. 


Unfortunately I accidently ripped some of the rubber off the grommet as I was drilling through it, so go easy on that drilling! I have also repaired a few adapters where the cable has broken and burnt on the connector end. This is a slightly more difficult repair, but I can make a guide if requested.