Mine Cryptocurrency with your Raspberry Pi!

A year or so ago I got a Raspberry Pi for the purpose of building an emulation station, which works wonderfully. As time has gone on, I've wondered if there isn't more I could be doing with my Raspberry Pi as it is capable of much more than nostalgic gaming. At the same time, I've become more of a crypto enthusiast as the advent of blockchain technology continues to revolutionize the way people can improve and simplify financial transactions, among other aspects of the computing industry.

My intention isn't to provide a plug for blockchain tech, rather describe a way to combine two interests. Before I get into how to get your raspberry pi to mine cryptocurrency, let's first be honest about the profitability of such an endeavor.

Many mining algorithms are very complex and take a lot of computational power, not to mention, the cost of powering such a system. For this reason, people have to build mining farms to make such an endeavor profitable. Whereas, raspberry pis are energy efficient but they aren't computational work horses.  Getting your pi to mine crypto will be more of a fun project and a way to contribute to crypto projects and mining pools, so don't go in to this expecting to make much money.

With that in mind, this tutorial is designed for beginners and people looking for something to keep their pi occupied while they aren't playing around.

Setting up Your Raspberry Pi

Odds are you are running Ubuntu, or Rasbian on your pi, which will work just fine for this task. Be aware that in order for this to work, you will need to have a functioning OS on your pi. The rest of this post assumes that you at least have the OS and the internet configured.

Before we get to the mining application, we need to make sure all is up to date with our OS so let's go ahead and update and upgrade. Enter the following into the console.

sudo apt update
sudo apt upgrade

With rasbian or Ubuntu up to date, we can go ahead and acquire the application and needed libraries.

Acquiring the Crypto Mining Application

The specific application is cpuminer found on github.  The link I just provided has a lot of useful information, some of which we will be using. The needed libraries are all laid out under the "Build" section of the github page, but I will provide it here as well.

apt-get install automake autoconf pkg-config libcurl4-openssl-dev libjansson-dev libssl-dev libgmp-dev zlib1g-dev make g++
This may take a moment to run. Once this is done we need to pull the application code down from github. Let's first make a folder where we want all of this to reside.

I made a folder called "miner" in the the home directory with the following. Call it whatever you like though.

mkdir miner
cd miner
cd /opt
git clone https://github.com/tpruvot/cpuminer-multi
cd cpuminer-multi
Now that we have everything downloaded, it's time to compile the application. Directions for this is provided in the github page so you can consult that, as well.
sudo ./autogen.sh
sudo ./configure
sudo ./build.sh
Again, this could take a bit. Mine gave me a progress bar, not that gives you a great perspective on how long it will actually take.

Participate in a Mining Pool

There are many mining pools out there like MinerGate, or NiceHash. I found a cryptopool that doesn't require a registration process and is pretty straightforward to use. On the page that I linked, go ahead and click on a cryptocurrency you would like to mine. Let me work through an example with LiteCoin. You will need a crypto wallet address to do this. I manage my crypto through online institutions such as Coinbase, rather than house the wallet locally and accept that risk. You can get the wallet address by selecting the option to receive funds to a specific cryptocurrency. If you don't use an online institution, then you are already very aware of your wallet address.

Now that we have that out of the way, let's put our pi to work! Like I said, I'm going to provide an example with LiteCoin. If you click on Litecoin, then it will provide you with the following.

In this dialog box, we have everything we need to launch our mining expedition. An example of executing the cpuminer miner for this pool would look like the following.

./cpuminer -a scrypt -o stratum+tcp://cryptopools.aod-tech.com:4008 -u xxxxxxxxxxxxxxxxxxx.name -p pps
I'm going to select I low hash rate port because we are working with a raspberry pi, after all. The "-a" option refers to the mining algorithm. These are all laid out in the github page for the mining application. There is a section called "Algorithms" you should consult to select which algorithm is appropriate for a given cryptocurrency.

"-o" refers to the url for the mining pool. "-u" is for the username where I followed the instruction provided by the cyrpto pool sight. That is, all the x's I have in my code represent your crypto wallet address so you would, of course, change all the x's to your specific address. For the password or "-p" I just specified the reward method, and didn't bother with difficulty because those are complicated numbers and depend on the crypto. You would only provide this if you already knew what parameters you wanted to set for you mining session.

With that your mining expedition should be under way. If you have any questions or run into issues acquiring the cpuminer, please refer to the github page.

I hope this was a fun project to play around with on your raspberry pi, and I wish you happy mining!

Comments

Popular posts from this blog

How to Get Started Playing Super Metroid / Link to the Past Crossover Randomizer.

Two-Step fix for rJava library installation on Mac OS

Structural Machine Learning in R: Predicting Probabilistic Offender Profiles using FBI's NIBRS Data