develop iot project with airvantage m2m cloud

37
1 Develop IoT project with AirVantage M2M Cloud Crystal Lam – AirVantage Product Marketing Manager

Upload: crystal-lam

Post on 21-Jun-2015

479 views

Category:

Technology


1 download

DESCRIPTION

Learn how to build an Internet of Things (IoT) project with sensors, BeagleBone Black, MQTT protocol and the AirVantage M2M cloud

TRANSCRIPT

Page 1: Develop IoT project with AirVantage M2M Cloud

1

Develop IoT project with AirVantage M2M Cloud

Crystal Lam – AirVantage Product Marketing Manager

Page 2: Develop IoT project with AirVantage M2M Cloud

2

Agenda

• Introduction

• Eclo Inc. & their greenhouses

• Example: Greenhouse project

• Q&A

Page 3: Develop IoT project with AirVantage M2M Cloud

3

In the Air Design Challenge

Page 4: Develop IoT project with AirVantage M2M Cloud

4

Sierra Wireless Device-to-Cloud Solution

Leading-edge intelligent devices

Secure cloud services platform

Value creation& competitive barriers+ =

Page 5: Develop IoT project with AirVantage M2M Cloud

5

Eclo Inc. & their greenhouses

Corporatesoftware

sensor

Embedded system

Support team

greenhouse

actuator

Customers

MQTT

REST API

AlertMonitoringTroubleshoot

ConfigurationSoftware upgradeAlertStatistics

Asset monitoring

Page 6: Develop IoT project with AirVantage M2M Cloud

6

Example: Greenhouse project

BeagleBone Black

MQTT

Mobile/ Web App

SensorsActuators REST

API

Page 7: Develop IoT project with AirVantage M2M Cloud

7

Bill of Material

• BeagleBone Black (and the USB cable)

• Ethernet cable

• Sensors and actuators (e.g. servomotor)

• AirVantage M2M Cloud account

Get an AirVantage Enterprise Platform trial account:https://signup.airvantage.net/public/avep/

(Free for 6 months, up to 10 systems)

Don’t have one?

Page 8: Develop IoT project with AirVantage M2M Cloud

8

Key steps

Page 9: Develop IoT project with AirVantage M2M Cloud

9

Step 1:Develop embedded code on BBB

Cloud9 IDE

Ethernet cable

USB cable

sensors

Page 10: Develop IoT project with AirVantage M2M Cloud

10

Embedded code

Purposes:

• Setup connection with AirVantage

• Read the sensor inputs• Send the data to AirVantage• Listen to the command from

AirVantage

Test it on Cloud9

Keep sending data to AirVantage!

Get the sample code : https://github.com/crystallam/beagleboneblack-mqtt-greenhouse Customize the code and flash it to your BBB with the Cloud9 IDE

Page 11: Develop IoT project with AirVantage M2M Cloud

11

Step 2: Register your BBB on AirVantage

Go to Inventory tab/ Systems: register your BBB by creating a new system

Page 12: Develop IoT project with AirVantage M2M Cloud

12

Create a system

System = “Gateway” (hardware) + “Subscription” (optional) + “Applications” (software)

Note your BBB serial number and the MQTT password for the embedded code

Page 13: Develop IoT project with AirVantage M2M Cloud

13

Application model

Find an example in the tutorial “Using MQTT with AirVantage” :https://doc.airvantage.net/display/USERGUIDE/Using+MQTT+with+AirVantage

Application model

- Describe the capability of the embedded application

- Help AirVantage UI to understand what are the data and commands sent by the systems

Page 14: Develop IoT project with AirVantage M2M Cloud

14

Publish it on AirVantage

Go to Develop tab/ My Apps and release your app to the repository

Page 15: Develop IoT project with AirVantage M2M Cloud

15

Release & publish your application

Page 16: Develop IoT project with AirVantage M2M Cloud

16

Step 3:Test it on AirVantageGo to Monitor tab/ Systems, and click on your BBB to find this System detail page

Page 17: Develop IoT project with AirVantage M2M Cloud

17

Timeline – troubleshoot

Troubleshoot with all the data sent from your device to AirVantage

Page 18: Develop IoT project with AirVantage M2M Cloud

18

Data History – analyze data

Plot aggregated data on chart, identify trends

It works!

Page 19: Develop IoT project with AirVantage M2M Cloud

19

Step 4: Use API

First thing to do : create an API Client as the identifier of your application

Page 20: Develop IoT project with AirVantage M2M Cloud

20

AirVantage uses OAuth 2.0• Pick the most suitable OAuth flow to get the

access token

– Resource owner for really trusted application

– Authorization code for server-side application

– Implicit for client-side application

Implement authentication

Specs: http://tools.ietf.org/html/rfc6749

Page 21: Develop IoT project with AirVantage M2M Cloud

21

AirVantage API

Base URI : https://na.airvantage.net/api/v1

HTTP VerbsGET: Used for retrieving resources.

POST: Used for creating resources, or performing custom actions.

PUT: Used for updating resources or collections.

DELETE: Used for deleting resources.

Resource Path : find them all in the API Documentation

Get an access token with OAuth 2.0

21

> GET https://{server}/api/v1/users/current?access_token={token}

HTTP Verb Base URI Resource Path

This is the typical format of our REST API

Page 22: Develop IoT project with AirVantage M2M Cloud

22

I want to use the AirVantage API to • get data sent from the greenhouses,

• automate communications,

• analyze the data

For the greenhouse project

Page 23: Develop IoT project with AirVantage M2M Cloud

23

« I want to see the stream of values sent from my device. »

API to list all historical values for a given data of a system

e.g. greenhouse.temperature:

Raw data

> GET https://{server}/api/v1/systems/data/raw? targetIds={system_uid} &dataIds={data_id} &access_token={token}

Page 24: Develop IoT project with AirVantage M2M Cloud

24

« I want my device to execute a command. »

API to send a command to given system. e.g. powerFan

Send commands & track operation

> POST https://{server}/api/v1/operations/systems/command?access_token={token}{ "systems" : { "uids" : [“{system_uid}"] }, "commandId" : “{command_id}"}

Page 25: Develop IoT project with AirVantage M2M Cloud

25

« I want to validate the command has been received and executed. »

API to get the details of an operation

> GET https://{server}/api/v1/operations/{operation_uid}?access_token={token}

Send commands & track operation

Page 26: Develop IoT project with AirVantage M2M Cloud

26

« I want to validate the command has been received and executed. »

API to get the details of an operation

• Track the "state" property to know if the operation is done

• Track the "state" property of the different "counters" to know if it worked or not

Send commands & track operation

> GET https://{server}/api/v1/operations/{operation_uid}?access_token={token}

Page 27: Develop IoT project with AirVantage M2M Cloud

27

« I want to be notified when the temperature is above a threshold. »

Configure an alert rule

Setup the "Call URL" to enable webhook notifications

Alerts & Webhooks

Page 28: Develop IoT project with AirVantage M2M Cloud

28

Alerts & Webhooks

Page 29: Develop IoT project with AirVantage M2M Cloud

29

AirVantage will send a request on the callback URL as soon as a new alert is generated

Alerts & Webhooks

> POST http://www.yoursite.com/your_callback{

"name":"event.alert.rule.triggered","date":1385718100163,"content": {

"alert.uid":"f04a77e306de463e919ec39c387fa016","rule.uid":"7316ee643b17473381b61b8ac0afa824","target.uid":"da687e2c39d54bc391633fa9c8d4c0da"

}}

Page 30: Develop IoT project with AirVantage M2M Cloud

30

« I want to analyze the data sent by my device.»

API to get aggregated values of data and multiple systems

Available functions:

mean, max, min, standard deviation, sum of squares, count, count of occurrences

e.g. get the average temperature of the greenhouses in Toulouse, Nice, Paris

Aggregated data (System level)

> GET https://{server}/api/v1/systems/data/aggregated? targetIds={system_uid1},{system_uid2}… &dataIds={data_id1},{data_id2}… &fn={aggregation_function} &access_token={token}

Page 31: Develop IoT project with AirVantage M2M Cloud

31

« I want to analyze the data sent by all my devices.»

API to get aggregated values for data of all the systems

Aggregated data (Fleet level)

> GET https://{server}/api/v1/systems/data/fleet? targetIds={company_uid1} &dataIds={data_id1},{data_id2}… &fn={system_aggregation_function} &fleetFn={fleet_aggregation_function} &access_token={token}

e.g. get the maximum values of the average temperature of all my greenhouses

Page 32: Develop IoT project with AirVantage M2M Cloud

32

Want to test the API now?

Try tools like Postman – www.getpostman.com

Page 33: Develop IoT project with AirVantage M2M Cloud

33

What’s next?

Use the AirVantage API to get data with your favorite language

Check out sample web app “eclo watch”: https://github.com/AirVantage/sampleapp-eclo-watch

Data visualization

Dashboard

Page 34: Develop IoT project with AirVantage M2M Cloud

34

The key steps again

SensorsActuators MQTT REST

API

Application

Step 1. Develop the embedded code on BBB

Step 2. Register BBB on AirVantage to receive data/ send command

Step 3. Test it on AirVantage

Step 4. Create API clientAuthenticate OAuth 2Use APIs

Page 35: Develop IoT project with AirVantage M2M Cloud

35

Explore the resources• Get your free trial account: https://signup.airvantage.net/public/avep/

• To get started with AirVantage, check our the User Guide and Developer Guide: https://doc.airvantage.net/

• Find the full list of the API in Develop/ API Documentation

• Check out http://airvantage.github.io/ for API libraries, projects and sample codes

• Tutorials mentioned:

– Connect your BBB to AirVantage using MQTT: https://doc.airvantage.net/display/USERGUIDE/Using+MQTT+with+AirVantage

– Embedded code for BBB to send/receive sensor data to AirVantage: https://github.com/crystallam/beagleboneblack-mqtt-greenhouse

– Web app example (“eclo watch): https://github.com/AirVantage/sampleapp-eclo-watch

• Need help?

– Forum: https://forum.sierrawireless.com/

– Feedback button on the web user interface @crystallam31@airvantage

Page 36: Develop IoT project with AirVantage M2M Cloud

36

Thank YouThank you

Questions?

Page 37: Develop IoT project with AirVantage M2M Cloud

37

House by Wayne Tyler Sall from The Noun Project

Thermostat by Luboš Volkov from The Noun Project

Fan by Arthur Shlain from The Noun Project

People by Berkay Sargın from The Noun Project

Cell Phone by Yorlmar Campos from The Noun Project

Router by im icons from The Noun Project

Circuit Board by Mike Wirth from The Noun Project

Credits