How to mine bitcoin with your Raspberry Pi

Raka Mahesa

October 13th, 2017

Maybe you recently heard stories about people earning a little bit of money by mining Bitcoin on their computer. Or maybe you recently found out that your computer is infested with a Bitcoin miner trojan. Or maybe you simply read an article about Bitcoin mining. Then, maybe you remembered that you have an unused Raspberry Pi in your home and wonder if you can use it to mine Bitcoin. If that's the case, then this post is perfect for you, since we will be discussing everything about Bitcoin mining and Raspberry Pi.

Before we go further, let's make sure we understand all of the aspects involved. After all, Raspberry Pi and Bitcoin mining are quite advanced topics and not some technological terms that you read every day. So with that in mind, let's take a quick refresher course.

Okay, so let's start with the easier topic: Raspberry Pi. Basically, Raspberry Pi is a computer with a very, very small size and sold at a very, very low price. Despite the size and the price, Raspberry Pi is a full-fledged computer that can be used like any computer out there, and of course, this includes Bitcoin mining.

Understanding Bitcoin

Oops, we're getting ahead of ourselves here. So, what is Bitcoin? Well, in the simplest term, Bitcoin is a cryptocurrency, or a decentralized digital cash system. The decentralized part is important, because it means there is no single central entity that controls and records Bitcoin transactions. Instead, anyone who participates in the system can help verify transactions by solving hash calculations. Solving these calculations will reward the person with Bitcoin, and this operation is what people call mining.

So, how exactly are people solving those equations and mine Bitcoin? In general, there are two ways you mine Bitcoin. You can either use consumer-grade, general hardware like a CPU to solve calculations, or you can use hardware customized for mining Bitcoin, which are also called ASIC miners. These ASIC miners can mine Bitcoin much, much more efficiently than general-purpose hardware. In fact, these days, profitable Bitcoin mining operations can only be done using those ASIC miners.

Since this post is about Bitcoin, we're going to use an ASIC miner for our mining operation. But keep in mind that there are some cryptocurrencies, like Ethereum for example, that cannot be mined with an ASIC miner. Since each cryptocurrency is different, it's best to research them separately and not assume that what works with Bitcoin will also work with another cryptocurrency.


We touched a bit about profitability earlier, so let's discuss it further. The main expense of Bitcoin mining is the cost of the electricity needed to run the hardware. So to be profitable, the hardware needs to be efficient enough to earn Bitcoin with higher value than the electricity cost. And since Raspberry Pi isn't exactly powerful, gaining profit from mining with the miniature computer isn't exactly feasible.

If getting profitable from mining Bitcoin with Raspberry Pi isn't possible, is there any point in doing it? Well, for one, it would make a fun side project and you'll learn a lot from doing it. And also, if you have free electricity, like if you live in a dorm or something, that would mean you could earn Bitcoin with zero costs.

Mining Bitcoin with Pi

Okay, enough talk, let's actually do some mining. To mine Bitcoin with Raspberry Pi, you're going to need:

  • Raspberry Pi
  • USB Bitcoin ASIC Miner
  • Powered USB Hub

Having a powered USB Hub is important, because Raspberry Pi can only supply a limited amount of power to a connected USB device. Since a USB ASIC miner can draw a lot of power, having it powered by an external source would easily solve the power problem. Not to mention that with a USB hub you can connect more than a single ASIC miner to the Raspberry Pi.

There are 2 more things to do before we can start mining. The first one is to set up a Bitcoin wallet, a place to store all the Bitcoin we're going to get. The other one is to join a Bitcoin mining pool. By joining a Bitcoin mining pool, you no longer need to single-handedly finish the entire Bitcoin block calculation to earn Bitcoin. Instead, you can earn Bitcoin by just solving a part of the calculation, since now you are working as a group.

All right, the next thing we want to set up is the mining software. For this one we're going to use BFGMiner, a popular mining software focused on mining with ASIC miner instead of CPU/GPU.  To install BFGMiner, you need to first install a couple of additional libraries to our Raspberry Pi, which can be done by executing the following commands on the LXTerminal assuming you're using Raspbian operating system:

sudo apt-get update
sudo apt-get install autoconfautogenlibtooluthash-dev libjansson-dev libcurl4-openssl-dev libusb-dev libncurses-dev git-core –y

With the library set up, you can install BFGMiner by executing these lines:

git clone
cd bfgminer

And now, to actually start the mining operation, connect BFGMiner with your mining pool account and run the application. It can be done by running the following command:

./bfgminer -o <http://pool:port> -u <username> -p <password>

And that's it! Now your Raspberry Pi will use the ASIC miner attached to it and automatically mine Bitcoin. The field of cryptocurrency is a vast one, and this little project we've just finished is nothing but a little peek into that field. There are other cryptocurrencies, or other mining methods that you can use to gain profit more effectively. And if you are interested in actually doing it, you'd better start researching it as soon as possible.

About the author

Raka Mahesa is a game developer at Chocoarts (, who is interested in digital technology in general. Outside of work hours, he likes to work on his own projects, with Corridoom VR being his latest released game. Raka also regularly tweets as @legacy99.