Raspberry Pi for Bitcoin mining (and not only)

I bought a Raspberry Pi for some of my tests and I wanted to build as a Bitcoin Mining machine. Easy;

You Need

One Raspberry Pi Model B+
One MicroSD card (8GB)
One Wireless Nano USB adapter (this one works without the need to place it on a powered hub)
Latest Raspbian version.

Also Needed
One CAR CHARGER 12V – USB 5V
One USB HUB, which should be with a power supply. Because I wanted nothing to be connected on the power socket, but to get power from a solar panel, I got a simple hub and put it along with this, so the USB Stick Miners can be powered properly.

At first, we need to set up Raspberry Pi. It is good to put it in a case so it will not be hit. You first need to install the operating system on MicroSD. To do this, copy the Rasbian’s image to a computer (I tried it on Linux) and connect the MicroSD. When the computer recognizes it, go at the left to the hardware list and press “umount” on this MicroSD card. Then run a terminal window and write this command (Where xxx the name of your device):

sudo dd if=/media/xxx/2014-09-09-wheezy-raspbian.img of=/dev/mmcblk0 bs=4M

Wait for it to finish. To see its progress, open a new terminal window (without affecting the one that is already opened) and put the following command every time you want to check the progress of the writing. Note that the report will appear in the first window, no matter if we put it in the new window.

sudo pkill -USR1 -n -x dd

When it’s over, take yout our card and put it on Raspberry Pi, connect it to the power and wait for it to boot up. Now put the options you want and when you’re done, you’ll see the desktop.

However, Raspberry Pi can not yet recognize the WiFi adapter and so you do not have an internet connection. You need to connect it to a network cable and once you have access to the internet, open a terminal window and put the following commands:

First you will need to upgrade Raspberry to the latest version of its firmware.
rpi-update

If you get a message that there is no command, you need to install it and then run it, so put this command:
sudo apt-get install rpi-update

Now you need to make sure that the upgrading succeeded. So put this command:

uname -a

To me it showed that it was upgraded to version 3.12.33+ #724 (the exact version is important).

Now give theses commands:
sudo apt-get upgrade
sudo apt-get update
sudo reboot

When system reboots, go here and you see the corresponding drivers for each version of the firmware. Next, open a terminal window and give the commands (note the bold points, they should be from the firmware version):

wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20141107.tar.gz
tar -zxvf 8188eu-20141107.tar.gz
sudo install -p -m 724 8188eu.ko /lib/modules/3.12.33+/kernel/drivers/net/wireless
sudo insmod /lib/modules/3.12.33+/kernel/drivers/net/wireless/8188eu.ko
sudo depmod -a
sudo reboot

When system reboots, Raspberry can now connect to the internet wirelessly. One piece is over.
Here you have a fully functional Raspberry Pi and you can use it everywhere. If you now want to use it for mining, do the following to install CGminer (see also here). In a terminal window, put the following commands (note that it takes some time to finish):

sudo apt-get install build-essential libusb-1.0-0-dev libusb-1.0-0 libcurl4-openssl-dev libncurses5-dev libudev-dev
git clone https://github.com/ckolivas/cgminer
cd cgminer
./autogen.sh
./configure --enable-bitfury
make
make install

For the CGminer to run, put the following command, where you have to change the options you need:

sudo cgminer -o <pool url> -u <username> -p <password>

To disable the terminal from going to sleep, when is idle for some time (regardless if the USB sticks working), give the following command:

sudo nano /etc/kbd/config

And there change the following options:

POWERDOWN_TIME=30 should be changed to POWERDOWN_TIME=0
BLANK_TIME=30 should be changed to BLANK_TIME=0

Save the file with control-o and then press control-x to exit.

To disable Raspberry sleep mode, give this command:

sudo nano /etc/X11/xinit/xinitrc

At the end, add the following:

xset s off # don't activate screensaver
xset -dpms # disable DPMS (Energy Star) features.
xset s noblank # don't blank the video device

Save the file with control-o and then press control-x to exit.

Now, in order for CGminer to run automatically every time Raspberry starts, at the terminal give this command:

sudo nano /etc/xdg/lxsession/LXDE/autostart

At the end, add the following:

@/usr/bin/lxterminal --geometry=90x35 -e cgminer -o <pool url> -u <username> -p <password>

Save the changes and restart Raspberry. If everything went well, CGminer will start automatically.

Now, if you want to plug it into a solar panel (or some other power source, eg battery), the source should be at least 12V. Plug in the Car changer to get the 5v needed for the Raspberry and connect the USB hub. The hub should have its own power and not connect it to the Car changer, so that there is no drop in voltage on USB Stick Miners. This way the system can only operate with a battery/solar panel only, with no other source needed. In the photo below you can see the whole system getting power from a battery.

Leave a Reply