Stratum Mining Proxy For Raspberry Pi

Mine Using Your Raspberry Pi With Stratum Mining Proxy

Honestly, when you have as many miners as I do sometimes setting them up gets annoying. Imagine having to setup 20 or more ASIC blades. Having your own stratum proxy not only makes setup easier but stratum improves pool performance. Advantages of stratum is:

  • No more messages like “pool is not providing work fast enough” in miners, because work is produced locally by the proxy
  • Extremely low stale rate (less than 0.1%, that means below 1 stale per 1000 accepted shares)
  • Very low network bandwidth usage (around 10kB/minute)

The best way to have your own proxy is to install it on a Raspberry Pi. They are inexpensive, low power and runs Linux. It doesn’t get any better than that. If you want more information about stratum read the great post on Slush’s website. http://mining.bitcoin.cz/stratum-mining

The following tutorial is a modified version of Slush’s tutorial  for the Raspberry Pi.

What you will need:

Get the Raspberry Pi set up and running your OS. You can follow the tutorials at Adafruit.

Alright, now its time to get to the meat of the tutorial. Open putty or ssh software and connect to your Pi. From here on its copy and paste. Pretty easy.

Lets start off with updating our Pi:

sudo apt-get update

This will download the files we need:

git clone git://github.com/slush0/stratum-mining-proxy.git

We now need to change to the directory where the files are located:

cd stratum-mining-proxy

Now time to download development packages for Python:

sudo apt-get install python-dev

We need to upgrade setuptools package:

sudo python distribute_setup.py

This package needs to have Twisted install. Problem is we need Twisted for the Pi. So, we need to change some files:

sudo nano setup.py

Find:

'install_requires': ['setuptools>=0.6c11', 'twisted>=12.2.0', 'stratum>=0.2.11', 'argparse'],

Change to:

'install_requires': ['setuptools>=0.6c11', 'stratum>=0.2.11', 'argparse'],

That will not install Twisted. You will not get an error saying you dont have enough space.

Now, we install Twisted for Pi.

sudo apt-get install python-twisted

Perfect, that should have installed twisted. We can now install the rest of the libraries:

sudo python setup.py develop

We are almost done. Time to install Screen. Screen allows us to continue running an SSH command even after we have disconnected.

sudo apt-get install screen

Lets start a Screen session. Its simple:

screen

Press Enter or Space to bring up the command line.

Lets get back into the directory:

cd stratum-mining-proxy

Last but not least lets run the script*:

./mining_proxy.py

That’s all. All you need to do is change your miner settings.

Point your miners to the Raspberry Pi ip address and port:

Example: 192.168.1.xx:8332

8332 is the default listen port.

*The script is for Slush’s pool. Not all of us mine his pool. If you need to change it its pretty simple. Instead of running:

./mining_proxy.py

Run:

./mining_proxy.py -o stratum.poolurl.com -p port -sp 3334 -gp 8332

Make sure you change “stratum.poolurl.com” to your pools URL and the port to the pool.

For example I am on Zetpool. I am using:

./mining_proxy.py -o us.stratum.zetpool.com -p 3333 -sp 3334 -gp 8332

That’s all folks. If you have any problems let me know. I will do my best to help. If you found this helpful please donate to keep the tutorials coming.

More from Dennis Stamatoiu

Site Update

Sorry for the lack of posting. The markets have been on fire...
Read More
  • atari_guy

    After doing a ‘sudo apt-get update’, don’t you also want to do a ‘sudo apt-get upgrade’? 🙂

    • dstamatoiu

      Thanks for the reply. ‘Apt-get update’ is to update the repos to the newest version. ‘Apt-get upgrade’ will upgrade old software to the newest ones. This is the part that will takes a long time. I would personally recommend doing the upgrade but would go get lunch while its upgrading. I probably went through 5 SD cards and countless re-install before I installed Twisted manually.

  • gozita03

    any idea what i should enter on my block erupter blade for the address and the port? also what would the address be fore eclipsemc?

    • dstamatoiu

      You need to point the blades to the pi(IP for pi on your network) Example 192.168.1.110 you enter 192.168.1.110,192.168.1.110. The second IP is the fall back IP. The ports are the last 4 digits in the command. Gp- 8832 or whatever you change it to.

  • Vitali Kolosovski

    Thanks for posting. I connected the device
    Asicminer Block Erupter Blade.
    2 units are working properly. 3 pcs not pull.
    Speed ​​of 3 is the same as at 2x.

    • dstamatoiu

      Log in with ssh and type “screen -ls” which will list all the commands you ran. In other words you can see the mining proxy commands. Youll get a list of running commands. Example

      Pi.example.224.1
      Pi.example.225.2

      Most likely you will only have one so Type screen -r nameinlist

      Example
      screen -r Pi.example.224.1

      Press enter and youll see the miner working. Check to see if you are getting errors. The best way is to check if your “pool worker” is to the server and then if its getting an error. If its getting an error you’ll be able to see of the password is wrong. Of its not seen on the list getting work check your IP and port of rig.

      • wild66

        This is my farm.
        More photos at one proxy at all.
        Next everyone has his own proxy.

        • dstamatoiu

          There ins’t a need to have multiple Pi’s unless your using them to do other things like web server, htpc, etc.. Screen is an amazing program. Not only does it allow you to disconnect from an ssh session and keeps your commands running but it also allows you to run multiple commands in different screens. You can use the command “screen” to have multiple proxies running…

          Example in ssh..

          Screen> Enter/space> /miningproxy.py -o poolurl -p poolport -sp 3334 -gp getworkport

          Type Ctrl a c (This will exit the current screen and start a new one)

          now repeat: /miningproxy.py -o poolurl -p poolport -sp 3334 -gp getworkport (This time change the pool url and port to another pool. Also change the get work port to something else.. Example the first one can be 8123 and the second one can be 8234. Then point your miners to those ports.)

          • wild66

            Thanks, I’ll try.
            I thought that the port 8332 can not be changed.
            Now everything is logical.

          • dstamatoiu

            That port can be changed to almost anything. I say almost because you dont want it to be a port that another program uses like 80, 8080, 21.. Etc. I have a VPS server running my server (have friends and strangers connecting to the server wanted iy off my personal network) and it has 10 instances of the server running. (I had 5 on my pi and it ran fine) Each one pointed to a pool and each one has a different get work port. I believe they range from 8330 to 8340. My miners connect to what ever one I want to mine and a backup. I mine zeta, btc, dem, tiger, xjo, uno, open, ltc, stable and anon. Each one has a constant server on. If the server isnt being used it only uses a small amount of bandwidth. I average about 3 gbs per month in bandwidth.

          • wild66

            Thanks, everything works perfectivity.
            You’re writing a script when started running Linux, everything starts immediately …

          • dstamatoiu

            ** Type all commands without quotes “X”…I havn’t been able to test this but should be straight forward. Log into ssh… Type.. “cd stratum-mining-proxy”..This changes directories to the mining software. Type “sudo nano miningserver.sh” This will make a file called miningserver,sh in the proxy folder. Now, time to populate the file with the command to run at startup. Type… “#!/bin/bash
            (New Line)node ./mining_proxy.py -o poolurl.com -p poolport -sp 3334 -gp getworkport (New Line)exec bash.. New line means make sure its on a line of its own. Also, make sure to change the info to your pool. Then press Ctrl x. Then Y… Then Enter. This will save the file and exit the text editor. Almost done. Now time to tell the system to start that command at startup. Type…”sudo nano /etc/rc.local” This is the boot file for linux. After # By default this script does nothing. and before exit 0. Type..”cd stratum-mining-proxy (new line)screen -dmS test ./miningserver.sh” Then press ctrl-x. Then Y, Then Enter. Your pretty much done. Type… “sudo reboot” this will reboot the pi. Wait a few mins. then try it out. After the new years ill have my computer and ill try it out. Sorry, seeing my family and away from my computer. Happy New Years.

  • sturtester

    So I followed your instructions and was able to get the proxy to run on my Pi but for some reason as soon as I start the proxy the CPU usage jumps to 100% and stays there and the miners I have connected don’t operate anywhere near peak efficiencies but they run just fine when I have the proxy running on an old windows box. So I am not sure what I am doing wrong. Any help would be greatly appreciated. Thanks

    • dstamatoiu

      Which Pi are you using? Model A or Model B? Easiest way to tell is Model B has an Ethernet connection where Model A doesn’t.

  • Ben Pople

    I could really do with some help here. I have gotten to the point: sudo python setup.py
    it then says: Traceback (most recent call last):
    File “setup.py”, line 1, in
    x#!/usr/bin/env python
    NameError: name ‘x’ is not defined.
    I’m a complete novice and dont know what ive done. I think twisted has installed correctly.