Some links in this post may be affiliate links. We may get paid if you buy something or take an action after clicking one of these, but without addictional costs for you compared to direct buying.

How to mine cryptocoins with a Raspberry Pi

cryptocurrency-miner
0
(0)

Is it really possible? Many people ask themselves if t is possible to use their small Raspberry to earn money in general. With cryptocurrencies spreading all over the world, mining has become really popular and easy to access also with a very simple PC. But, honestly, if you are expecting to generate an income by mining cryptocurrencies, I must advise you that this is really hard – if not impossible – because using RPI means electricity costs, hardware usage (and failure risks) and internet connection costs.

RPI is capable to run only CPU mining, as their GPU is not enough powerful to make mining cryptocurrency efficient. For this reason, you can use it as a miner only for some cryptocurrencies allowing CPU mining (like, for example, Monero, Bytecoin and Litecoin). It will not be possible to use RPI for Bitcoin mining as this cryptocurrency relies on a blockchain using only GPU miners. The same result will occur with other only-GPU cryptocurrencies like Ethereum.

Before entering on how to mine process, let’s dig on main terms related to this topic.

What is Bitcoin?

Bitcoin is a digital currency or a cryptocurrency. An increasing number of businesses today are starting to accept Bitcoin and other cryptocurrencies (such as Litecoin and Ethereum) as a form of payment for products and services.

As a digital currency, Bitcoin is not held in your hand or kept in your pocket. Bitcoin only exists on a digital ledger known as a blockchain. Typically, people keep their bitcoins in a digital wallet.

Bitcoin is not backed by any government, central bank, or precious metal like gold; its value comes mainly from its acceptance as a currency. Some of its value also comes from its scarcity. Only a finite number of bitcoins will ever be mined, and that number is estimated to be 21 million bitcoins. But this is not expected to happen until the year 2140.

Bitcoin was created in 2009, during the banking crisis, as an alternative to traditional banking. It wasn’t always valuable, however. In 2010, bitcoin was worth about 10 cents. Today, one bitcoin is worth over $37,000, and it has been higher.

The idea behind Bitcoin as a currency was that it would not rely on traditional banks for transactions. Due to the fact it isn’t backed by a government, it should therefore not be affected by inflation. Transactions made with bitcoins can be quicker, smoother, and cheaper because the banks are taken out of the equation.

What is a Blockchain?

A blockchain is a digital ledger with information such as dates, amounts, etc. The bitcoin ledger keeps track of transactions and other types of transaction information.

Bitcoin’s blockchain is a decentralized ledger that is transparent on a peer-to-peer network. The blockchain confirms transactions without a need for a central clearinghouse like banks need.

The blockchain is a series of separate blocks in chronological order. Each block of information depends on the previous block. As the process of transaction verification continues, a chain of blocks is created. This is the blockchain.

The blockchain is unbreakable. Once a transaction has been confirmed, it is stored on the digital ledger and is protected by using cryptography. It cannot be deleted or changed without group agreement. Even if one node or computer on the chain breaks, others take its place, and the process continues, which builds trust and transparency in the blockchain.

What is Mining?

Bitcoin mining refers to the verification of transactions and awarding miners new bitcoins for their service. The purpose of mining is to allow Bitcoin nodes to reach a consensus that a transaction is valid, secure and tamper-proof.

As soon as a miner verifies a transaction, all of the nodes (the consensus) will confirm that it is valid and is then added to the blockchain. The cryptocurrency miners will be awarded Bitcoins for their work and new bitcoins are put into circulation.

Bitcoin mining also utilizes a great deal of computer power. Each transaction is sent to everyone on the network. But before the transaction is added to the blockchain, miners must solve complicated cryptographic puzzles.

CPU, GPU and ASIC Mining

CPU, GPU and ASIC are three popular methods for mining cryptocurrencies. CPU stands for central processing unit, and every computer has a CPU. In the beginning, it was possible to mine for bitcoins using a computer with just a CPU. Today, there are still some cryptocurrencies mined using a CPU.

GPU stands for graphics processing unit and is much more powerful than a CPU. GPUs are good for large amounts of calculations. It is still possible today to mine numerous cryptocurrencies using a GPU.

ASIC is an application-specific integrated circuit. Today, most miners use ASIC to mine for bitcoins and other cryptocurrencies such as Litecoin. Most of the large cryptocurrency mines use an ASIC chip because they are specifically built for this purpose.

What is a Digital Wallet?

People keep their personal cryptocurrencies in a digital wallet, and security is crucial because lost cryptocurrencies cannot be replaced. Cryptocurrencies are not protected against theft or fraud like money in the bank is.

A cold wallet is stored offline and is more secure. Hot wallets are connected to the internet and are used to carry around what you might need to spend. They are less secure than a cold wallet. There are also hardware wallets, desktop wallets, paper wallets, mobile wallets and web wallets.

A digital wallet allows users to make electronic transactions with their cryptocurrencies. Cryptocurrency can be bought and sold through exchanges and either put in or taken out of the wallet. Cryptocurrencies are traded similarly to stocks and they are used for purchases such as a cup of coffee, a new computer, or any item as long as the business selling the goods accepts the cryptocurrency as payment.

In this tutorial I will explain a step-by-step guide to use your Raspberry PI as miner. I will use a Raspberry PI 3 model B, but this guide works also with other Raspberry PI boards,

What we need

As usual, I suggest adding from now to your favorite e-commerce shopping cart all needed hardware, so that at the end you will be able to evaluate overall costs and decide if continuing with the project or removing them from the shopping cart. So, hardware will be only:

I strongly suggest evaluating buying a case with a cooling system with fans (for example give a try searching Raspberry PI Case with cooling on Amazon).

I will configure my raspberry by ssh connection from my PC with Putty.

I will also use as mining software “cpuminer-arm” from afritzler. This is a multi-threaded CPU miner, a fork of pooler’s cpuminer and supports a wide number of algorithms. All is simplified using Docker: our CPU miner will run inside a container so that – once installed Docker – enabling it will require a single line command.

You also should choose a mining pool. Please check Solo mining versus pool mining to see the differences between solo mining and pool mining. For example, I use Minergate: this a simple way to start learning to mine. Just signup and get your cryptocurrency mining link.

Step-by-Step Procedure

Prepare your RPI operating system installing Raspberry PI OS Lite.

Once done, proceed installing Docker in your Raspberry PI.

From here we don’t need any dependencies or installation for our container to run.

Choose your coin to be mined: in this example, I will mine Monero. From the terminal, use the following command, changing <<yourEmail@address>> with your Minergate registration email:

docker run -d --name minerd -e ALGO="cryptonight" -e URL="stratum+tcp://xmr.pool.minergate.com:45700" -e EMAIL="<<yourEmail@address>>" -e THREADS="2" afritzler/cpuminer-arm:latest

This command will download (only for the first time) container image and run a container named minerd. “-e THREADS=”2″ ” identify how many CPU you are dedicating to mining. Keep low this value without cooling fans, to avoid hardware failures.

Looking in logs we will see that it is working:

pi@raspberrypi:~ $ docker logs minerd

[2020-06-30 17:20:02] Using JSON-RPC 2.0
[2020-06-30 17:20:02] CPU Supports AES-NI: NO
[2020-06-30 17:20:02] Starting Stratum on stratum+tcp://xmr.pool.minergate.com:45700
[2020-06-30 17:20:02] 2 miner threads started, using 'cryptonight' algorithm.
[2020-06-30 17:20:02] Pool set diff to 2000
[2020-06-30 17:20:02] Stratum detected new block
[2020-06-30 17:20:02] thread 0: 1961878880 hashes, 0.00 H/s
[2020-06-30 17:20:02] thread 1: 1951393120 hashes, 0.00 H/s
[2020-06-30 17:20:48] thread 1: 1951393120 hashes, 0.00 H/s
[2020-06-30 17:20:48] accepted: 1/1 (100.00%), 4.83 H/s at diff 2000 (yay!!!)
[2020-06-30 17:20:55] thread 0: 1961878880 hashes, 0.00 H/s
[2020-06-30 17:21:44] thread 1: 1951393120 hashes, 0.00 H/s

And (after first accepted mine) your Minergate Dashboard will show your active worker.

You can stop / start this docker container when you want with:

docker stop minerd
docker start minerd

You need to stop and remove minerd container to change running options.

Take a continuous look on system temp with the following command:

watch cat /sys/class/thermal/thermal_zone0/temp

which gives you a continuous look to system temperature (divide resulting number by 1000 and you have temperature in °C).

Enjoy!

Check hardware prices with following links:

Amazon raspberry pi boards box
Amazon Micro SD box

How useful was this post?

Click on a star to rate it anonymously!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

10 comments

  1. I am getting this error:
    /usr/bin/ld: warning: libssl.so.1.0.2, needed by /usr/lib/gcc/arm-linux-gnueabihf/6/../../../arm-linux-gnueabihf/libcurl.so, may conflict with libssl.so.1.1
    /usr/bin/ld: warning: libcrypto.so.1.0.2, needed by /usr/lib/gcc/arm-linux-gnueabihf/6/../../../arm-linux-gnueabihf/libcurl.so, may conflict with libcrypto.so.1.1
    make[2]: Leaving directory ‘/home/pi/cpuminer-multi’
    make[1]: Leaving directory ‘/home/pi/cpuminer-multi’
    And the Make process is aborted.
    Did anyone else had this problem and if so, how did you solve it?
    Thanks
    Ilan

    1. Hi Ilan,
      the problem is that libcurl requires OpenSSL shared objects version 1.0.2 (libssl-dev). This issue is the same traced in GitHub (https://github.com/Azure/azure-iot-sdk-c/issues/265). However, currently apt-get installs by default the newer versions (1.1). The workaround should be to downgrade versions for this package:
      sudo apt-get purge libssl-dev
      and install the working version:
      sudo apt-get install libssl1.0-dev
      then compiling should work. I’ve tested in on my RPI and seems to do the trick. I’ve also updated dependencies list.
      Many thanks

    1. Hi Jason,
      you should add “--restart unless-stopped” in your docker run command before image name (“afritzler/cpuminer-arm:latest”) to get docker conainer run after failures/reboot

    1. Hi Luke,
      what do you refer to as Nonce start time?
      Ps: Raspberry PI will never compete with ASICS in mining, as latter have high performance hardware (also expensive) built specifically to mine crypto…

  2. Hi, I managed to run the docker, but not able to connect to URL eth. The error is timeout. Do you have suggestions to ping the URL?

  3. hi,
    i am new to docker but when i launch thje command i get this error:
    Unable to find image ‘afritzler/cpuminer-arm:latest’ locally
    docker: Error response from daemon: pull access denied for afritzler/cpuminer-arm, repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied.
    See ‘docker run –help’.

    1. Hi Luca,
      first thing, try if your docker can get images from docker hub:
      docker run hello-world
      If this works, it’s a remote image problem. If it doesn’t, it is a local problem in your docker installation.

      For first case, you can also use same image by compiling it from github (ref https://github.com/afritzler/cpuminer-arm, section “Build & Push”). You need to install git (sudo apt install git)

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept the Privacy Policy