Arduino连接传感器/执行器,同时连接LoRa模块作为LoRa节点,将收集自传感器的数据通过LoRa模块发送到网关。树莓派连接 LoRa/GPS Hat 作为 LoRa网关接受来自LoRa节点的数据,并提交到The Things Network(TTN) 网络,从TTN后台获取实时数据供区块链处理
在正式开始本实验之前,已经尝试过使用两台电脑和两台树莓派搭建 Quorum 网络,主要使用的是虚拟机,但到最后由于网络质量的问题,共识协议无法正常运行,导致合约部署无法完成。估计主要原因是 PC 上的节点装在了虚拟机里,虚拟机又使用桥接模式,导致最后丢包率和延迟都比较高。因此这次对实验做一定的调整,主要有两点:
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
保存退出,编辑/etc/apt/sources.list.d/raspi.list文件
1
sudo nano /etc/apt/sources.list.d/raspi.list
将源更新为:
1
2
deb http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
deb-src http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
更新源文件列表,更新软件
1
2
$ sudo apt-get update
$ sudo apt-get upgrade
B. 安装xrdp供远程连接
1
2
3
4
5
$ sudo apt-get install xrdp
# 确认安装
$ dpkg -l | grep xrdp
ii xorgxrdp 1:0.2.9-1 armhf Remote Desktop Protocol (RDP) modules for X.org
ii xrdp 0.9.9-1 armhf Remote Desktop Protocol (RDP) server
C. 开启ftp供文件传输
安装vsftpd
1
2
3
4
$ sudo apt-get install vsftpd
# 确认安装
$ dpkg -l | grep vsftpd
ii vsftpd 3.0.3-12 armhf lightweight, efficient FTP server written for security
编辑配置文件
1
$ sudo nano /etc/vsftpd.conf
启用对树莓派的写入权限
1
2
# Uncomment this to enable any form of FTP
write command.write_enable=YES
Current default time zone: 'Asia/Shanghai'
Local time is now: Fri Sep 13 18:40:56 CST 2019.
Universal Time is now: Fri Sep 13 10:40:56 UTC 2019.
New password:
Retype new password:
passwd: password updated successfully
OK
$ geth --datadir node0/data account new
WARN [12-23|18:45:02.029] Sanitizing cache to Go's GC limits provided=1024 updated=655
INFO [12-23|18:45:02.031] Maximum peer count ETH=25 LES=0 total=25
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat passphrase:
Address: {bffe4ff0cbd0a7590fb71966d1e6bb1a4c2359e0}
$ geth --datadir node1/data account new
WARN [12-23|18:45:13.335] Sanitizing cache to Go's GC limits provided=1024updated=655
INFO [12-23|18:45:13.337] Maximum peer count ETH=25LES=0total=25
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat passphrase:
Address: {dfb9cd6f474188fecbaafb9335d2905f08794612}
$ geth --datadir node2/data account new
WARN [12-23|18:45:26.461] Sanitizing cache to Go's GC limits provided=1024 updated=655
INFO [12-23|18:45:26.462] Maximum peer count ETH=25 LES=0 total=25
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat passphrase:
Address: {b7ce2bd1cb7232b92220f91aa44bfd48d0d4e806}
$ geth --datadir node3/data account new
WARN [12-23|18:45:35.615] Sanitizing cache to Go's GC limits provided=1024updated=655
INFO [12-23|18:45:35.616] Maximum peer count ETH=25LES=0total=25
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat passphrase:
Address: {174ec46a6cda172678dfebe0ed8b0c7da685c9a4}
$ cd node0
$ geth --datadir data init genesis.json
WARN [12-23|18:52:30.425] Sanitizing cache to Go's GC limits provided=1024 updated=655
INFO [12-23|18:52:30.438] Maximum peer count ETH=25 LES=0 total=25
INFO [12-23|18:52:30.439] Allocated cache and file handles database=/home/shuzang/istanbul/node0/data/geth/chaindata cache=16 handles=16
INFO [12-23|18:52:30.453] Writing custom genesis block
INFO [12-23|18:52:30.455] Persisted trie from memory database nodes=5 size=819.00B time=76.952µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [12-23|18:52:30.456] Successfully wrote genesis state database=chaindata hash=afaace…b46039
INFO [12-23|18:52:30.456] Allocated cache and file handles database=/home/shuzang/istanbul/node0/data/geth/lightchaindata cache=16 handles=16
INFO [12-23|18:52:30.460] Writing custom genesis block
INFO [12-23|18:52:30.460] Persisted trie from memory database nodes=5 size=819.00B time=47.175µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [12-23|18:52:30.460] Successfully wrote genesis state database=lightchaindata hash=afaace…b46039
$ cd ../node1
$ geth --datadir data init genesis.json
WARN [12-23|18:53:24.245] Sanitizing cache to Go's GC limits provided=1024updated=655
INFO [12-23|18:53:24.246] Maximum peer count ETH=25LES=0total=25
INFO [12-23|18:53:24.247] Allocated cache and file handles database=/home/shuzang/istanbul/node1/data/geth/chaindata cache=16handles=16
INFO [12-23|18:53:24.251] Writing custom genesis block
INFO [12-23|18:53:24.252] Persisted trie from memory database nodes=5size=819.00B time=51.433µs gcnodes=0gcsize=0.00B gctime=0s livenodes=1livesize=0.00B
INFO [12-23|18:53:24.252] Successfully wrote genesis state database=chaindata hash=afaace…b46039
INFO [12-23|18:53:24.252] Allocated cache and file handles database=/home/shuzang/istanbul/node1/data/geth/lightchaindata cache=16handles=16
INFO [12-23|18:53:24.255] Writing custom genesis block
INFO [12-23|18:53:24.255] Persisted trie from memory database nodes=5size=819.00B time=48.23µs gcnodes=0gcsize=0.00B gctime=0s livenodes=1livesize=0.00B
INFO [12-23|18:53:24.255] Successfully wrote genesis state database=lightchaindata hash=afaace…b46039
$ cd ../node2
$ geth --datadir data init genesis.json
WARN [12-23|18:53:52.025] Sanitizing cache to Go's GC limits provided=1024 updated=655
INFO [12-23|18:53:52.026] Maximum peer count ETH=25 LES=0 total=25
INFO [12-23|18:53:52.027] Allocated cache and file handles database=/home/shuzang/istanbul/node2/data/geth/chaindata cache=16 handles=16
INFO [12-23|18:53:52.032] Writing custom genesis block
INFO [12-23|18:53:52.032] Persisted trie from memory database nodes=5 size=819.00B time=76.54µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [12-23|18:53:52.032] Successfully wrote genesis state database=chaindata hash=afaace…b46039
INFO [12-23|18:53:52.032] Allocated cache and file handles database=/home/shuzang/istanbul/node2/data/geth/lightchaindata cache=16 handles=16
INFO [12-23|18:53:52.035] Writing custom genesis block
INFO [12-23|18:53:52.035] Persisted trie from memory database nodes=5 size=819.00B time=44.94µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [12-23|18:53:52.035] Successfully wrote genesis state database=lightchaindata hash=afaace…b46039
$ cd ../node3
$ geth --datadir data init genesis.json
WARN [12-23|18:54:13.106] Sanitizing cache to Go's GC limits provided=1024updated=655
INFO [12-23|18:54:13.107] Maximum peer count ETH=25LES=0total=25
INFO [12-23|18:54:13.108] Allocated cache and file handles database=/home/shuzang/istanbul/node3/data/geth/chaindata cache=16handles=16
INFO [12-23|18:54:13.115] Writing custom genesis block
INFO [12-23|18:54:13.122] Persisted trie from memory database nodes=5size=819.00B time=65.787µs gcnodes=0gcsize=0.00B gctime=0s livenodes=1livesize=0.00B
INFO [12-23|18:54:13.123] Successfully wrote genesis state database=chaindata hash=afaace…b46039
INFO [12-23|18:54:13.123] Allocated cache and file handles database=/home/shuzang/istanbul/node3/data/geth/lightchaindata cache=16handles=16
INFO [12-23|18:54:13.126] Writing custom genesis block
INFO [12-23|18:54:13.127] Persisted trie from memory database nodes=5size=819.00B time=45.203µs gcnodes=0gcsize=0.00B gctime=0s livenodes=1livesize=0.00B
INFO [12-23|18:54:13.127] Successfully wrote genesis state database=lightchaindata hash=afaace…b46039