Skip to content

kernadler/app-sensor-telemetry

 
 

Repository files navigation

app-sensor-telemetry

This application demonstrates capturing sensor measurements on the blockchain using Ambrosus API.

It's composed of:

  1. A local connection to our private Ethereum test network using testrpc
  2. A local node.js app (bridge) that receives data from sensors and pushes it
  3. An ethereum smart contract that receives sensor data periodically and reacts if sensed data exceeds a predefined threshold

Installation

  1. Clone this repo and install dependencies
$ git clone https://github.com/ambrosus/app-sensor-telemetry
$ cd app-sensor-telemetry
$ npm install
  1. In a separate shell, start testrpc
$ npm testrpc 
  1. Deploy contracts to the network
$ npm truffle migrate
  1. Start Web server
$ npm start

You should see something along the lines of:

$ npm start

> [email protected] start /home/ambrosus/app-sensor-telemetry
> DEBUG=api:* ./bin/api

  api:server API service started on 0.0.0.0:3000 +0ms

Usage

  1. Create an account at https://dev.ambrosus.com and get an address and secret.
  2. Open a browser and create a shipment by going to:
http://localhost:3000/shipment?
    owner=0x2EB...4474
    &secret=0xa0e13...456fd
    &shipmentId=123
    &name=Tylenol
    &minTemperature=0
    &maxTemperature=10
    &minHumidity=40
    &maxHumidity=65
    &minAirPressure=980
    &maxAirPressure=1010
  1. Then submit sensor data like so:
http://localhost:3000/telemetry?
    owner=0x2EB...4474
    &secret=0xa0e13...456fd
    &shipmentId=123
    &name=Tylenol
    &temperature=5
    &humidity=40
    &airpressure=1000

Both shipment and sensor data are uploaded to the smart contract. After submitting a data from sensor, it's verified by smart contract to fulfill all requirements(e.g. temperature, humidity and air pressure). If it doesn't, the smart contract marks whole shipment as defective. To check the shipment status, go by URL:

http://localhost:3000/status?
    owner=0x2EB...4474
    &shipmentId=123

If the shipment's quality is too low, the owner may be punished in some way, for example by giving a rebate to the customer or by reducing the balance of shipment's owner in the Ambrosus Network.
To further examine all events related to the shipment, you can check the Ambrosus Network.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%