Click here to Skip to main content
15,895,746 members
Articles / Internet of Things
Article

Intel(R) XDK IoT Edition node.js Templates

Rate me:
Please Sign up or sign in to vote.
1.00/5 (1 vote)
10 Dec 2014CPOL2 min read 6.5K   3  
Intel XDK® IoT Edition is a HTML5 hybrid and node.js application development environment that allow users to deploy, run, debug on various IoT platforms such as the Intel® Galileo and Edison board

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

The source code for these templates can be found here: https://github.com/gomobile?query=iotapp or download the Intel® XDK IoT Edition to check out all the node.js IoT application templates.

Image 1

Introduction

Intel XDK® IoT Edition is a HTML5 hybrid and node.js application development environment that allow users to deploy, run, debug on various IoT platforms such as the Intel® Galileo and Edison board running the IoT Development Kit Linux Image and utilizes the Grover Starter Kit Plus – IoT Intel® Edition. With the starter kit and Linux* image installed, your development platform is ready to connect to XDK IoT Editon and run your node.js applications. Along with development features, this development environment provides various node.js templates and samples intended for running on Intel IoT platforms. For more information on getting started, go to https://software.intel.com/en-us/html5/documentation/getting-started-with-intel-xdk-iot-edition.

Purpose

The templates distributed within Intel® XDK IoT Edition provides compelling functionality such as access to various ways to handle analog and digital data transmitted to plus received from sensor(s) connected to any IO pin(s) among other functionality. In order to communicate with sensors, each of the relevant templates uses the MRAA Sensor Communication Library. The intent of this library is to make it easier for developers and sensor manufacturers to map their sensors & actuators on top of supported hardware and to allow control of low level communication protocol by high level languages & constructs.

Design Considerations

Each of the templates require the mraa library and xdk daemon to be installed on your board. These two requirements are included in the IoT Development Kit Linux Image which enables communication between your board and XDK IoT Edition plus access to the IO pins.

Development /Testing

Each of the templates have been test on Intel® Galileo Generation 1 and 2 boards as well as the Intel® Edison board.

Intel® XDK IoT Edition IoT node.js templates

OnBoard LED Blink

A simple node.js application intended to blink the onboard LED on the Intel based development boards such as the Intel(R) Galileo and Edison with Arduino breakout board. Source: https://github.com/gomobile/iotapp-template-onboard-led-blink

JavaScript
var mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the Intel XDK console
var myOnboardLed = new mraa.Gpio(13); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2 plus Edison Arduino Breakout board)
myOnboardLed.dir(mraa.DIR_OUT); //set the gpio direction to output

Analog Read

A simple node.js application intended to read data from Analog pins on the Intel based development boards such as the Intel(R) Galileo and Edison with Arduino breakout board. Source: https://github.com/gomobile/iotapp-template-analog-read

JavaScript
var mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
var analogPin0 = new mraa.Aio(0); //setup access analog input Analog pin #0 (A0)
var analogValue = analogPin0.read(); //read the value of the analog pin
console.log(analogValue); //write the value of the analog pin to the console

Digital Read

A simple node.js application intended to read data from Digital pins on the Intel based development boards such as the Intel(R) Galileo and Edison with Arduino breakout board. Source: https://github.com/gomobile/iotapp-template-digital-read

JavaScript
var mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
var myDigitalPin6 = new mraa.Gpio(6); //setup digital read on Digital pin #6 (D6)
myDigitalPin6.dir(mraa.DIR_IN); //set the gpio direction to input

Digital Write

A simple node.js application intended to write data to Digital pins on the Intel based development boards such as the Intel(R) Galileo and Edison with Arduino breakout board. Source: https://github.com/gomobile/iotapp-template-digital-write

JavaScript
var mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
var myDigitalPin5 = new mraa.Gpio(5); //setup digital read on Digital pin #5 (D5)
myDigitalPin5.dir(mraa.DIR_OUT); //set the gpio direction to output
myDigitalPin5.write(1); //set the digital pin to high (1)

PWM

A simple node.js application intended to read and write analog values to fade a LED from Digital pins (PWM) on the Intel based development boards such as the Intel(R) Galileo and Edison with Arduino breakout board. Source: https://github.com/gomobile/iotapp-template-pwm

JavaScript
var mraa = require("mraa"); //require mraa
//Initialize PWM on Digital Pin #3 (D3) and enable the pwm pin
var pwm3 = new mraa.Pwm(3, -1, false);
pwm3.enable(true);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --