š„§ Turning My Dadās Raspberry Pi into a Crypto Miner
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 š