Turning My Dad’S Raspberry Pi Into A Crypto Miner
January, 2022
I wanted to mine crypto… But I didn’t want to use my laptop. I’m already using most of the computing power for other uses. So I looked around my house a bit to see if there were any computers I could re-use and turn into crypto miners. As I was looking, I found one. This beast of a computer was beautiful. It had served me well in the past, and I was going to use it once again. As I picked up my dad’s palm-sized raspberry pi, I could only imagine the journey to come.
My dad was kind enough to give it to me for free, but that didn’t seem fair at all. I offered to pay him 1/3rd of the cryptocurrency I mine. Alright, with that out of the way, let’s jump into this project!
📦 What the Heck is Crypto Mining?
Ok, fair, yeah let’s go all the way to the start!
Cryptocurrencies are built on a giant decentralized network called the blockchain. Different cryptocurrencies have their own blockchains. Because blockchains are decentralized (no 1 person is in charge of making it work), we need a way to make sure the transactions are legit. That’s where mining comes in.
Miners are in charge of checking whether transactions are real or not. When transactions happen, they are pooled together in a waiting room. Once we have a few piled up, they get grouped into blocks. To confirm or link this block of transactions, miners need to solve a tough cryptographic puzzle.
Before a block is added, they get an equation assigned to them. This is the puzzle. Suppose I gave you 4,386,377 and told you to find which 2 prime numbers multiply to find it. You only have 1 option to solve it. Guess until you find the right 2 numbers.
This is what miners do. They guess, guess, guess as much as possible until they find the right 2 numbers. When they do, the miner gets rewarded with some kind of currency depending on which blockchain you’re mining on.
The answer for 4,386,377 is 2357 * 1861. Again the only way to find that out is to keep guessing until you figure it out. That’s why mining takes so much computational power.
So our Raspberry pi is not going to be an extremely efficient miner. Using a raspberry pi, my hash rate (how many guesses per second) is around 100/s. For context, computers built for mining crypto (like the AntMiner) average 13.5 terahashes (13.5 trillion hashes) per second. So our tiny raspberry pi won’t do this by itself.
That’s why we’re joining a mining pool. A mining pool is when multiple miners join together to combine computational power to find the answers. Then the reward is split among the group depending on how much each member helped.
Alright, with that out of the way, how can you build one of these?
🔨 Build Process!
What you need:
- Raspberry Pi 4
- MicroSD card
- SD Card Adaptor
🥧 Baking the Raspberry Pi
Step #1, download the Raspberry pi OS Lite 64bit Image. You can find that here. You’ll want to navigate to the last one on the list. Inside, the 2nd file has a different Icon from the others. It’s called “2021–10–30-raspios-bullseye-arm64-lite.zip” download that one.
Once that is downloaded, you’ll also need the Raspberry pi Imager. You can download that here!
Step #2, write the OS to your micro SD card. Launch the Rasberry Pi Imager, it should look something like this:
Navigate to the downloaded Raspberry pi OS and Unzip it. Tab back to the Raspberry pi Imager and press “Choose OS”
Scroll down to “Use Custom” (the last option) and click on it. Navigate to your unzipped file, and select it!
Now take your Micro SD card and put it in your Card Adaptor. Put the card adaptor into your computer. Usually, the input for SD cards is on the right side of your laptop. Press “Choose Storage” and select your card!
Now, last thing, press ctrl + shift + x, a pop-up should appear. Scroll down and Enable SSH, set a password for the Raspberry pi. Now scroll a bit lower and configure the wifi, so it connects to your internet on launch.
Press “Save”, and now you can write it to your card!
📡 Getting the IP
Now we need to access the pi to download the mining software. To do this, we need to find its IP.
Our router has an app we can download on a tablet that neatly shows you each device using the internet. Using this, I was able to find my pi’s IP. Otherwise, you should be able to log into your router by typing its IP into your web browser. This didn’t work for me, but I read it in a few places while figuring out how to get the pi’s IP.
🔽 Downloading XMRig
XMRig is a mining program to mine a cryptocurrency called Monero. We’re mining Monero because it isn’t as big as Ethereum or Bitcoin, but it’s still fairly big. So our little Raspberry pi can still help on Monero but wouldn’t do anything on a more extensive network like Ethereum or Bitcoin. Alright, let’s download the software.
We need to access the Raspberry pi. To do this, launch a command line by pressing windows and then typing “cmd”.
Let’s connect to the pi. Type the command below, but replace [IP of your pi] with the IP you got from the step above
ssh pi@[ip of your pi]
Great, incredible, now we’re connected. Let’s update the repositories, type:
sudo apt update
Now let’s download the prerequisites
sudo apt install git build-essential cmake libuv1-dev libssl-dev libhwloc-dev -y
And finally, let’s download the miner from a public Github repository.
git clone https://github.com/xmrig/xmrig.git
Take a quick break while this downloads. Now we need to build the miner from the repository. Let’s navigate to a new folder. First type:
cd xmrig
Next step, we’ll make a new folder and navigate into it.
mkdir buildcd build
And now we install XMRig from the repository.
cmake ..make
Now take a loooooonnnng break.
💻 Launching the Miner
Step #1, To launch the miner, we need a place to store the rewards. Let’s create a Monero wallet. Go to https://www.getmonero.org and download the GUI wallet. Once it’s downloaded, launch it.
Step #2, Create a new wallet.
Name your wallet, and make sure to write down your Mnemonic seed. You can use that phrase to restore your wallet in case you lose it.
Welcome to your Monero Wallet.
What we need is your wallet address. To find it navigate to the account tab on the left. On the right of this page, there’s a small copy button. Press it to copy your wallet address.
Step #3, Now let’s finally launch the miner! Tab back over to the command prompt. Make sure you’re in the xmrig/build directory. If you’re not, type “cd xmrig” followed by “cd build”
And for the final command! Replace yourwalletaddress with the address you copied from your Monero Wallet and nameofyourpi with any username to represent your miner.
./xmrig -o gulf.moneroocean.stream:10128 -u yourwalletaddress -p nameofyourpi
How do I know if I’m mining?
There are 2 types of texts to look for: pink new job messages and green accepted messages.
New jobs are something for the miner to work on, and accepted messages mean that your miner has helped mine something.
Fun Commands:
If you press H, it shows you your hashrate.
If you press S, it shows you your results.
📦 Making the Case
For this step, you might need a bit of extra equipment. I’m fortunate enough to have a laser cutter in my garage, so I just had to find a design, modify it a little bit, and cut it.
This is the design I used as a base. I just added “miner” next to the Raspberry pi icon for my first prototype. This turned out to be too small, and my pi 4 didn’t fit in this pi 3 design xD
So I went back and modified it. I removed all the other inputs and outputs and scaled the box up a bit. Since I only need a power supply to mine crypto, that’s all I left. Here’s the final design if you’re curious.
📈 Final Results
So with all that said and done. You now have a small crypto miner! WOOHOO! 🎉
Let’s see how much I’ll owe my dad by the end of the week.
My dad was kind enough to give it to me for free, but that didn’t seem fair at all. I offered to pay him 1/3rd of the cryptocurrency I mine.
Using a few estimators, we can estimate that if I leave this running all week. I’ll be making 0.03$! This makes it easy for me. I only owe him 0.01$ per week 🤣
So no, this project is not at all meant for profit. If you’re paying the power bills, you’ll probably lose money. But it’s fun! I get an unreal amount of satisfaction when I turn over and see my miner working away on my desk. It’s nice to know I’m helping the blockchain.
I wonder if I could do this with a desktop… NEXT ARTICLE! Subscribe if you want to see it! See you soon 👋