Skip to content

lucamoroz/iot-blockchain-data-integration

Repository files navigation

Blockchain-based Sensor Data Integration

Overview

This project simulates readings from multiple sensors (temperature, humidity, air pressure, wind speed, etc.) and stores relevant values in a blockchain. A user can sett multiple filters in a dashboard in order to change what data is relevant and stored permanently. This could for example be used by an insurance company for only permanently storing data from days with extreme weather conditions in order to be able to understand later which services are to be reimbursed.

For a more detailed description of the project, please refer to Assignment.pdf.

Team

Samir Duvelek

David Kirchsteiger

Luca Moroldo

Konstantin Strümpf

Architecture

In general the architecture follows a pipes and filters pattern for integrating the data from fake sensors into the blockchain. Filters can be set and updated via a REST API directly from the frontend. Sensor measurements are transported as MQTT messages between the various components.

Architecture Diagram

Tech Stack

All components are provided as Docker images. For communication with the message broker the MQTT protocol is used (message broker: Eclipse Mosquitto). For communication with the blockchain a web3 library is used in js as part of a Python script. The fake sensors are implemented in Python using the pandas library for reading thhe sensor values from csv files. The filters are implemented with Java using the Spring Boot framework. The frontend uses Angular as a framework.

How to run

To run the project clone the repository to your local machine. An installation of docker-compose is required to start the project.

For simplifying the local execution a Makefile (requires the make tool) is provided that supports the following targets:

  • make start builds and starts the project in the background (frontend can be accessed via http://localhost:8080)
  • make start-logs builds and starts the project in the foreground (frontend can be accessed via http://localhost:8080)
  • make stop stops the execution of the project
  • make purge stops the project, removes all volumes and deletes the images

How to run the G5B docker-compose file

Two things are necessary to run:

  • the .env.prod: which is included in the submission, but not in the repository
  • the fake-sensor/data directory with its content to be mounted into the containers (also included in the submission)
    docker-compose --env-file .env.prod -f G5B up

How to run in the cloud

The project has also been deployed to a VM on the Google Cloud Platform and can be accessed via iotws20.allteams.at. This deployment publishes data to an Ethereum Testnet (see dedicated chapter).

For manual deployment

  • Log into Google Cloud Console and navigate to the project IOTWS2020 Group 5's VM Instances
  • Open a new shell on the presentation instance directly in the browser or via gcloud cli tool provided in the dropdown GCP VM Instances
  • Redeploy the project by executing /srv/iot-presentation/deploy.sh
  • The frontend should be accessible from iotws20.allteams.at

Testnet

As a testnet we decided for Kovan, since it has the least block time ( according to this stackexchange-post) and is supported by Infura. We use Infura to connect to Kovan via Infura without requiring to run a full node. We use this account to create the contract and transact the data.

Deploy the contract

Depending on the commandline arguments the blockchain-publisher project is configured to either use an existing contract or deploy the contract by compiling its ´.sol´-file and make the contract-creation-transaction using the provided blockchain account. For details see its usage description.

How to debug

You can run all docker containers locally with the environment file for development:

docker-compose --env-file .env.dev up --build

or run each sub project directly on your host by checking out the README files there.

Contributions

  • Luca Moroldo: mainly data-filter (middleware)
  • Konstantin Strümpf: mainly fake-sensors (data provider)
  • David Kirchsteiger: mainly blockchain-publisher (middleware)
  • Samir Duvelek: mainly frontend (user interface)