There are three different approaches (only the first two are possible at the moment) to set up the OS for the Pi:
-
Install normal Raspbian OS with Jessie. (+) easy (-) no preinstalled ethereum clients and many unnecessary software packages like GUI, clientGateway is not usable
-
Use EthRaspbian. (-) additional configuration is required to use newer client versions. (+) no unnecessary packages
-
TODO: Create Dockerfile
-
For the first installation follow the instructions on github
-
To update without trouble to newer supported client version of Ethraspbian follow these instructions
-
[For experts] Update to any newer ARM version of Parity or geth. Following is suited for parity, geth is the same process
sudo apt-get update
sudo apt-get upgrade
// backup configuration files into home directory
sudo cp /etc/systemd/system/parity.service ~/
sudo cp /etc/parity/parity.conf ~/
// download parity arm binary
cd ~/
wget http://parity-downloads-mirror.parity.io/v1.7.0/armv7-unknown-linux-gnueabihf/parity_1.7.0_armhf.deb
sudo apt-get purge parity-rasp
sudo dpkg -i parity_1.7.0_armhf.deb
sudo cp parity.service /etc/systemd/system
Cd /etc und hier drin sudo mkdir parity
Cd ~ und sudo cp parity.conf /etc/parity
sudo systemctl daemon-reload
// only if needed: prevent autostart of client
crontab -e
add: @reboot sudo systemctl stop parityBought this flow meter. It should be similiar to Adafruit's version. Follow Adafruit Kegomatic's guide for additional informations.
My python modules use this wiring scheme, fritzing is also availabe in the docs folder.
- Install python dependencies
// if not already installed
sudo apt-get install python3
sudo apt-get install python3-pip
sudo apt-get install python-rpi.gpio
sudo apt-get install python3-rpi.gpio
pip3 install web3
// https://github.com/ethereum/pyethapp/issues/195 if any problems occur
pip3 install ethereum- Set url in gateway or go to 3. To use the InfuraGateway, a link with access token/api key and blockchain network is required to access Infura's endpoints. It is available from Infura for free. This line must be edited:
self.web3 = Web3(HTTPProvider('https://kovan.infura.io/<key>'))- Set password to unlock an account, if clientGateway is used
self.web3.personal.unlockAccount(self.address, 'password')- Initialize gateway in read_water_flow.py with secret values smartContractAddress: Address of smart contract which was created by the admin of the water utility. Only if the meterAdress was specified initially
self.blockchainGateway = InfuraGateway(smartContractAddress,privateKey,meterAddress)- Start the smart meter
python read_water_flow.pyNow it displays any measured water consumption in the shell. In addition, a transaction to invoke the method of the related smart contract will be triggered automatically every hour.
If you do not want to set up a raspberry pi, buy a flow meter and do wiring stuff only to send sample meter readings data to smart contract functions then the gateway faker is your friend. It can easily be used from the interactive shell in the same directory where the files are. Configurations are still required.
python3
>>>from blockchain_gateway_Faker import InfuraGateway
>>>iG = InfuraGateway(smartContractAddress, privateKey,meterAddress)
>>>iG.transmitSmartMeterReading(2017,12,18,19,75) //(yyyy,mm,dd,hh,liters)The abi.json is required and was compiled from WaterMeterService.sol on another device or with RemixIDE because it can be tricky to set up solc on a raspberry.