Piminer Raspberry Pi Bitcoin Miner
Piminer Raspberry Pi Bitcoin Miner
Guide Contents 2
Initial Setup & Overview 3
What you'll need: 3
A note about USB mining devices 4
Install Software 5
cgminer 5
PiMiner 6
Configure Settings 7
Start Mining 8
Run cgminer 8
Run PiMiner 9
Controls 11
Up/Down Buttons 11
Screen 1: 11
Left/Right Buttons 13
Select Button 14
Configure Auto-start 15
How do you stop it? 17
Option 1: Stop mining & shutdown via the SELECT button 17
Option 2: Stop mining without shutting down 17
Next, we can find cgminer's process ID by entering the following: 18
First off, if you're wondering what bitcoins are, Learn more here (https://adafru.it/cgM).
Building this project will allow you to use a Raspberry Pi as a 'headless' controller and status monitor for your USB
bitcoin mining devices. The project incorporates an LCD to display hashrate, error rate, share data, network difficulty,
mining duration, & current exchange rates.
Raspberry Pi (http://adafru.it/998)+ SD Card running Raspbian (http://adafru.it/1121) configured for network access
Adafruit 16x2 LCD + Keypad Kit (any color style will work) assembled & installed
I2C, & Adafruit Pi Code libraries installed on Pi (https://adafru.it/aTI)
USB Bitcoin Mining Device
Powered USB Hub (needed for USB powered miners) (http://adafru.it/961) - most hubs can power up to 4 of these
miners (others may use more or less current). You can always get more hubs, one for every 4 miners!
Mining Pool Account (Login/Password)
Your Computer (for configuration and setup)
Before you start this tutorial you'll need a fully working Pi with network setup and also an assembled Adafruit LCD Pi
Plate.
Cgminer (https://adafru.it/diY) is a cross-platform program for mining crypto-currency with support for SHA-
256 (https://adafru.it/cgB) and scrypt (https://adafru.it/cgC) algorithms, as well as drivers for a broad range of mining
hardware.
To install cgminer on the Pi, we'll first need to connect to the Pi via ssh (https://adafru.it/aWc) or console
cable (https://adafru.it/aUA).
Once you're logged in, ensure all preexisting software is up to date by entering the following:
After the update has completed, Install the all of cgminer's software dependencies by entering:
cd
wget http://ck.kolivas.org/apps/cgminer/3.1/cgminer-3.1.1.tar.bz2
Note: this is not the latest version of cgminer, at the time of this writing, the current version (3.3.1) has issues
communicating with Block Erupter USB on Raspbian
cd cgminer-3.1.1
Configure the software for use with Block Erupter USB devices:
./configure --enable-icarus
Note: Other device types will require specific "--enable" parameters, see cgminer's README files for more
info
make
… and that's all for the cgminer install. Return to the home directory by entering:
cd
PiMiner
The PiMiner software continuously gathers info from cgminer, formats it for display, and responds to button presses on
the 16x2 Character LCD Plate.
Once the download is complete, we're ready to configure settings for our miner.
Update the below template with your mining pool credentials by replacing "PoolAddress:Port",
"UserName.WorkerName", and "Password" with your info, then copy & paste into the nano editor:
{
"pools" : [
{
"url" : "PoolAddress:Port",
"user" : "UserName.WorkerName",
"pass" : "Password"
}
]
,
"api-listen" : true,
"api-port" : "4028",
"expiry" : "120",
"failover-only" : true,
"log" : "5",
"no-pool-disable" : true,
"queue" : "2",
"scan-time" : "60",
"worktime" : true,
"shares" : "0",
"kernel-path" : "/usr/local/bin",
"api-allow" : "0/0",
"icarus-options" : "115200:1:1",
"icarus-timing" : "3.0=100"
}
The above lines containing "icarus" were included for Block Erupter USB devices, be sure to update them if
you are using a different mining device!
For example, if you mine using Slush's pool (https://adafru.it/cgD) you would replace "PoolAddress:Port", with:
"http://stratum.bitcoin.cz:3333",
Once you've updated and pasted the above text, do the following:
Settings are now saved. We'll reference them later when starting cgminer.
If you're mining device is powered via USB (such as the Block Erupter USB, or Klondike1), you'll need to connect it to a
powered hub, which then connects to the Pi. Mining devices which use external power should be happy with either
direct or hub connection.
Run cgminer
Once everything is connected, we'll need to find the address of each device. To List all serial USB devices, enter the
following command:
ls /dev/*USB*
The above shows two USB serial addresses; /dev/ttyUSB0 and /dev/ttyUSB1
We'll pass these to cgminer using the "-S" parameter.
For other types of USB miners, check out the cgminer README files to determine which parameters to use and include
them in the following format (and remove the curly braces!):
sudo nohup ./cgminer-3.1.1/cgminer --config /home/pi/cgminer.conf {add parameters here!} >/dev/null 2>&1&
We'll be using the cgminer startup command later on to configure auto-start. If you customized it, be sure to paste a
copy of it into a scrap text document for later reference.
If you're using USB Block Erupters, you should see the green idle LEDs turn off at this point, indicating that cgminer
has started using them.
Run PiMiner
The LCD should now light up and display your mining info, like so:
The LCD Plate's buttons can be used to adjust the info displayed and control the backlight.
Up/Down Buttons
Pushing the Up or Down buttons will cycle through the available info screens:
Screen 1:
Screen 2:
Screen 3:
Screen 4:
Screen 5:
Left/Right Buttons
The left & right buttons are used to adjust text position when a line contains more than 16 characters. This occurs most
After several seconds the text position will automatically reset to its original position
Select Button
Pushing the select button will toggle the display backlight on/off when using a single color display and will cycle colors
on RGB displays.
We'll need to add our custom startup commands above the last line which reads "exit 0"
The block of code shown below will start PiMiner & cgminer using two USB Block Erupters and is similar to what we
used to start mining manually.
Simply replace the last line with the command you used to start cgminer earlier, but remove the leading "sudo"
cd /home/pi/PiMiner
python PiMiner.py &
cd ..
nohup ./cgminer-3.1.1/cgminer --config /home/pi/cgminer.conf -S /dev/ttyUSB0 -S /dev/ttyUSB1 >/dev/null 2>&1&
Paste the updated code into the nano editor above "exit 0" so that it looks like the following:
Now when the Pi boots up, it will automatically start cgminer & the PiMiner scripts.
Note: the mining startup process can take a minute or two, during which you may notice your mining devices
start, go idle, and then start again.
The easiest way to stop mining is to press & hold the SELECT button for three seconds. After doing so, you should
briefly see this message before the LCD backlight turns off:
At this point, the Raspberry Pi will run through its shutdown routine and halt all processes. You'll need to wait up to 30
seconds before unplugging and/or restarting your Pi.
First, to stop the PiMiner script currently running in the background, we'll need to find its process ID by entering the
following:
The top entry in the list tells us the PiMiner's process ID (4097, in this example).