Coder Social home page Coder Social logo

anuragar / iotkit-samples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from enableiot/iotkit-samples

0.0 1.0 0.0 2.33 MB

Demonstration code for the IoT Kit

License: Other

JavaScript 25.97% Python 9.97% C++ 33.87% Arduino 21.98% C 8.02% Makefile 0.20%

iotkit-samples's Introduction

IoT Kit Samples

Samples illustrating application development on the IoT Kit platform.

Usage

These samples assume you have already installed (or have access to) the iotkit-agent which supports the following protocols:

  • UDP
  • TCP

Setup

In order to use iotkit-agent you have to create an account on iotkit dashboard iotkit-dashboard. Once you verify the registered email address you will be able to add individual devices. The rest of this document assumes you have already registered your devices in the Cloud.

Sensor Registration

In order to submit data to the IoT Kit Cloud, the individual sensors have to be registered first. The sensors type must be included in the Component Catalog associated with your iotkit-dashboard account.

Obtain the sensors types by executing the command catalog. Check how to execute this command in the iotkit-agent Readme.

Regardless of the protocol used, the iotkit-agent expects the inbound sensor registration message to be in following simple format:

UDP Message Format

{ "n": "<sensor name>", "t": "<sensor type>" }

Examples:
{ "n": "temperature sensor", "t": "temperature.v1.0"}
{ "n": "humidity sensor", "t": "humidity.v1.0"}

TCP Message Format

<size>#{ "n": "<sensor name>", "t": "<sensor type>" }

Examples:
53#{ "n": "temperature sensor", "t": "temperature.v1.0"}
47#{ "n": "humidity sensor", "t": "humidity.v1.0"}

Where:

  • sensor name: the sensor name ("Temperature", "Humidity", "Weight", "Force", etc.).
  • sensor type: is the sensor type of data this source generates (This should be one of the Component Type defined in your account Catalog available in the iotkit-dashboard)
  • size: is the message length

The registration needs to be performed only once for each new sensor

Usage of register command

For testing purposes, you can use the command iotkit-admin register <comp_name> <catalogid>. The is obtained with the catalog command mentioned before.

It's not required that the iotkit-agent be running to execute this command. The command will start the iotkit-agent, register the component and stop it.

Data Submission

Once the sensor has been registered, you can send your observations for that sensor to the cloud. Everything else will be provided by the agent before your message is relayed to the cloud. Regardless of the protocol used, the iotkit-agent expects the inbound message to be in following format:

UDP Message Format

{ "n": "<sensor name>", "v": "<value>", "on": <on> }

Examples:
{ "n": "temp sensor", "v": "5", "on": 1401893417000}

TCP Message Format

<size>#{ "n": "<sensor name>", "v": "<value>", "on": <on> }

Examples:
52#{ "n": "temp sensor", "v": "5", "on": 1401893417000}

Where:

  • sensor name: is the sensor name which was previously registered
  • value: is the value of this observation
  • on: optional: the observation timestamp
Usage of observation command

You can also use the command iotkit-admin observation <comp_name> <value> (just for testing purposes) to submit data for a specific component.

As command register, this will start the iotkit-agent, send the observation for the component and then stop the iotkit-agent.

For more information about iotkit-admin commands, go to section Notes about "admin" commands of iotkit-agent readme file.

Protocol-specific API

Many development frameworks have their own implementation of each one of these protocols. The following command-line examples should give you an idea how to access iotkit-agent API:

TCP

If assuring the message delivery to the iotkit-agent is important to you (yes, I'm talking about you UDP) you can use a simple TCP socket connection to send your data. Here is a command line example:

echo -n '52#{ "n": "temp sensor", "v": "5", "on": 1401893417000}' | nc 127.0.0.1 7070

How to

See our wiki pages for additional information (FAQs, Arduino, Data access etc.)

How to for Arduino

Feedback

Yes please... use the Issues Section to report bugs, recommend enhancements, or simply ask questions.

iotkit-samples's People

Contributors

mchmarny avatar pjholmes avatar mtomczew avatar jcarrz1 avatar jtaryma avatar davidverme avatar anilskeshavamurthy avatar javier-r avatar piti 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.