Code, projects, whatever I'm interested in

Main menu

Bitcoin Mining with the Raspberry Pi and Antminer U1 For Fun

This article assumes a basic level of technical proficiency, and some degree of familiarity with the hardware used.

I recently purchased a Raspberry Pi because it’s about the coolest thing I can think of for under $40. It’s great for little projects because you can use it to solve very easy problems, and more complex problems.

Another interest of mine is the crypto-currency known as bitcoin. I think the entire idea is fascinating, from the cultural impact to the impressively complicated mathematics behind it. I thought it’d be fun to try and build a bitcoin mining rig!

Worth noting: bitcoin mining is no longer profitable for most, this is purely an interesting exercise.

Getting Started

First, my build was guided by an Adafruit project, but I found some things had to be modified to get it to work for me and this particular ASIC device. If you use the hardware in the Adafruit article you can just use their instructions to achieve the same result.

Step 2 (Optional) – Build the Adafruit 16×2 LCD Plate
Assemble and install the Adafruit 16×2 LCD Plate. I bought and used this for my rig because I thought it looked cool, and I liked that I got to assemble it myself. It’s basically a project all on it’s own. For this article, I’ll go over getting the miner set up without using this, and then at the end I’ll show how they can work together.

Step 3 – Set Up Mining
First, plug in your powered USB hub to the Raspberry Pi. The Antminer ASIC device draws too much power to use the Pi’s onboard power.
Next log into your Pi, and let’s get started!

Plug in the Antminer
Plug in your Antminer to the powered USB hub, and then run the following to verify that there is a com device for your USB ASIC.

ls /dev/*USB*

Sign up for a mining pool
To use cgminer, you should join a mining pool. This greatly increases the speed at which new blocks are found, and you share the pot with others. For this tutorial, I’m using BitMinter. There are plenty of others, and they all pay out slightly differently, so I’d suggest you review:Comparison of mining pools wiki

Pool Url: Change this to the one provided by your pool if not using BitMinterUsername: Change this to your username. For BitMinter, it’s your username, underscore, instance name. You just make up the instance name, so username_instance1 would work.Password: BitMinter will accept any password, so most people just use an x.
If you’ve done everything correctly, within a minute or so, Cgminer should start, connect to the pool, and begin processing work for it. You’ll see an overview screen somewhat like the following:

Report Usage on the Adafruit 16×2 LCD Plate
As part of Adafruit’s tutorial on creating a bitcoin mining rig, they offer some Python libraries and utilities to manipulate the LCD screen, and further, to hook into cgminer’s API.
These tools are a great starting point, but the cgminer API implementation is a bit outdated. Adafruit mentioned they are using cgminer 3.1.1, whereas the custom build that supports the Antminer device is 3.8.5. In the time between those two releases, some elements of the API have changed, and as a result, the files provided by Adafruit don’t entirely work. I decided that I would play around with the python a bit myself, and make a dumbed down version that might be easier for novice python users to work with. It removes a lot of functionality, but I think it also makes it a little easier for a novice to see what’s happening.
Repository: https://github.com/tghamm/PiMinerSimple
From /home/pi, do the following:

git clone https://github.com/tghamm/PiMinerSimple.git

Now, if you’ve already got cgminer running, we need to stop it, and re-run it using the nohup command, so that we can return to the console to run PiMinerSimple.
Use Ctrl + if you need to exit cgminer, or, you can always restart the Pi.Now, let’s start cgminer as a background application. It’s almost the same as before, but with a couple of small changes.
From home/pi:

Note: Remember to substitute the correct parameter values! Save the file, and reboot your Pi. When it reboots, both applications should start, and you’ve now got yourself a turn-key bitcoin mining rig!

No problem! That’s strange. I just tried it myself on a clean machine and it works, but I checked over at StackOverflow to see if that had happened to anyone else, Take a look at this: http://stackoverflow.com/questions/12538130/cant-clone-a-github-repo-on-linux-via-https. Does it work if you try using your username like the top answer suggests? Seems like a local git configuration/security thing. Let me know if I can help further, and good luck!