šŸ„§ Turning My Dadā€™s Raspberry Pi into a Crypto Miner

Nicolas Gatien
8 min readJan 3, 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 šŸ‘‹

--

--

Nicolas Gatien

Hi! I'm Nicolas! A 17-year-old game designer & maker. I build things and write about them!