With Bitcoins traded at nearly $ 14,000 per bitcoin, maybe the time has finally come for me to get into the cryptocurrency game? Instead of buying bitcoins, could I instead use my Raspberry Pi to mine bitcoins?
What is cryptocurrency mining?
Crypto mining is the digital version of mining for gold, which combines performing complicated calculations and pure luck (being the first to complete the calculation) with your computer. Mining is essential for cryptocurrencies in order to maintain their distributed ledger, also known as the Blockchain.
Although Bitcoin is the best known form of cryptocurrency, it is certainly not the only game in town. All forms of cryptocurrency use blockchain to keep each transaction valid and prevent someone from fraudulently spending their coins more than once.
Is Bitcoin Raspberry Pi Mining Profitable in 2020?
My initial research showed that bitcoin mining with any consumer grade computers are not profitable when the cost of electricity and hardware is taken into account. Most bitcoin mining is now done ASIC Bitcoin Miners; hobbyists and individuals can find limited success by joining a mining pool, harnessing the power of a group of distributed computers. What if we entered a mining pool, used solar panels to power our Pi, and “wiped out” the cost of our hardware? Bitcoin mining is an extremely competitive venture with too many other miners, increasing difficulty levels and lower rewards for miners.
Despite this dark and fatal news, I have decided to move forward with this project and set my sights on alternative cryptocurrencies. At the time of this writing, there are finished six thousand alternative cryptocurrencies traded today.
Mining pools
Individual cryptocurrency mining was out of the question as we are using a Raspberry Pi and not a file ASIC Bitcoin Miner. I looked at several groups of mining pool software that I could participate in; most had options for Windows and MacOS; there were no mining pools with Raspberry Pi support. Raspberry Pi is not supported by Linux miner software due to its ARM architecture. Supported Linux mining software is based on the x86 processors found in typical PCs.
Disclaimer: This article is presented as an educational opportunity to spark interest in learning more about blockchain and cryptocurrency, and not necessarily to generate cryptocurrency. The methods described in this article are tricks and not officially supported. The easiest and fastest method is to download and install the free software associated with the mining pool of your choice on your PC.
What you will need for this project
This tutorial is based on terminal commands. If you are unfamiliar with terminal commands on your Raspberry Pi, we highly recommend that you review them 25+ Linux Commands Raspberry Pi users need to know first
How to mine for cryptocurrency on Raspberry Pi
We will start by creating our account with Minergate, a cryptocurrency mining pool with 3.5 million users worldwide for Bitcoin Gold, Zcash, Ethereum, Ethereum Classic and Currency. This tutorial is specific for mining Currency as it was the only cryptocurrency I have had some level of success with.
2. Start your Raspberry Pi. If you don’t already have a microSD card see our article on how to set up a Raspberry Pi for the first time or how to run a file Raspberry Pi headless installation.
3. If you are using the Raspberry Pi operating system with Desktop, open a terminalor press Ctrl-T. If you’re using Raspberry Pi Lite, log in as you normally would.
4. Once in the terminal, perform the following updates and install the necessary dependencies:
sudo apt-get update && sudo apt-get upgrade -y
sudo apt install git automake autoconf libcurl4-openssl-dev libjansson-dev libssl-dev libgmp-dev
cd cpuminer-multi
5. Now, let’s go compile the mining code with the following three commands. This step will take a couple of minutes on a Raspberry Pi 4.
sudo ./autogen.sh
sudo ./configure
sudo ./build.sh
6. After we have created and configured our mining software on our Raspberry Pi, let’s start mining Currency! Enter the following terminal command to start the miner, replacing YOUR_EMAIL with the email address you used to subscribe to yours Minergate account.
./cpuminer -a cryptonight -o stratum+tcp://xmr.pool.minergate.com:45700 -u YOUR_EMAIL
You should see the mining software start and hopefully see some “accepted” shares with “yes!”
7. We do check your Minergate Dashboard by accessing https://minergate.com/internal. You can do this on a Chromium browser if you are using Raspberry Pi Desktop or on your PC. Scroll down until you see Monero. If everything works, your Monero status will indicate ONLINE. Congratulations! Now you are digging for Monero!
How to start Raspberry Pi Crypto Mining on startup
To automatically start our cryptocurrency miner upon startup on our Raspberry Pi, we will use the Crontab method.
crontab -e
If you haven’t set up the crontab before, you will see the answer “no crontab for pi, select an editor”.
1. Type 1 ‘ and hit log into.
2. This will open a new crontab file, arrow down to the end of your crontab file and enter the following command, replacing YOUR_EMAIL, with the email address you used when you create your Minergate account
@reboot sudo /cpuminer-multi/cpuminer -a cryptonight -o stratum+tcp://xmr.pool.minergate.com:45700 -u YOUR_EMAIL
4. Press Ctrl-X, is Y to save yours crontab.
5. Now restart your Pi typing ‘sudo reboot‘ in your terminal.
How Much Monero Did I Mine With Raspberry Pi?
My Raspberry Pi 4 calculated 357 good actions in about 8 hours of autonomy. The miners are rewarded good actions. Bad deeds are calculations where I found the right answer, but my Pi produced the results slower than another computer. Miners are only paid when they submit the correct answer first. Invalid Shares they are the worst as a miner is penalized for each invalid quota due to possible fraudulent activity. I was a little worried when my first 4 shares were marked as invalid shares.
357 good deeds = 0.000001410642 Currency = 0.00015569 USD
I earned the equivalent of 1/100 of a cent in 8 hours.
To collect my Monero, I needed a minimum of 0.05 Currency, approximately equal to $ 5,811 USD. (Exchange rate at the time of this writing.) At a pace of accumulation 0.000001410642 Monero for 8 hours, it would take me 3,762 years to reach the minimum withdrawal threshold of 0.05 Monero.
Lessons Learned About Raspberry Pi Crypto Mining
As stated at the beginning of this article, the purpose of this exercise was to learn about cryptocurrency and not make a profit.
- The rewards of cryptocurrency mining are calculated based on the shares and hash rates. My hash rate ranged from 1.6H / s to 33.3H / s. The average hash rate for the pool was 10.27 MH / s, about 3 million times my Pi’s hash rate. For reference, 1 MH / s is 1,000,000 hashes per second.
- The mining pool company (in this case Minergate) also charges a small transaction fee. You have the option to choose the commission based on luck (higher risk, higher reward) or Pay Per Share (higher commission for Minergate, but less risk).
- At various points during the writing of this article, my Pi had numerous “timeout” and “send_line failed” errors. Sometimes a restart of the Pi helped, and sometimes the miner would eventually start working again without human intervention.