Giter Site home page Giter Site logo

app-sensor-telemetry's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.