Make your own Bitcoin Full node with LCD display. [Full Guide]
Bitcoin Full Node: Raspberry Pi 3* with LCD Display
*(Guide compatible for any single board computers with ARMv7 Processors, full list here )
Live price tracking display.
Full Node, verify transactions and enforce the rules of the network
HARDWARE
Raspberry Pi starter Kit: 2.5A Power supply, 16Gb SD card, Raspberry Pi model 3b and case (case style can vary by kit, some are suitable to fit with screens).
I picked this kit up for around £50.
SATA -> USB adaptor.
These are the best type SATA to USB providing 1x USB for power and data + 1x additional USB for power only. Allowing the Pi's full USB 1.2A for the drive.
Raspberry Pi 3b 3.5"
Touchscreen LCD display.
USB Storage: If you can find a supplier that offers a warranty with 2nd hand HDDs then this will be your cheapest option. As I've said I use CEX(UK) they have stores in USA, Spain, Ireland, India and Australia. 500GB 2.5" drive available for around £20.
Acrylic sheets (A3 x 3mm used in these projects) Great for other projects too.
M3 Nylon risers, screws and nuts 300x for building case layers.
For detailed assembly instructions for the Hardware see my main site, it contains measurements and dissected views for clarity.
Step (1) Preparing the Pi
There are some basic steps required to prepare the SD card for the Raspberry Pi Node installation in this guide. For this we require five (all free) programs. They are:
- Win32DiskImager For Windows Pc or Etcher for Mac OS
- 7-Zip for Windows Pc or The Unarchiver for Mac OS
- SDformatter for all Pcs
- PUTTY for Windows Pc. Not required on Mac as you already have "terminal"
- IPscanner for Windows Pc and Angry IP Scanner for Mac
To start with we'll erase (format) all the data from the SD card to start fresh. This is done with the SDformatter you just downloaded. The reason we need a special program to do this is that Raspberry Pi requires the card prepared (formatted) to something called Fat32, it's to do with how information is addressed on the card so it can be read. Without using this software Pcs will often restrict your options when formatting large cards and try to use a different addressing system that wont work on the Pi.
So:
SDFormatter looks like this, and is very easy to use. Ensure the drive letter corresponds to the drive the card is inserted in.
Click "Option"
Change "Format size adjustment" to "ON"; Then "OK"
Then "Format"
It only takes a couple of seconds
Now the Card is empty, we need an operating system on it to give the Pi it's basic instructions. The easiest way to do this is to put an exact copy of an already working system onto the card. These exact copies are called "images" and are available to download from the Raspberry Pi website. We need the Stretch-lite 2Gb image click "download zip".
Because these images are large data files, they are compressed so they are quicker to download. We need to un-compress it.
For this we use 7-zip or The Unarchiver depending on if you're Windows or Mac.
7-Zip Shown here.Open either 7-zip or The Unarchiver, and navigate to where you downloaded the image. Open that file and it will look something like the picture on the left.
Select the file and then select "Extract".
It will ask you where you want to extract the file to and will take less than a minute to process it.
Now we have an image file ready to copy on to the card. We use Win32DiskImager next (or Etcher for Mac)
Another very easy to use program.Select the Uncompressed image we just made, double check that the "device" is the correct drive letter of the SD card. And hit "Write"
It will give a series of warnings and they are to be acknowledged only once you have confirmed it is definitely the SD card you are writing to. If you accidentally over-write your Pc's main drive instead it will cause BIG problems. Check first and double check
Nearly ready!
To avoid the hassle of finding spare HDMI cables, keyboard etc, this guide uses something called SSH. It's what PUTTY is for (or Terminal on Mac).
What it enables you to do is take complete control of the Raspberry Pi and manage the installation of the rest of the guide, sending commands over the network. It also means you can put the node anywhere in the house once complete, and log in remotely with SSH and check it's progress/status without a TV or keyboard directly plugged into it. Much easier long-term.
However, I just said that it enables complete control of it remotely. This is a security problem. To solve this the people that made the system have disabled SSH. We have to tell it to enable. Again it's really simple. All we need to do is make a file called ssh and put it on the card.
On a windows Pc open notepad, (found under the start menu and accessories)
Windows, Notepad
Select "file", "save as" and go to the drive with the SD card now called "BOOT"
Call the file "ssh" (with quotes, this stops it saving it as a .txt file)
Mac
Make a text file in same location and call it ssh
Then go to the file properties and delete it's extension.
The Pi will look in this location when it starts. If it sees a file called ssh it enables it.
So now we plug everything in.
Put the SD card in the Pi, an Ethernet cable will also be needed as Wifi isn't enabled yet and the power. The USB drive can be added now or later.
Turn on the Pi and give it a few seconds to start up.
We now need to know it's IP address. If you have plugged in the HDMI it will display it on the screen. The next easiest option is to look on your home router for the IP address of connected devices and identify the Pi. The third option is for people that can't do either of those.
The IP scanning software is simple and great. You enter in where you want it to search and it will bring up every connected device in range.The default settings will find it unless someone in your house has customized the LAN settings. It's usually between:
192.168.1.1 - 192.168.1.250
In the example to the left it is showing connected devices with blue logos. I have a few connected but you should have just one called "raspberrypi"
We then take this number, (in my example '192.168.1.8' yours will probably be different) and put it in PUTTY
And that's pretty much it, this is the business end.
Enter the IP address from the step above into where it says "HostName (or IP address)" and click "open"
It ask for a username which is:
pi
and password:
raspberry
You are now logged in and ready to continue with the guide.
When you connect to Wifi later your IP address may change. You can find it again with IP Scanner.
Also now that SSH is enabled it is wise to change the default password of raspberry to something more secure. We do that near the end in a step called "Security" with a couple of other things.
If you need to pause when making these projects, it's good practice to use the command "sudo shutdown now" before turning off the power.
Step (2) Enabling WiFi
Wifi is available once the Pi is rebooted. Either reboot now using sudo reboot and remove the ethernet cable. Or continue, and reboot later as it is required after the next step. With the Pi turned on, booted and you logged in with SSH we can start the setup.First WiFi network connections are stored:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Go to the bottom of the file and add the following text:
network={
ssid="YOUR WIFI ROUTER NAME"
psk="YOUR WIFI ROUTER PASSWORD"
}
**Note: Enter details between the quotes, leave the "" in
save and exit using
ctrl+O
Then 'enter'
ctrl+X
Step (3) Expand the file system, (making full use of the SD card) and changing the Password.
enter:
sudo raspi-config
The default password for obvious security reasons should be changed. That is done in this menu.
select "1 change user password", and follow the on-screen instructions. This will be the new password when using PUTTY to SSH into the Pi.
Because we installed a 2GB image onto the card, the Pi may think that the card is only 2GB in size. So we tell it to expand the file-system (returns it to it's full size allowed):
select "7 advanced options"
select "A1 expand filesystem"
select 'finish' system will reboot, (remove the ethernet cable if you didn't at the previous step). And log back in with SSH and PUTTY once reboot is complete.
Step (4) Updates
The image we downloaded may have an update or two since they released it:
sudo apt-get update
sudo apt-get upgrade
select 'y' to accept the storage requirement.
Step (5) Installing the screen
sudo wget http://www.spotpear.com/download/diver24-5/LCD-show-170309.tar.gz
sudo tar xvf LCD-show-170309.tar.gz
cd LCD-show/
Then pick and type one command from the list below depending on your screen size/resolution.
If your display is the Raspberry Pi 2.4inch, 2.8inch or Raspberry Pi 3.2inch
sudo ./LCD32-show
If your display is the Raspberry Pi 3.5inch
sudo ./LCD35-show
If your display is the Raspberry Pi 3.5 inch HDMI LCD
LCD35-HDMI-480x320-show
OR
LCD35-HDMI-800x480-show
If your display is the Raspberry Pi 4inch
sudo ./LCD4-show
If your display is the Raspberry Pi 4inch HDMI(800x480)
sudo ./LCD4-800x480-show
If your display is the Raspberry Pi 4.3inch
sudo ./LCD43-show
If your display is the Raspberry Pi 5inch
sudo ./LCD5-show
If your display is the Raspberry Pi 7inch (800x480)
sudo ./LCD7-800x480-show
If your display is the Raspberry Pi 7inch (1024x600)
sudo ./LCD7-1024x600-show
If your display is the Raspberry Pi 10.1inch (1024x600)
sudo ./LCD101-1024x600-show
This command takes some time ("LCD configure 0" displayed for a while) and it reboots when it is complete but reboots in the background so it confuses PUTTY. The reboot causes PUTTY to crash and is normal. I recommend waiting until the activity indicator on the pi has been lazy for a minute or two (an indication it has finished) then press enter. PUTTY will bring up an error and close. (This has been updated and did this twice on a rebuild) This is fine. Log back in with SSH and PUTTY
Now we tell the Pi to boot using the new display:
sudo nano /boot/config.txt
And at the bottom you will find
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
dtoverlay=waveshare35a
dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,sw$
Adding a # before a line make the Pi ignore it and is called a comment.
Comment out the dtoverlay=ads7846...line by adding a #.
The line that we want active is the dtoverlay=waveshare35a
The rotation value should be changed here from now on too, by adding :rotate=0 as in the image above
Choose your rotation value. 270 is the HDMI port at the top. Use 0,90,180,270 as needed.
It should look like this after, (depending on rotation preferences)
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
dtoverlay=waveshare35a:rotate=270
#dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,sw$
then, save and exit (CTRL+o, CTRL+x)
sudo reboot
And you will have your display working.
(If rotation is wrong, edit the config.txt again and change rotate=<###>. Reboot required for changes to take affect)
Step (6) Adding the GUI (the desktop)
A very easy copy/paste step:
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
don't reboot just yet...
Step (7) Force the output to the LCD, not HDMI
sudo nano /usr/share/X11/xorg.conf.d/99-fbdev.conf
should be blank, add the following text
Section "Device"
Identifier "touchscreen"
Driver "fbdev"
Option "fbdev" "/dev/fb1"
EndSection
save, exit, ctrl+o ctrl+x
sudo reboot
pi will reboot and after about 1 min for initial setup will load GUI onto the display giving a desktop
If it prompts you for a login username and password it can be disabled via the PuTTY window with
sudo raspi-config
option 3 (Boot options)
option B1 (Desktop/CLI)
option B4 (Desktop Autologin)
Select finish and reboot again for changes to take effect.
Step(8) Disable screensaver, auto-boot chrome
Now it's booted to the GUI you can disable the screen saver with a USB mouse. Open the menu in the bottom left, preferences, screensaver. and select disable from the drop down list.
Then the via SSH
The file below contains setting for the GUI
sudo nano ~/.config/lxsession/LXDE/autostart
Change it to look like
@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash
@chromium-browser --start-fullscreen --incognito http://www.realtimebitcoin.info/
This loads the chrome browser on boot in a full screen mode.
We will come back to this file later to tell it to auto boot the node.
Step (9) Moving everything to the USB drive
People have been making projects (not just nodes) on the raspberry pi for some time. A common failure point seems to be the SD cards. The constant read/write process 24/7 drastically shorten their life. We can reduce this by moving the entire file-system to the USB drive, and where possible using traditional platter HDDs. Check out HARDWARE for cheap solutions available to the Raspberry Pi.
For moving the file-system we need the "git" repository
sudo apt-get install git
Insert the USB drive if you havn't already, then check it is mounted to the Pi.
sudo lsblk
99% of the time it will be mounted as /dev/sda with a partition called sda1. However if it has found sda1 it won't let us continue until it is unmounted. (It would be telling it to make changes to the filesystem whilst it's in use. It won't let us and doesn't like it). So we unmount with
umount /dev/sda1
We need to delete this partition to stop raspbian from automatically using the drive on boot, at this point. The helper in the next step will automatically create a new partition to do it's job of moving the files.
sudo fdisk /dev/sda
d
(deletes old partition)
w
(writes and commits the changes)
Now it's compatible with the helper script.
The folks at Adafruit have made a very useful helper to reduce the amount of commands you need. These next three lines create a new partition and move the entire file system onto the USB drive. It does warn you that any data currently written to /sda will be overwritten. If you are an advanced user and have called the partition something other than /sda, this is where it should be changed.
git clone https://github.com/adafruit/Adafruit-Pi-ExternalRoot-Helper.git
cd Adafruit-Pi-ExternalRoot-Helper
sudo ./adafruit-pi-externalroot-helper -d /dev/sda
It will ask you to check that you are writing to the correct partition, select y when you are sure. When I do this step it takes a little under 10mins. Please be patient.
Picture
This is our drives labels and addresses. We need to check that the PARTUUID long number (that's the USB), is entered into
sudo nano /boot/cmdline.txt
So everything has been copied over and the drive configured. We just need to change the boot file so it starts from the USB drive from now on. The helper untility should have done this automatically. But recently this has not been the case. Do this just to check, it's simple and is just a copy/paste action.
sudo blkid -o export /dev/sda1
The numbers will be different but it brings up something like the image on the left.
Enter:
sudo nano /boot/cmdline.txt
And ensure that the helper has changed
root=PARTUUID=
to match the one that was listed to you above. Yours will be different to mine. Then Save and exit using ctrl+o then ctrl+x.
Do another reboot with sudo reboot and when the Pi starts this time your USB activity light will blink like crazy, showing it's now getting it's data from there.
Step (10) Installing "Screen"
We are now very close to completion. Very soon we will be telling the node to start. However the node will be running in the PUTTY window on our Pc and if you close that screen, it closes the connection too, stopping the node. An easy solution is to use a nifty program called "screen". It runs the current session on the Pi and detaches you from it. This leaves you free to leave and re-join to check the node's progress as you wish, without disturbing it!
sudo apt-get install screen
Then, to use it, type…
screen bash
It will open another terminal instance that is running on the Pi. You can now start a process you want to be able to leave running and reconnect to later. In this case, this will be the node.
"Screens" can be rejoined (I'll show how to detach and re-attach to them later)
Step (11) Installing Bitcoin 0.16
Enlarge something called a swapfile so the blockchain loads quicker (like artificially boosting available memory)
sudo nano /etc/dphys-swapfile
And change the default size of 100(MB, to 1000 as shown to the left
save, exit, ctrl+o ctrl+x
*If you wish you may make a 2GB swap file by entering a figure of 2000.
This is the upper configurable limit of a Pi3.
Then, to build the new swap file...
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
We start with making a directory to hold the blockchain:
mkdir ~/bitcoinData
Download the dependencies Bitcoin needs:
sudo apt-get install autoconf libevent-dev libtool libssl-dev libboost-all-dev libminiupnpc-dev -y
make a directory to download the files
mkdir ~/bin
cd ~/bin
Download Bitcoin from github with:
git clone -b 0.16 https://github.com/bitcoin/bitcoin.git
then navigate to our bitcoin folder to install it all
cd bitcoin
./autogen.sh
./configure --enable-upnp-default --disable-wallet
make
Note 'make' took around 2 hours on my last build. It has been recommended to use 'make -j2' as the command as it is quicker. The -j2 flag tells the pi how many cores of it's processor to use in that instruction. The pi has 4 cores available but it is not recommended to use them all for a task. If you encounter errors just stick with 'make'.
Then
sudo make install
then we configure the node.
sudo nano /home/pi/bitcoinData/bitcoin.conf
and add to it
rpcuser=<yourbitcoinrpcuser>
rpcpassword=<yourpasswordhere>
**make up some values here remove the <>
save, exit, ctrl+o ctrl+x
Now we have the node installed we add it to the autorun file to it starts on boot. Nearly done!
So back to:
sudo nano ~/.config/lxsession/LXDE/autostart
And add
@bitcoind -datadir=/home/pi/bitcoinData -daemon
Save and Exit as before for the last time!
sudo reboot
Once booted that should be it! To verify it's working use
bitcoin-cli -datadir=/home/pi/bitcoinData getinfo
check you have 8 connections (after giving it 5 mins to start) and each time you use that command, the value of "blocks": xxxxx should be increasing. That is your current block height. It will get slower to increase later on as blocks start getting busier.
The "version": is referring to the version of Core you're using. It will be a higher number than the one in my screen shot
This is the tedious bit. It has to download approx 130GB+ of blocks and verify every transaction within it. That's a big ask for a little raspberry pi! It handles it fine though and on the nodes I have built it has taken approx 4 weeks. Just check on it every-other day or so with the getinfo command above. I've not had one crash yet. I should also mention that it builds the block-chain very quickly at first. For the first few years the block-chain is mostly empty, now the blocks are mostly at capacity and there are many more transactions to verify. It will get slower, this is normal. Once it has fully sync'd the Pi pretty much idles until a new block appears, busying itself with the transaction mempool.
o stop the node (recommended before disconnecting power, or using sudo reboot/shutdown from now on to prevent data corruption) use:
bitcoin-cli -datadir=/home/pi/bitcoinData stop
Step (12) Security
I've been made aware that there are some underlying defaults that can affect system security. One is to disable root login by ssh by editing
sudo nano /etc/ssh/sshd_config
and changing
PermitRootLogin without-password
to
PermitRootLogin no
and add the line below to only allow ssh access to user 'pi'
AllowUsers pi
Save, ctrl+o, enter, exit ctrl+x
then reboot just sshd by
sudo /etc/init.d/ssh restart
I will update any security recommendations as I become aware of them.
Enjoy
This guide created, by shermand100 of http://www.PiNode.co.uk
Guides also available for Bitcoin, Litecoin, Ethereum, Monero, Sia, Storj, Blackcoin, Pinkcoin, Dash, Doge and others
✅ @shermand100, I gave you an upvote on your post! Please give me a follow and I will give you a follow in return and possible future votes!
Thank you in advance!
Congratulations @shermand100! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :
You published your First Post
You made your First Vote
You got a First Vote
Award for the number of upvotes received
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
SteemitBoard World Cup Contest - Final results coming soon