Bitcoin Mining on Your Raspberry Pi

Introduction: Bitcoin Mining on Your Raspberry Pi

About: Born in Austria. Began to learn coding in 2015. Passionate software developer ever since. Skilled at Javascript, PHP, C#, Java and C. Always excited to learn new things.

Bitcoin is a cryptocurrency, a form of electronic cash. It is a decentralized digital currency without a central bank or single administrator that can be sent from user to user via the bitcoin network.

There are two main methods for obtaining bitcoin: mining and purchasing. In this tutorial we will focus on cryptocurrency mining on the Raspberry Pi!

Supplies

For your bitcoin miner you need the following equipment:

Step 1: Construction

Raspbian, or any other appropriate operating system must be installed on the Raspberry Pi.
Construction
  1. Plug in the power adapter of the Raspberry Pi adapter and connect it to your Pi
  2. Connect the Pi to the internet
  3. Plug in the power adapter of the USB Miner and connect it to the USB Miner
  4. Connect to USB Miner to your Pi, by plugging the USB into the Raspberry Pi and the other end into the USB Miner

Step 2: Check for Updates

Type in this command to check for updates:

sudo apt-get update

You might have to upgrade your operating system too, if its a older version:

sudo apt-get upgrade

Step 3: Create a Bitcoin Wallet

To receive your mined bitcoins, you need a wallet to save them. The two general types of Bitcoin wallets are online and offline.

An online wallet requires internet connection. You have to enter your username and password to access your wallet from any device and you don't have to worry about its backup and maintenance.

Offline wallets store your bitcoins on a computer, so they do not require an internet connection. Such wallets require a lot of space on your hard drive and you are fully responsible to your wallet. It is recommended to make backups weekly and save it on multiple devices. If you loose your wallet, because your computer is broken and you have no backup, then all your bitcoins are gone.

How to create an online Bitcoin Wallet?

  1. Go to coin.space
  2. Click on 'Create new wallet'
  3. Click on 'Generate passphrase'
  4. Save the passphrase somewhere, where you will find it again and make several backups of this passphrase
  5. You have to agree, that you have written down or otherwise securely stored your passphrase and you have to agree to the terms & conditions to continue.
  6. Click on 'Set your PIN'
  7. Set a PIN for quick access

You have now successfully created a bitcoin wallet!

Step 4: Enter a Mining Pool

A mining pool is the pooling of resources by miners, who share their processing power over a network, to split the reward equally, according to the amount of work they contributed to the probability of finding a block.

How to enter a mining pool?

  1. Sign up to Slushpool
  2. Open the profile settings (click the user icon on the top right corner > click on 'Settings')
  3. Click on the 'Bitcoin' tab
  4. Click on 'BTC Payouts'
  5. Add your wallet address (on Coin Space, the address can be found by clicking on receive)

You are now part of a mining pool!

Optional:
You can create workers by clicking on the workers tab and 'new worker'. 'worker1' is already created during the registration process.

Step 5: Install the Miner

The miner is responsible for the actual mining part. It uses the power of the USB Miner and searches for blocks. In this tutorial we use cgminer, a multi-threaded multi-pool miner for bitcoin.

  1. Install the dependencies
    sudo apt-get install libusb-1.0-0-dev libusb-1.0-0 libcurl4-openssl-dev libncurses5-dev libudev-dev screen libtool automake pkg-config libjansson-dev screen
  2. Clone the cgminer repository from github
    git clone https://github.com/bitmaintech/cgminer
  3. Install and configure the miner
    cd cgminer
    sudo ./autogen.sh
    export LIBCURL_CFLAGS=’-I/usr/include/curl’
    sudo ./configure --enable-bmsc
    sudo make
  4. Start the miner
    sudo ./cgminer --bmsc-options 115200:0.57 -o POOL -u USERNAME -p PASSWORD --bmsc-voltage 0800 --bmsc-freq 1286

POOL: the url to the pool. Default: stratum+tcp://stratum.slushpool.com:3333

USERNAME: [your_slushpool_username].[your_worker] Default: yourusername.worker1

PASSWORD: anything, you don't need to enter your login password

For more information about available pools on slushpool click here.

I highly recommend using a cooling case for your Raspberry Pi, to avoid overheating.

Step 6: Automatically Start the Miner on Boot (optional)

  1. Edit the 'rc.local' file
    sudo nano /etc/rc.local
  2. Just above 'exit 0' add the following lines with your slushpool credentials
    cd /home/pi/cgminer
    screen -dmS cgminer ./cgminer --bmsc-options 115200:0.57 -o POOL -u USERNAME -p PASSWORD --bmsc-voltage 0800 --bmsc-freq 1286

-

That's it! You can now mine your own bitcoins. If you have any more questions, don't hesitate to contact me.

Happy mining!

IoT Challenge

Participated in the
IoT Challenge

Be the First to Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Fandom Contest

      Fandom Contest
    • Stone, Concrete, Cement Challenge

      Stone, Concrete, Cement Challenge

    15 Comments

    0
    lexar902
    lexar902

    Question 2 months ago

    Now that the USB miner you have link is no longer available, would any usb btc miner work?

    0
    supplyguy701
    supplyguy701

    Question 3 months ago on Introduction

    I'm getting no device detected any ideas what I might be doing wrong?
    Thanks in advance.
    cgminer version 4.9.0 - Started: [2021-04-01 22:23:31]
    --------------------------------------------------------------------------------
    (5s):0.000 (1m):0.000 (5m):0.000 (15m):0.000 (avg):0.000h/s
    A:0 R:0 HW:0 WU:0.0/m
    Connected to stratum.slushpool.com diff 8.19K with stratum as user **********.
    Block: 70c40683... Diff:23.1T Started: [22:23:31] Best share: 0
    --------------------------------------------------------------------------------
    [U]SB management [P]ool management [S]ettings [D]isplay options [Q]uit
    --------------------------------------------------------------------------------
    [2021-04-01 22:23:29] Started cgminer 4.9.0
    [2021-04-01 22:23:30] No devices detected!
    [2021-04-01 22:23:30] Waiting for USB hotplug devices or press q to quit
    [2021-04-01 22:23:30] Probing for an alive pool
    [2021-04-01 22:23:30] Pool 0 difficulty changed to 8192
    [2021-04-01 22:23:31] Network diff set to 23.1T

    0
    robertbrann18
    robertbrann18

    Answer 2 months ago

    I am getting the same error

    0
    alexposcher
    alexposcher

    Reply 2 months ago

    Have you plugged in the power plug?

    0
    supplyguy701
    supplyguy701

    Reply 2 months ago

    We have a be nice policy.
    Please be positive and constructive.
    This is the message below my response window so i'm not going to be an a&*hole
    My cable management sucks but it appears to have power so yeah. thanks for your input

    WIN_20210506_19_54_26_Pro.jpg
    0
    alexposcher
    alexposcher

    Answer 3 months ago

    Hi,
    thanks for your interest in my instructable! I have been trying to reproduce the issue, unfortunately it is working on my device. Maybe you have to install a driver for the AntMiner?

    0
    buronleopold
    buronleopold

    6 months ago

    Hello,
    How many USD or BTC the Pi is able to mine ?
    Thanks

    0
    alexposcher
    alexposcher

    Reply 6 months ago

    In one month you get about 0.000012 BTC.

    0
    greysolive13
    greysolive13

    7 months ago

    I think it's better invest in blockchain technologies, they will be profitable in the next few years. I'm working on my blockchain business development right now too. Hope I'll attract more target audience to get profit. I heard many positive reviews about this marketplace https://bitmedia.io/ and they provide effective and affordable ads with flexible pricing models.

    0
    barzillialloyd
    barzillialloyd

    Question 1 year ago

    Hi, how can more raspberry pi be linked up in such set-up for mining?

    0
    alexposcher
    alexposcher

    Answer 1 year ago

    The first thing that comes to my mind, is setting up a second environment with another Raspberry Pi and another Miner. You could control the Pis with a main application on your PC coding an app for this.

    0
    JanoschS1
    JanoschS1

    2 years ago

    This is really cool! I've heard of bitcoin mining but whould have never thought of someone using a Rapberry Pi!

    0
    alexposcher
    alexposcher

    Reply 2 years ago

    Thanks! I am really interested in mining cryptocurrency. Using a Raspberry Pi wasn‘t the first thing that came in my mind, but then I realized, using a Pi is really energy efficient. If you use some more Pis you could even make some money.

    1
    Shanedolin
    Shanedolin

    Question 2 years ago

    With just one of these running, how long would you say before One Bitcoin is rewarded?

    1
    alexposcher
    alexposcher

    Answer 2 years ago

    Using just one miner would take about a thousand years until you get one Bitcoin. If you want to do this profitable you would probably need about 50-100 of these to get a serious amount of money.