I started to make this small project motivated by few things which happened last time in Bitcoin world. People argue with me that Raspberry Pi 2 is not capable to host Bitcoin node anymore because of Core’s software high hardware requirements. However it was executable in the past. What was changed is the blocks are fully filled to 1MB right now. There are also new features implemented by Bitcoin Core in last years few years. I have to agree all that made setup of independent node a little harder, but not impossible.
We are near 6 weeks before SegWit activation. It is perfect time to show Your vote if we want new feature to be activated or not. I won’t convince anyone here to do so. It is all Your choice. To be honest I am very interested in the way how SegWit things will happen.
I treat this project as my little challenge. What I wanted to achieve:
- setup light Bitcoin node (pruned to 550MB) on Raspberry Pi 2 with success
- assemble 3D printed custom case to make minicomputer pretty attractive
- setup 3,5 inch TFT display with small info
- do not spend more than $100 on parts
This is a story how all things got connected together by me.
Parts
Raspberry Pi 2 Model B £20.00 = $25.20 https://thepihut.com/collections/raspberry-pi/products/clearance-raspberry-pi-2-model-b?variant=18198528708 | |
---|---|
EU Micro USB Power Supply for Raspberry Pi £5.00 = $6.30 https://thepihut.com/collections/raspberry-pi-power-supplies/products/eu-micro-usb-power-supply-for-the-raspberry-pi | |
3.5inch RPi LCD (A), 320x480 $24.99 http://www.waveshare.com/product/3.5inch-rpi-lcd-a.htm | |
16GB Sandisk Ultra Class 10 Micro SD card £9.00 = $11.34 https://thepihut.com/collections/raspberry-pi-sd-cards-and-adapters/products/noobs-preinstalled-sd-card | |
USB Wifi Adapter for the Raspberry Pi £6.00 = $7.56 https://thepihut.com/products/usb-wifi-adapter-for-the-raspberry-pi | |
Raspberry Pi Display Case $16 https://www.thingiverse.com/thing:1229473 |
£1 = $1.26
Total amount: $91.39
Assembly
While connecting Raspberry Pi to power is trivial I wanted to achieve more. Headless minicomputer is too ugly for me. I decided to 3D print one of the projects from thingiverse.com community. The case I found turned out to match perfectly with the rest of my parts. Small company in my town printed it for me for about $16. The quality of the parts aren't the best but pretty decent. I am okay with that.
Project visualization and author's photo
Connecting parts together:
Looks beautiful and neat :)
Operating system
Here comes the coding thing. I have decided to install default Raspbian Jessie image with PIXEL desktop. It is official Raspberry Pi operating system. Just download and write that onto SD card.
After configuring basic settings like WiFi connection, hostname and local settings, it's time to launch display screen.
I remember how difficult was to properly configure this display on Raspberry Pi. The drivers juggle was a madness. Luckily newest waveshare drivers made that very easy process for me. It all came to type just few commands.
> wget http://www.waveshare.com/w/upload/7/74/LCD-show-170309.tar.gz
> tar xvf LCD-show-*.tar.gz
> cd LCD-show/
> chmod +x LCD35-show
> sudo ./LCD35-show
Then reboot
It works :) Next step was to display something prettier than just console terminal. Redditors recommend http://www.realtimebitcoin.info/ as simple widget for small screens. I think this is the best choice for my display. For this I had to configure light desktop GUI where I could display realtimebitcoin.info site. Set it in fullscreen POS style for best utility.
> sudo apt-get install --no-install-recommends xserver-xorg
> sudo apt-get install --no-install-recommends xinit xserver-xorg-video-fbdev
> sudo apt-get install lxde-core lxappearance
> sudo apt-get install lightdm
> sudo apt-get install --no-install-recommends matchbox chromium-browser
Plus 3,5inch rescaling:
> sudo nano /usr/share/X11/xorg.conf.d/99-fbdev.conf
Section "Device"
Identifier "touchscreen"
Driver "fbdev"
Option "fbdev" "/dev/fb1"
EndSection
And finally set the kiosk mode directing to http://www.realtimebitcoin.info:
> sudo nano ~/.config/lxsession/LXDE/autostart
@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash
@chromium-browser --kiosk --incognito http://www.realtimebitcoin.info/
Just to hide weird mouse cursor:
> sudo apt-get install unclutter
Result after reboot. Beautiful :)
Bitcoin node
I don't wanted to run full Bitcoin node. Pruning to 550MB is enough to be light node. It synchronizes with full blockchain and checks every block for theirs compatibility but saves only last 550MB of blockchain on the disk. This is what I wanted to achieve.
I had some issues in the middle of compiling the sources of Bitcoin Core application. According to Core, it is recommended to have at least 1,5GB of memory available. The problem is my Raspberry Pi has only 1GB. I had to resize the swap dynamic memory and compile c++ code with additional parameters. It made compilation very slow and took few hours, but ended without errors.
Install all the packages needed for Bitcoin Core:
> sudo apt-get install autoconf libevent-dev libtool libssl-dev libboost-all-dev libminiupnpc-dev -y
Clone most recent repository:
> git clone -b 0.14 https://github.com/bitcoin/bitcoin.git
Extend swap from 100MB to 1GB!
> sudo sed -i '16s/.*/CONF_SWAPSIZE=1024/g' /etc/dphys-swapfile
> sudo dphys-swapfile setup
> sudo dphys-swapfile swapon
Compile and install
> cd bitcoin
> ./autogen.sh
> ./configure --enable-upnp-default --disable-wallet CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768"
> time make
real **354m**40.952s
user 348m8.710s
sys 5m28.990s
> sudo make install
As You see, it was needed to configure with specific parameters. The most crucial one was heapsize=32768, which changed memory used while compiling from 1,5GB down to 500MB! The downside of this solution was the compiling time which took 6 hours...
Blockchain synchronization
Before run of bitcoin client I had to set configuration options in bitcoin.conf file. I decided that my Bitcoin node will be pruned to 550MB and it will signal UASF-SegWit-BIP148 proposal. This is optional and only my preference.
> nano /home/pi/bitcoinData/bitcoin.conf
prune=550
uacomment=UASF-SegWit-BIP148
Run bitcoind client as a daemon:
> bitcoind -datadir=/home/pi/bitcoinData -daemon
We can see all the data through the bitcoin-cli command:
> bitcoin-cli -datadir=/home/pi/bitcoinData getinfo
{
"version": 140100,
"protocolversion": 70015,
"blocks": 365029,
"timeoffset": 0,
"connections": 0,
"proxy": "",
"difficulty": 51076366303.48193,
"testnet": false,
"relayfee": 0.00001000,
"errors": ""
}
However I was monitoring the status of synchronized blocks in real time through command:
> watch bitcoin-cli -datadir=/home/pi/bitcoinData getblockcount
Every 2.0s: bitcoin-cli -datadir=/home/pi/bitcoinDa... Tue Jun 13 22:14:42 2017
368160
I started downloading blockchain about 2 weeks ago. Right now I have synchronized about 75% of blockchain. I do keep my fingers crossed to make it finish before 1st of August.
75 percent confirmed by the network https://bitnodes.21.co
htop monitor
Links
https://www.raspberrypi.org/downloads/raspbian/
http://www.waveshare.com/wiki/3.5inch_RPi_LCD_(A)
https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
https://github.com/bitcoin/bitcoin/issues/6658#issuecomment-174396998
https://bitnodes.21.co
Cool stuff!
A load average of 2 seems like it's a little too much for the poor thing tho :D
Cool project! I was gonna offer my 3d printing services, but $16 is a great deal for that. I wonder if a pi 3 would be much better?
RPI 3 is definitely much easier to configure bitcoin core and faster to synchronize blocks. Many people build nodes based on rpi3 without any problems.
The challenge was to use old rpi2 :)
I like it, I was thinking about doing similar node, hovewer my internet connecion is to weak currently;/
I have technical question: is there any available power to run other services on this rpi, or it can stand just a node?
It all depends what are the other services. You can save some CPU power by disabling Desktop GUI and keep console terminal screen. The www animations from www.realtimebitcoin.info takes so much power tho :/ The blocks synchronize much faster when I turn the screen off.
You can host simple SAMBA server together which doesn't take any CPU usage or other light services You like.
Great project for pi 2/3 - Excellent info. Looking forward to giving this a try.
Interesting how much the sd card can withstand. Sd card does not like big swap. Nice "pi box" ;)
I think I should do backup of pruned blockchain soon. Just in case the SD card breaks down :\
Cool. Cool cool cool.