Wireless Raspberry Pi

I recently acquired my first Raspberry Pi. It is fun to have have such a small computer. I decided that I would make it the “real” brain of a robot. After all, half a gig of RAM of a Raspberry is a lot more than 8 Kb of an Arduino Mega, even when quite a lot is used by the operating system (Raspbian, the version of 9 Feb 2013). But if you look at the foto you can see a lot of wires coming out of the Raspberry: five to be precise. I wouldn’t have my robot to have that drag around. So I started operation “Dwire Raspberry”.

A fully wired Raspberry-Pi

A fully wired Raspberry-Pi

Wires

What are all these wires for? Let’s sum up:

  1. HDMI for the monitor
  2. Keyboard USB cable
  3. Mouse USB cable
  4. Ethernet cable
  5. and the power chord

In fact our job is a little easier than it looks like. We need the first three wires for communicating with the Raspberry Pi, to establish a terminal. The fourth wire might be replaced by a Wifi adapter. The last wire cannot be eliminated. There are magnetic plates to load mobile devices but they are still quite new and I am afraid that the strong magnetic field might interfere with the sensors of my robot. On the other hand, my robot needs power as well and that is drawn from a battery. If I can connect my Raspberry to a battery I feel that I have dewired my Raspberry sufficiently.

The job is thus reduced to:

  1.  create a terminal session over the network (remove 3 wires
  2. create a Wifi connection (remove 1 wire)
  3. power the Raspberry by a battery (remove 1 wire)

Create a terminal session over the network

This is both easy and not so easy. I here describe a solution for Windows. However, in my quest for solutions I noticed that there were plenty products available for other platforms, notably for Mac and Linux.

A terminal program moves the communication with the Raspberry to another PC. Just establish a connection from your PC, via a terminal program, to your Raspberry and 3 wires are eliminated: screen, keyboard and mouse. Terminal programs are avilable on all platforms and Putty is a good solution for Windows.

Install Putty, run it and enter the host name of your Raspberry-Pi. Raspbian has SSH communication up and running, so choose SSH for secure communication. A terminal window is shown in which you enter your user name and password. When correct you have entered a Linux session on the Raspberry Pi. You now may disconnect *three* wires: the keyboard, the mouse and the monitor.

The not so easy part is having a remote desktop on your local machine. This I will discuss in the last chapter because it requires you to change your network settings.

Wifi connection

The next step was to replace the fixed network connection by a Wifi connection. There are several articles on how to do this, I found those from PingBin and AdaFruit quite useful but there are many more. I bought an Edimax EW-7811Un nano wireless adapter and plugged it into the USB port (hey, you freed two USB ports by installing Putty). Now you need to edit two files: /etc/network/interfaces and the supplicant file. The interfaces file should look like this

auto lo
iface lo inet loopback

iface wlan0 inet static
  address 192.168.178.101
  netmask 255.255.255.0
  network 192.168.178.0
  broadcast 192.168.178.255
  gateway 192.168.178.1

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

and /etc/wpa_supplicant/wpa_supplicant.conf should look like this:

network={
ssid="your ssid"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="your password"
}

Reboot and it should work. If not, consult the forums.

For reasons that I will mention later I needed a fixed IP address. I could fix this via the router, but I decided to handle this in the interfaces file.

And again one wire through the drain. We are making progress.

Power

The Raspberry Pi documentation works on a USB adapter which gives (about) 5V of power. For my dewiring purpose I should connect it to a battery of 5V.

You could try three AA batteries (4.5V), but I noticed that the Raspberry is quite sensitive for low voltage and the documentation warns against using a voltage too high. And anyhow, my robots work on a LiPo battery of 7.4V. I have to scale down this voltage to 5V. This is what an Arduino does standard, so there must be ‘things’ that scale down to the requested voltage. These things are called a voltage regulator. When looking around for these things I stumbled apon a BEC in the model building world which does the same thing. I buy them at 4RC but of course you can buy them everywhere, HobbyKing for example.

Now all is very simple. Connect the the battery to the BEC and next connect the BEC to the Raspberry-Pi and all is well. Ah, but how to connect? I use internally all T-plugs to connect batteries, BEC’s and so on. And I soldered one connector from T-plug to micro USB.

Diagram of a Micro USB connector. For the power requirements only the Vcc (= voltage +) and the GND (ground) are required. Buy a cable, cut the micro USB about 10cm below the plug and bare the Red (+) wire and the Black (ground) wire.

Diagram of a Micro USB connector. For the power requirements only the Vcc (= voltage +) and the GND (ground) are required. Buy a cable, cut the micro USB about 10cm below the plug and bare the Red (+) wire and the Black (ground) wire.

Of course you bought a LiPo with a female T-plug. Solder a Male T-plug at the receiving at of the BEC, a female T-plug at the 5V end, and a male T-plug at the micro-USB.

 It is quite important that you connect the + to + and ground or – to ground. Tradition has it that Red wires are + and Black wires are ground. Stick to tradition to avoid unwanted smoke and sparks. Batteries have a lot of current, esepcially LiPo’s. Wrongly connecting them may ruin your BEC or Raspberry Pi. The main use of T-plugs or similar plugs is to prevent swapping + and ground. 

Connect it all and when there is no smoke, no sparks, it might work, just see the foto below.

A Raspberry Pi all ready to roam around unhindered by wires.

A Raspberry Pi all ready to roam around unhindered by wires.

If you are new to LiPo’s be aware of the difficulties that go with them. There is a simpler way, connect a 9V battery to the BEC.

Diagram of a 9V battery.

Diagram of a 9V battery.

Take the connector of a 9V battery, solder a to female T-plug and you can go thru the same routine of above. It saves you the cost of a LiPo charger.

With this I considered project Dwiring Raspberry PI succesful. I am now able to mount it on a robot and program it remotely. I did one extra thing though and that was trying to get a remote desktop of the Raspberry on my local machine. That wasn’t easy and is treated in the next paragraph.

Remote desktop

[Here comes the story of how to remote desktop to your Raspberry Pi]

About Arnold

I compose music and love to write software so I write software to compose music. Somewhere in that proces I got attracted to robots. Probably this all makes few sense but it is fun.

Category(s): Robots

Leave a Reply