GithubHelp home page GithubHelp logo

rakesh-mohanta / johnnyfive-eon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pubnub/johnnyfive-eon

0.0 3.0 0.0 976 KB

Realtime data visualization with PubNub EON Demo & Arduino: Displaying the data sent by Arduino with DS18B20 temperature sensor using Johnny-Five

HTML 64.59% JavaScript 35.41%

johnnyfive-eon's Introduction

EON Demo from sensor data using Arduino and Johnny-Five

You need to install Johnny-Five and PubNub to run the node.js code with Arduino.

$ npm install johnny-five
$ npm install pubnub

Overview on Publishing from Hardware & Subscribing to Plot a Graph on Browser

Publishing the Sensor Data to PubNub

Once you get the data from the sensor, send the data to PubNub.

var pubnub = require('pubnub')({
  publish_key: 'YOUR_PUB_KEY',
  subscribe_key: 'YOUR_SUB_KEY'
});

var data = {
  'temperature': temp
};

pubnub.publish({
  channel: 'temperature-ds18b20',
  message: data,
});

Data Visualization with EON

The basic graph can be drawn with EON's chart() as it receives the data from PubNub.

Chart type can be specified with data.type. In this example, it is a simple line graph:

<div id="temp"></div>
var pubnub = PUBNUB.init({
  publish_key: 'YOUR_PUB_KEY',
  subscribe_key: 'YOUR_SUB_KEY'
});

eon.chart({
  channel: 'temperature-ds18b20',
  generate: {
    bindto: '#temp', 
    data: {
      type: 'line'
    }
  }
},
pubnub: pubnub,
transform: function(m) {
  return { eon: {
      temperature: m.temperature
    }}
  }
});

To customize the chart (e.g. changing line colors, adding labels, etc.), please refer C3.js docs.

Run the HTML File

For eaxmple, to view the temperature line graph, run /temperature/temperature.html file on local server:

$ python -m SimpleHTTPServer 8000

Then go to localhost:8000 on browser, and run temperature.html EON line graph

Hardware Wiring

Temperature

The temperature data comes from a DS18B20 sensor, and it is published to PubNub.

When you are using Arduino with Johnny-Five, you need to install ConfigurableFirmata to your Arduino to be able to run the code. The code requires OneWire support using the ConfigurableFirmata.

Installing ConfigurableFirmata

  1. Connect your Arduino to computer with a USB cable
  2. On Arduino IDE, go to Sketch > Include Library > Manage Libraries
  3. Search for "ConfigurableFirmata"
  4. Click the result, then click Install
  5. Go to File > Examples > ConfigurableFirmata
  6. Upload the code to the device

Arduino Wiring

DS18B20 OneWire digital temperature

Run the Node.js to Get Temperature from the Sensor

Change directory to temperature/ and run temperature.js:

$ node temperature.js

Photoresistor (Ambient Light Sensor) with DS18B20

Both a photoresistor a temperature sensor and the same breadboard to send both values to PubNub together:

DS18B20 OneWire digital temperature

Potentiometer

potentiometer

For potentiometer, I am using a gauge chart, instead of line graph.

Define the chart type, gauge (also label, min/max, ect.) in the eon settings:

eon.chart({
  channel: 'potentiometer',
  generate: {
    bindto: '#pot',
    data: {
      type: 'gauge',
    },
    gauge: {
      label:{
        format: function(value, ratio){
          return value; //returning here the value, not in %
        },
      },
      min: 0,
      max: 1023
    },
  } ...

gauge


DS18S20, Photoresistor, and Potentiometer in one breadboard

sensors

johnnyfive-eon's People

Contributors

girliemac avatar

Watchers

 avatar  avatar  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.