DIY Bitcoin Lottery With Raspberry Pi




About: I'm a content creator. I make open source projects and videos for said projects. My goal is to create free and open knowledge for everyone.

There was a time when I was really into Bitcoin mining. I had a bunch of GPUs running and it was a fun hobby that surprisingly made me a little money as well. It was a fun experiment but I eventually ran out of time to play around with it, and it was a good time to sell everything, so that is what I did. I kept a few of the small ASIC block erupters. Fast forward 3-4 years, Bitcoin is in the news again $4000 US for 1BTC. Crazy! So I made this fun little device that will never actually make money(Unless you are lucky!) It is a conversation starter.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Watch the Video!

Step 2: Get the Parts!

You don't need many parts for this, the Block Erupters could be hard to find.

  • Raspberry Pi 3 B
  • Block Erupter or other ASIC for Bitcoin Mining
  • 3D Printed Files
  • Small Fan(recommended not needed)
  • 8 Neopixel Strip(or more or less if you want, adjust python script accordingly)
  • Power Supply good enough for 6W at 5V
  • Plastic threading screws M2.26 for pi mounting
  • Zip Ties
  • White paint if using non white filament
  • Shrink tube(for fan)


  • 3D printer
  • Screw driver for mounting
  • Jumpers to cut
  • Soldering Iron(for fan)

Step 3: 3D Print the Body!

The files are up on Thingiverse here:

Pretty easy to print, any settings should work.

Step 4: Paint the Back White(if Its Not White)

I was using black filament, so I decided to paint the part that reflects the light, white.

Step 5: Assemble the Body With Pi.

Pi Mounts to the back. I use Torx screws, M2.26, plastic threading.

Plug in the block erupter. Hook up the fan if you are using one.

Step 6: Connect the Wiring.

I am powering everything from a 5V power supply including the Pi. Some people do not recommend this because it bypasses a fuse. You can choose your method of powering.

The Neopixels also need 5V, and then connect the data line to GPIO18 of the Pi.

Step 7: Program the Pi to Mine.

You will need to get CGMiner working. Here is the method that worked for me, you may require more knowledge in cgminer, lots of documentation online. For this to work you need to solo mine, I use NiceHash.

This was found here and updated by me:

sudo apt-get update
sudo apt-get install libusb-1.0-0-dev libusb-1.0-0 libcurl4-openssl-dev libncurses5-dev libudev-dev wget tar xvf cgminer-4.10.0.tar.bz2 cd cgminer-4.10.0 ./configure –enable-icarus sudo make install sudo apt-get install screen screen -S miner cd cgminer-4.10.0 sudo cgminer

Step 8: Run the Programs.

To get the Neopixels working follow this tutorial:

To get them working with a Pi 2 and 3 you need to disable the soundcard driver, follow this:

I wrote a python script to run along side cgminer to work the LEDs and see if you have won or not, you can download it here:

You need to get CGminer working and running, then run the program. Instructions are inside the program. takes the information from CGMiner so they both need to be running to have the lights displaying anything.

Step 9: Get Lucky!

You could find a block, you never know!

Step 10: Support These Projects!

If you would like to support my projects, Consider subscribing to my YouTube, becoming a Patron, and following on Instagram.

You can also send me bitcoins, here - 19s7hAVkm54Ev7QZEsWAfoyECy1CwXSrhL

I won't be expecting to win the lottery any time soon...

YouTube SeanHodgins

Patreon Sean Hodgins



Get notified the moment a new project comes out!

Automation Contest 2017

Participated in the
Automation Contest 2017

Be the First to Share


    • Instrument Contest

      Instrument Contest
    • Make it Glow Contest

      Make it Glow Contest
    • STEM Contest

      STEM Contest

    10 Discussions


    12 months ago

    If you want to increase your chances of earning, I'd strong recommend joining a mining pool. while you will not earn an entire bitcoin, you should be able to steadily earn smaller units that eventually will pay off. thanks for sharing your guide. I'm going to give this a try as I have a raspberry pi model B+ just sitting that would probably still work just fine as a dedicated cgminer controller


    Question 1 year ago on Introduction

    Yes hi I would like to know that if instead of neo pixels if you write a script to just flash one led on gpio 21

    Noor Hashem

    1 year ago

    I see you're interested in bitcoin. you might want to check this library if you have ideas of hardware projects that integrates bitcoin transactions


    1 year ago

    If I set this up on more than one machine, would it increase my odds? Would each machine go through the same sequence? or which each one be random? Also can I duel boot this with retro pi? I would like to run this until I play retro pi, then start the lottery up again. Thanks for posting. This is a cool project.


    Question 1 year ago on Step 10

    Have you won yet?


    1 year ago

    Nicehash is down. What else can we use?

    Also post those instructions.



    2 years ago

    so I am sorry I don't understand what this but I think I will try to make one but need more details should I have money to buy tickets or what?

    and wiring?


    2 years ago

    I guess I'm the only one struggling with this.. Where did you source the Neopixel 8 LED Strip specifically (can you supply link?). I think I have the pi mining, but I don't know where to get the right neopixel for the project..

    Thank you in advance!


    2 years ago

    Curious which wallet would best to use to connect your to? Blockchain seems to change your wallet address on each received transaction. Would that then require modification of the cgminer config? Not that winning the lottery more than once would likely happen..

    1 reply

    Reply 2 years ago

    Blockchain changes the wallet address each time you generate one, but the old ones still work to sending to your wallet.. This way you can assign different wallets for different things. E.g. 1 wallet for mining, 1 wallet for you store, 1 wallet for non-business transfers, etc. Just use the same one in your config. You can see past addresses in blockchain if you go to Settings->Addresses, all of the addresses listed there will still work.