This evening I spent some time setting up my Raspberry Pi to run a BFGMiner service for my AsicMiner Blades.

To get started I first setup the SSH service on the Pi. This was as simple as running the sudo raspi-config command to bring up the Raspberry Pi configuration menu. From here you can select advanced options and enable SSH.

Great! If you’ve done this correctly now you can SSH into your Pi and do the following steps from a more comfortable machine.

ssh pi@   

The next thing to do was to go and grab the source for BFGMiner. The source repository below is latest code from the master branch. This branch may not be the most stable so using a tagged version might be safer.

git clone   cd bfgminer-bfgminer/   

Before I went ahead with building the source I made sure I had all the dependencies installed.

sudo apt-get install build-essential libcurl14-openssl-dev autoconf libtool libncurses-dev yasm curl libcurl4-openssl-dev libjansson-dev pkg-config libevent-de uthash-dev   

There are three steps to building the source. The first step is to initialize any git submodules and (I think) install all the various components of the GNU build system.


The second is a configuration step to create Makefiles. Here you can set some flags like –with-libmicrohttpd but I was lazy and just ran the configuration with all the defaults.


The last step is to build the source. This can take a while…


Nice! Now its time to setup BFGMiner as a Linux service. To do this I had to create an init script.

vim /etc/init.d/bfgminer   
#! /bin/sh # /etc/init.d/bfgminer  case "$1" in     start)     echo "Starting bfgminer"     # run application you want to start     /home/pi/scripts/     echo "...started"     exit 1     ;;   stop)     echo "Stopping bfgminer"     # kill application you want to stop     killall bfgminer     exit 1     ;;   *)     echo "Usage: /etc/init.d/bfgminer {start|stop}"     exit 1     ;; esac  exit 0  

The home/pi/scripts/ is a one line script that has my BFGMiner command which looks something like this.

/home/pi/bfgminer/bfgminer --http-port  -o stratum+tcp:// -u  -p  >/dev/null & 
Note: I decided to put my BFGMiner command in a script because I have other things I’d like to do with it. But it would be totally fine to put this command inside the init script.

I also want this service to run at startup.

update-rc.d bfgminer defaults   

Hurray! Now I can start/stop BFGMiner as a Linux service.

sudo service bfgminer start   

The last thing I wanted to do is give the Pi a static IP address so I wouldn’t have to update my AsicMiner Blades to connect to a different address if it ever gets dynamically allocated.

vim /etc/network/interface   
iface eth0 inet static   address   netmask   gateway   network   broadcast   
Note: Don’t just copy these settings! Make sure you find out your proper gateway (router) and network address. netstat -nr and ifconfig will give you most of this information.

To get these settings to work I had to reboot the Pi. Rebooting the networking service failed and my SSH connection was dropped. However, once the Pi is back up and running and if everything worked out, then your service should have already started!


How to Create a Raspberry Pi Bitcoin Miner

If you don’t know already, Bitcoin is a virtual currency set up in 2009. Bitcoin has grown in reputation over the past few years becoming a very popular as a method to pay for services over the internet. The value has rocketed recently thanks to the huge coverage in the media, for both positive and negative reasons.

There are two ways to get Bitcoin:

  1. Buying them from an exchange, which is the process of converting local currency to Bitcoin.
  2. Mining them. Mining is the process of verifying transactions in the blockchain.

As the whole of the Bitcoin system is decentralised, every transaction is publically viewable within what is called the blockchain. This blockchain contains every bitcoin exchanged between users so, as there is no central server, it has to be self governed. This is the job of the miners.


In order to mine Bitcoin, you will

  • A pool account
  • Bitcoin Wallet
  • Raspberry Pi
  • Raspbian image SD card
  • USB Bitcoin miner

Creating an Account

There are two things you need to do:

  1. Download a bitcoin wallet
  2. Create a pool account
  3. Set up payment
  4. Set up workers

A wallet is a program that sits on your computer and gives you a wallet address, this is a unique string of numbers and letters that you will use to receive bitcoins. Download the client for your computer from

After installation, you will have to save a file called wallet.dat, keep this file safe, as this contains your unique wallet address within it, including all bitcoins that you will gain. If you lose this file, you cannot recover any bitcoins it contained.

Once you have a wallet address, create a pool account. A pool is a huge collection of other people working towards gaining bitcoins. Due to the complexity of mining a bitcoin, it has become unrealistic to solo mine–the act of processing millions of numbers to solve the block problem. Working as a group, or pool, lets everyone have a chance of earning some Bitcoin. There are many pools around, in this tutorial I’ll be using one called Slush’s pool:

Once you have created a pool account, you’ll need to enter your unique wallet address into the Bitcoin payout address.

Next step is to create a worker login account. Within your pool account you have the ability to create something called a worker for each of your bitcoin miners, so you’re able to monitor them all separately just in case one should fail.

Each worker has its own login name and password. Whilst you are on My Account click Register New Worker and give it a name, for example; worker, and a password.

Now you’re ready to set your Raspberry Pi mining for Bitcoin.

Setting Up the Raspberry Pi

Start with a fresh Raspbian install, if you don’t know who to do this, read the tutorial How to Install NOOBS on a Raspberry Pi With a Mac.

If you plan on running more than one Bitcoin miner at the same time, it is best to use a powered USB hub. Take into account the power rating as mining will need a lot of power, as much as one mp per miner.

With your USB miner attached to your Raspberry Pi, let’s get everything installed.

Installing Required libraries

The miner to be installed comes as source files, which means that the program must be compiled into a binary before it can be run. To make a program, in this case BFGMiner, many dependencies are required.

Dependencies are additional software, or libraries the program needs in order to compile properly, as it has been developed using them to make the software more efficient.

Hopefully you will be seeing the Raspbian desktop, so double click on LXTerminal and type in the following:

sudo apt-get update
sudo apt-get install autoconf autogen libtool uthash-dev libjansson-dev libcurl4-openssl-dev libusb-dev libncurses-dev git-core –y

This process will take a few minutes to complete.

Installing BFGMiner

Once all the dependencies have been installed, now it is time to download and install BFGMiner, so type the following into LXTerminal. It’s normal for these to take a few minutes to complete so some patience is needed.

git clone
cd bfgminer

You will be greeted with a screen that looks similar to the following:

Start Mining Bitcoin

Now you’re ready to start mining. To do this, providing you’re using Slush’s pool, you’ll use the following command:

./bfgminer -o -O username.worker:password -S all

The username section is composed of two parts, the username that you use to login to the pool, and worker which is the worker name you gave when you registered the worker. Finally, the password that was set when you created the worker.

If everything works, you will see the main screen that will look similar to this:

That’s a lot of numbers, so I’ll make some of them a bit clearer.

  1. Current mining speed, typically calculated in megahashes or gigahashes. The number of hashes a second that can be calculated the better. A hash is an algorithm of converting numbers and letters into an undecryptable set of characters. So a miner is used to process millions of numbers in an effort to match the hash to guess the original number. The more hashes that can be processed the faster it is able to solve the problem.
  2. Number of accepted shares. A share on a pool is to show the miner has successfully worked out a given problem, so the more shares you can process the better your reward from the pool.
  3. Detailed information on accepted shares and pool updates. This is a running log of what is currently happening with the miners and basic pool information, such as messages of updates and when new blocks are found.

More information can be found at the BFGminer github site.


Following these steps will leave you with a very energy efficient bitcoin miner, as a Raspberry Pi only uses four watts of power, and a miner is typically 2.5W. Mining used to be done with computers consuming over 700W for the same process so to make a jump in savings helps repay the cost of the hardware we are using.

All there is to do now is to sit back and watch the money slowly build up. Though it is important that you understand that Bitcoin value fluctuates wildly, it is extremely volatile, so invest at your own risk.

For more information there are a number of websites and forums available, such as,to help get you started.