GithubHelp home page GithubHelp logo

hasko / metricsinyourface Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tweakmunich/metricsinyourface

0.0 1.0 0.0 328 KB

An IoT project mixing RaspberryPI code and code for the Cloud

License: MIT License

Python 72.43% Shell 2.24% JavaScript 17.74% HTML 7.59%

metricsinyourface's Introduction

metricsinyourface

A simple IoT project that pulls data from the cloud and displays it on a seven-segment display. Seven-segment displays are a bit retro but very easy to read and more attention-getting than a tablet or small screen. Also, you can connect very large displays up to 10cm.

One or more displays, each with a configurable ID or "Channel", are connected to a Raspberry Pi, which fetches data from teh cloud and updates the display. Integer or floating point numbers plus a few special characters can be displayed.

Hardware

To preserve the number of GPIO ports used, input and output occurs via shift registers ('595 for output, '166 for input) or I2C bus.

  • Serial input: Each display's configurable ID and number of digits can be read from chained shift registers, 16 bits per display. Bits 0-11 are the display ID (aka "channel"), Bits 13-15 specify the number of digits (000 = 1, 110 = 7, 111 not allowed), Bit 12 is not used.
  • Serial Display: Large displays can be driven via chained shift registers, 8 bits per digit. The Pi shifts the correct number of digits for each display so that they can be chained together without addressing.
  • I2C Display: To simplify soldering you can connect 4-digit I2C displays from Adafruit.

Client Code

The client folder contains the code running in the Pi. To execute:

sudo python display_metric.py url domain

The Pi retrieves values to be displayed from the server based on the display ID and the domain string. For example if valueprefix is foo and a display with the ID 3 is connected to the Pi, it will look for the value of the parameter foo3.

Server-side code

The server folder contains the code running on a public cloud. It starts a simple Web server available via HTTP.

To make it run on your machine, execute : npm install, then node app.js. A deployment script has been provided to more easily deploy on a Linux box. See the sub directory : deployment scripts. It has been tested on an EC2 instance AWS Linux AMI.

The server can easily run on AWS Beanstalk: create a zip from the file contained in the server folder after having done an 'npm install' and follow the instruction on AWS Beanstalk wizard.

API version 1

Set value with HTTP POST (if domain is missing, it is defaulted to undefined):

curl -v -H "Content-Type: application/json" -X POST -d  '{"domain": "testdomain", "id":"testid", "value":"200"}' http://myhost:3000/setValue

Get Value with HTTP GET or directly from browser (if domain is missing, it is defaulted to undefined):

curl -v http://myhost:3000/getValue?id=testpi&domain=testdomain

API version 2

Set value with HTTP POST:

curl -v -H "Content-Type: application/json" -X POST -d  '{"value":"200"}' http://myhost:3000/:domain/:id

Get Value with HTTP GET or directly from browser:

curl http://myhost:3000/api/:domain/:id

Client identifier

The server is using the header remote_host to identify the client.

System domain

The system domain provides administrative/monitoring/test functions. The following ID's are currently supported:

  • 1 returns the number of clients known
  • 2 returns the number of clients that were active in the last 60 seconds

Trying to GET access to an ID different from the known one returns an error code 404 (not found)

System domain with ID = 1 and 2 can only be queried, a POST on with prefix = 'system' returns 403 (forbidden)

metricsinyourface's People

Contributors

spac3lord avatar mdan1eli avatar hasko avatar rbuehl avatar

Watchers

 avatar

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.