vinoblock
Assembling (List)
To assemble the system we need:
A raspberry pi 3 model B+ (https://www.amazon.es/dp/B07BFH96M3)
Heatsink and fan package (https://www.amazon.es/dp/B0756YN92J)
A microSDXC card (https://www.amazon.es/dp/B073JYVKNX)
A DHT22 sensor device. (https://4/dp/B07DK4PW9L)
MicroUSB Charger (https://www.amazon.es/dp/B07J4NK7ZD)
LCD 16x02 green display (https://www.iberobotics.com/producto/pantalla-lcd-16x2-1602-hd44780-display-green-backlight)
Potentiometer (https://www.iberobotics.com/producto/potenciometro-lineal-b10k-10k-con-mando)
Costs
Product | Price |
---|---|
Raspberry pi model 3 B+ | 35,30 € |
Heatsink and fan pack | 5,99 € |
MicroSDXC Card | 17,59 € |
DHT22 | 4,20 € |
MicroUSB Charger | 9,99 € |
LCD 16x02 Display | 2,95 € |
Potentiometer | 2,75 € |
Total | 78,77 € |
PoC Assembling (List)
For the PoC assemble we'll need:
Protoboard (https://www.iberobotics.com/producto/placa-prototipos-830-puntos-16x5cm-protoboard)
Dupont wires (https://www.iberobotics.com/producto/40x-cables-dupont-macho-hembra)
Pin headers (https://www.amazon.es/dp/B00QXBRCKG)
Tin welder (https://www.iberobotics.com/producto/soldador-de-estano-40w)
Costs
Product | Price |
---|---|
Protoboard | 4,50 € |
Dupont wires | 2,45 € |
Pin headers | 3,24 € |
Tin welder | 9,95 € |
Tin | 8,79 € |
Total | 28,93 € |
PoC Assembling
The first step we should take on is to place the heatsink and the fan. To do so we unpack following parts (raspberry pi, DHT22, heatsink and fan):
Once we have the parts prepared to install we can install the DHT22 taking into account the following gpio pin description from Raspberry Pi OS - Raspberry Pi Documentation :
So we going to connect the input to pin 1, the output to pin 4 and the ground to pin 5 as follows. In our case the orange wire is the voltage input one, the red one the output pin and the brown one representing ground. In this image we can also see how we've placed the heatsinks.
Finally we have have to assemble the fan. To do so and just for this PoC (this will change in a future assembling method as the box will be changed) we have attached it to a raspberry box as follows and we have connected its cables to pin 13 and 14:
To end the assembling procedure we just close the box used (remember this is just for the PoC, so no documentation of the box is given) with the 4 screws given by the provider. The final result is:
Install and init the OS
Download the Raspbian Stretch Lite OS as zip file from: Raspberry Pi OS – Raspberry Pi or use the following command
computer$ wget https://downloads.raspberrypi.org/raspbian_lite_latest
computer$ unzip raspbian_lite_latest
Introduce the micro sd on the computer and check its identifier:
computer$ diskutil list
Unmount the disk to prepare it for the image installation:
computer$ diskutil unmountDisk /dev/disk2
Install the latest raspbian image that you have unzipped:
computer$ sudo dd bs=1m if=2019-07-10-raspbian-buster-lite.img of=/dev/disk2
(Extra possibility) To work directly with ssh we can create a ssh file in the boot directory and it will allow ssh connections:
computer$ touch /Volumes/boot/ssh
Eject the micro sd safely:
computer$ diskutil eject /dev/disk2
Ensure that your RPi is powered off. Insert the SD card on you RPi, connect the ethernet cable and power on the device. Your RPi will boot the image. Log in the RPi with the default credential is (Alternatively you can connect directly to the raspberry pi in case you don't have access to an ethernet cable but you'll need a screen and a keyboard) :
computer$ ssh pi@192.168.1.58 [password: raspberry]
The RPi needs to be configured:
Change the keyboard layout (if required)
Set the timezone: required to allow a blockchain synchronisation between nodes
Enable SSH: securely access your RPi from your computer.
pi$ sudo raspi-config
1) Timezone can be changed from the option "Internationalisation Options" and "Change Timezone".
2) Keyboard layout can be changed from the option "Internationalisation Options" and "Change Keyboard Layout".
3) SSH can be enabled from the option "Advanced Options" then "SSH".
When everything has been modified, reboot the raspberry to apply changes:
pi$ sudo reboot
Finally when the system has rebooted, change the password for the user pi:
pi$ passwd
(Only if using Wi-Fi) Setup your Wi-Fi interface:
pi$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
(Only if using Wi-Fi) Change the country code to set yours and add the following lines at the end of the file:
network={
ssid="SSID of you network"
psk="Password of your network"
}
When everything has been modified, reboot the raspberry to apply changes:
pi$ sudo reboot
Find the private ip of your raspberry pi to connect via ssh to it.
pi$ ifconfig
computer$ ssh pi@"ip of your raspberry"
Finally to change the root password we just use the following command:
pi$ sudo passwd root
Update apt-get
Before starting to set up everything we'll make sure we have the last version of apt-get installed by:
pi$ sudo apt-get update
pi$ sudo apt-get upgrade
Install npm and nodejs
We'll also need to install the javascript npm package manager and installer:
pi$ sudo apt-get install nodejs npm
Install git
In order to be able to clone git repositories we must install the git toolkit, to do so:
pi$ sudo apt-get install git
Install geth
To run a local node connected to the Costaflores private network an Ethereum client is necessary. In this case we'll use geth to set it up, other clients such as Parity can be used too. To install it we need to know the type of cpu we are using:
pi$ cat /proc/cpuinfo
...
model name : ARMv7 Processor rev 4 (v7l)
...
Select the geth instance you want to install from Downloads | go-ethereum and retrieve the package from the raspberry:
pi$ wget https://gethstore.blob.core.windows.net/builds/geth-linux-arm7-1.8.20-24d727b6.tar.gz
pi$ tar zxvf geth-linux-arm7-1.8.20-24d727b6.tar.gz
Copy the Geth application to the /usr/local/bin folder:
pi$ sudo cp geth-linux-arm7-1.8.20-24d727b6/geth /usr/local/bin
pi$ rm -rf g*
Check it was installed correctly:
pi$ geth version
Install node-red
To implement the front-end of the temperature dashboard we will use nodered and its dht22 contributions, to do so, firstly we must install nodered by:
pi$ sudo apt-get install build-essential
pi$ sudo apt-get install nodered
Now that we have installed nodred we will use npm to install the dht22 contributions:
pi$ wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.58.tar.gz
pi$ tar zxvf bcm2835-1.58.tar.gz
pi$ cd bcm2835-1.58
pi$ ./configure
pi$ make
pi$ sudo make check
pi$ sudo make install
pi$ sudo npm install --unsafe-perm -g node-dht-sensor
pi$ sudo npm install --unsafe-perm -g node-red-contrib-dht-sensor
pi$ sudo npm install node-red-node-mysql
Finally we test it works by using:
pi$ node-red-start
Once we've checked everything is working correclty we can enable it to run on boot:
pi$ sudo systemctl enable nodered.service
Install MariaDB
In order to have a working database in the raspberry pi we've selected the mariadb sql one. To install it we must:
pi$ sudo apt-get install mariadb-server
Once installed we have to initialise following the instructions displayed when using:
pi$ sudo mysql_secure_installation
Finally we can test it by using:
pi$ sudo mysql -u root
Install python3 package manager and packages
Python comes already installed in the raspbian image so we can use it directly. To work with its packages we'll install the pip3 package manager. To install it:
pi$ sudo apt-get install python3-pip
pi$ sudo python3 -m pip install --upgrade pip setuptools wheel
Once we have python3 and pip3 installed we have to download the following packages:
pi$ sudo pip3 install adafruit-circuitpython-dht
pi$ sudo pip3 install adafruit-circuitpython-charlcd
pi$ sudo pip3 install --upgrade adafruit_blinka
pi$ sudo pip3 install mysql-connector-python
pi$ sudo pip3 install web3
Install and connect to OpenVPN
In order to be able to assure secure communications between nodes, just nodes inside the VPN can connect via HTTP, to do so, we'll install openvpn:
pi$ sudo apt-get install openvpn
Once we have installed openvpn, we must get the vpn config files from the admin. Once received we just have to:
pi$ mkdir vpn
computer$ scp openvino-openvpn.tar pi@192.168.1.58:/home/pi/vpn
pi$ cd vpn
pi$ tar -xvf openvino_openvpn.tar
pi$ sudo cp * /etc/openvpn/
pi$ sudo openvpn --config /etc/openvpn/mdv-clofw01-TCP4-1195-mbarrow.conf
pi$ sudo systemctl enable openvpn@mdv-clofw01-TCP4-1195-mbarrow
Finally we reboot the system to enable everything we have installed.
pi$ sudo reboot