Raspberry Pi WIFI multiple networks

I have no idea why I had so many problems setting up a Raspberry Pi to connect to multiple networks in the past… but it is actually really simple. I needed my Raspberry Pi to connect to different wireless networks when I plugged it in a different location. (And just to be on the safe side, also connect to my mobile’s hotspot)

Setting up wpa_supplicant.conf

In the file wpa_supplicant.conf you need to specify each wireless network’s SSID, PSK (Wifi key/password) and an ID.

Open wpa_supplicant.conf

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf 

Add the following for each of your wireless networks, providing a ID for each:

    ssid="Wireless SSID Here"
    psk="Wireless Key/Password"

My Example:



Configure Network Interfaces

Open network interfaces

sudo nano /etc/network/interfaces

Add the following lines for each of your wireless networks

iface [NetworkID from WPA_Supplicant] inet dhcp


My Example




 It is pretty easy to add multi wireless networks. To make sure I can always access my pi headless I got it to connect to my mobile’s hotspot, this has been very useful as I have a SSH app on my phone and can connect directly to my Pi when I do not have a monitor or keyboard handy. You can also set a static ip for different networks.

Mining BitCoins with a Raspberry Pi

Ok, so Bitcoins have been around for a while now. It has crashed twice and maybe a little late in the day to ‘get rich’ from mining coins. Anyway! I wanted to learn about Bitcoins and the mining process. This project is purely for interest and I do not expect to profit from it at all. I had a Raspberry Pi sitting around gathering dust so I decided to try to use it to mine bitcoins. This is how I did it.

Getting Started

I looked at ways of mining online, and for a raspberry pi the only way was to use a USB ASIC device. I started by getting all devices I needed. Here is what I used:

Qty  Item  Price (GBP)
1 Raspberry Pi
1 D-Link 7-Port Powered USB Hub – Model DUB-H7 (eBay) £22.00
5 USB ASIC Bitcoin Miner Block Erupter (eBay) £20.00 (Each)
1 Arctic Cooling Breeze Mobile USB Fan (Amazon) £10.00
1 Adafruit 16×2 LCD + Keypad Kit (Pimoroni) £21.00
1 USB Wifi (Pimorono) £8.00



To start I had to get my Raspberry Pi (RPi) to wireless connect to my router. This was because I cannot get a cable from my RPi to the router. I had a great deal of trouble trying to get the Wifi working! I was only using the command line over SSH. I found several websites telling me to do different things and none seemed to work. I finally got it working using a mixture of different websites, I’ve posted my solution here.


LCD Screen

Adafruit has a LCD kit which is fantasic. It sits perfectly on top of the Pi showing information. If you want to get one then head to the Adafruit website for full instructions.

Install the latest version of Raspbian

I had used my RPi for different things before, so I wanted to have a clean install of Raspbian. At the time of writing, Raspbian wheezy is the latest version.

Getting it working


Connecting it together

I have my five USB Block Erupters connected to the powered USB hub. The USB fan also connected to the hub to keep the Block Erupters cool. The hub is then connected to my Raspberry Pi. I did try to have the USB hub power the Raspberry Pi, however it didn’t work.

Installing the Software

I’m using cgminer, which is a program that can used to mine Bitcoins. To install it first we need to install the software that cgminer depends on. I used the following command to install it:

sudo apt-get update

sudo apt-get install libusb-1.0-0-dev libusb-1.0-0 libcurl4-openssl-dev libncurses5-dev libudev-dev

I spent many hours trying to get cgminer working, for some reason I could not get many versions to work on my RPi. Some would not make, open or would freeze after about 10 minutes. After hours of trying many different versions I got cgminer 3.8.5 working.

wget http://ck.kolivas.org/apps/cgminer/3.8/cgminer-3.8.5.tar.bz2

Once downloaded, I uncompressed and opened the directory.

tar xvf cgminer-3.8.5.tar.bz2
cd cgminer-3.8.5

Next I needed to configure cgminer to work with my USB Block Erupters

./configure --enable-icarus

And make the program

sudo make

As long as no errors appeared then everything should be good!

Creating the config file

I created a new file called cgminer.conf. This is where I placed all my details for mining pool. I’m using Bitminter.com as I found it easy to use. You should do your own research and choose a pool that you trust.

sudo nano cgminer.conf

I found this example config file from learn.adafruit.com.

"pools" : [
        "url" : "PoolAddress:Port",
        "user" : "UserName.WorkerName",
        "pass" : "Password"
    "api-listen" : true,
    "api-port" : "4028",
    "expiry" : "120",
    "failover-only" : true,
    "log" : "5",
    "no-pool-disable" : true,
    "queue" : "2",
    "scan-time" : "60",
    "worktime" : true,
    "shares" : "0",
    "kernel-path" : "/usr/local/bin",
    "api-allow" : "0/0",
    "icarus-options" : "115200:1:1",
    "icarus-timing" : "3.0=100"

Example my “url” is set to “http://mint.bitminter.com:8332”. Bitminter sets their usernames as your username, an underscore and then worker name. Other sites I’ve seen username, dot and then your worker name. Once you have completed your settings in Nano press CTRL-O to write the file, then Press CTRL-X to close nano.

Start Mining.

Everything should be ready! I started mining by typing the following command.

sudo ./cgminer-3.8.5/cgminer --config cgminer.conf

This command opens cgminer and start mining Bitcoins! To quit press q.


PiMiner is a piece of software written by Adafruit that displays information from cgminer on the LCD display. This makes it very handy to see stats without having to log into the RPi. To install it, ensure that your LCD screen works and run the following commands.

git clone https://github.com/adafruit/PiMiner.git
sudo python PiMiner/PiMiner.py &

Your LCD screen should now show the details of cgminer (When cgminer is running)

Make it run automatically when you turn on your RPi

To make cgminer and PiMiner automatically run on boot, follow these instructions.
Open rc.local

sudo nano /etc/rc.local

Add the following code to rc.local above “exit 0”

cd /home/pi/PiMiner
python PiMiner.py &
cd /home/pi
nohup ./cgminer-3.8.5/cgminer --config cgminer.conf &

It should look something like this


Complete! You should now have a working RPi mining you Bitcoins.


And finally

I never started this project to make money. In fact I expected to lose money buying all the equipment etc. It was more to learn how to set up a Bitcoin miner. I have completed this project and gained a lot of knowledge from it. I will keep my Pi running for a few days and may decide to sell all the ASIC miners back on eBay.

Raspberry Pi Wifi Static IP Address

I’ve had a Raspberry Pi for a number of years before I decided to actually start playing around with it. I used to sit in the other room where my wireless router is and connect my RPi with a ethernet cable. But I wanted to have it wireless, so I could use my RPi it in my room. It took me a long time to manage to get the Wifi working. I looked at many different websites and forums. I finally got it working and here’s my solution.

I have my adaptor plugged in to my Raspberry Pi without any other USB devices. Once set up I now log in to my Raspbery Pi over SSH. My Wifi network is secured with WPA2. I wanted to use a static IP address so I can easily connect to it using SSH.


Getting it working

Configure the Network Interface

First I edited the network interface file.

sudo nano /etc/network/interfaces

For the wlan0 interface (For the wireless connection) I set up my static IP. I found some posts on forums saying to add the SSID and wireless key in here. However everytime I tried, it would never connect. I found other places using the ‘wpa_supplicant’. After trying different configurations I managed to get the ‘wpa_supplicant’ working perfectly.

allow-hotplug wlan0
iface wlan0 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

The configuration should look like this.


Then save the file with CTRL + o and close nano with CTRL + x

Setting up wpa_supplicant

Next I opned up the wpa_supplicant config file.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Here is my configuration, under I will explain each part.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

ssid The name of your wifi network

proto RSN is for WPA2. You can use WPA for WPA1

key_mgmt WPA-PSK is the pre-shared key setting.

auth_alg OPEN is needed for WPA & WPA2

psk The pre-shared key AKA Your Wifi Password

Again save (CTRL + o) and close Nano (CTRL + x).

Reboot and test

Try rebooting your Pi and it could connect over WiFi.

sudo reboot

And finally

There seems to be many ways of setting up WiFi on the Pi, this is just one way that I have managed to get working.