Top Internet of Things Daily & Weekly

Environment Monitor With AWS IoT

Environment Monitor With #AWS #IoT by @PoojaBrs CC @CsharpCorner

  • Figure 1: Create an account at AWS Cloud
  • We will be using AWS Cloud in this project.
  • Let us create a simple temperature monitor with Edison which will monitor the room temperature and notify us through an email.
  • Connect the temperature sensor to A2 pin of Edison.
  • Create a new Role and add the recently created SNS action.

This article shows a simple environment monitor which sends you an email when an abnormal weather condition is detected.

@CsharpCorner: Environment Monitor With #AWS #IoT by @PoojaBrs CC @CsharpCorner

The compute module of Intel called Intel Edison is slightly larger than a SD card. It has an onboard Wi-Fi and Bluetooth, perfect for IoT projects. We can connect to Edison remotely and run commands or access the file system. This gives lots of flexibility to developers via SSH.

Edison can be used with Arduino IDE but to get the most out of it you can use other programming languages like Python, Node.js, C/C++. Intel has its own IDE called Intel XDK IoT edition which makes programming with Edison easy. While setting up the programming environment for Edison you can choose between Arduino IDE, Intel XDK or Eclipse.

Let us create a simple temperature monitor with Edison which will monitor the room temperature and notify us through an email. We will be using AWS Cloud in this project. AWS environment consists of a number of different AWS services providing security, transport, and storage of the sender data produced by your device. All services in AWS are delivered via a rich set of REST APIs. You can use a service programmatically through the APIs or can invoke manually using the console which make AWS Cloud powerful. It also offers numbers of API to speed our development with the language of our choice. Hence I have chosen its Node.Js library to interact with my Edison.

Follow the steps to setup the cloud environment:

Create an account at AWS Cloud.

Create and attach a thing.

Generate and download the keys and certificates to make connections.

Set up AWS SNS and create a topic.

Create an Email Subscription in SNS and publish the topic.

In AWS IoT page, Create a Rule from the Resource panel and select “Send message as a push notification (SNS)” from Action dropdown. Create a new Role and add the recently created SNS action.

Flash your Edison and enable WIFI on it.

Establish a serial connection with Edison and run this command to install the AWS IoT SDK.

Create a new project in Intel XDK, and paste the code.

varawsIot = require( ‘aws-iot-device-sdk’ );  //require for awsiot   

console.log(‘MRAA Version: ‘  + mraa.getVersion());  //write the mraa version to the console   

 * CONFIGURATION VARIABLES  

 * export AWS_ACCESS_KEY_ID=’AKID’ 

 * export AWS_SECRET_ACCESS_KEY=’SECRET’ 

varmqttPort = 8883;  

varrootPath = ‘/home/root/awscerts/’ ;  

varawsRootCACert = “root-CA.pem.crt” ;  

vartopicName = “Edison” ;  

varawsClientId = “Edison” ;  

varmyThingName = ‘Edison’ ;  

keyPath: privateKeyPath,  

certPath: clientCertPath,  

caPath: rootCAPath,  

clientId: awsClientId,  

region: ‘us-west-2’   

mythingstate = {  

  “state” : {  

    “reported” : {  

      “ip” :  “unknown”   

varnetworkInterfaces = require( ‘os’  ).networkInterfaces( );  

mythingstate[“state” ][ “reported” ][ “ip” ] = networkInterfaces[ ‘wlan0’ ][0][ ‘address’ ];  

console.log(temperature);  

thingShadows.on(‘connect’ , function() {  

console.log(“Connected…” );  

console.log(“Registering…” );  

thingShadows.register (myThingName );  

setTimeout( function() {  

console.log(“Updating my IP address…” );  

clientTokenIP = thingShadows.update(myThingName, mythingstate);  

console.log(“Update:”  + clientTokenIP);  

thingShadows.on(‘status’ ,  

function(thingName, stat, clientToken, stateObject) {  

console.log(‘received ‘ +stat+ ‘ on ‘ +thingName+ ‘: ‘ +  

thingShadows.on(‘update’ ,  

function(thingName, stateObject) {  

console.log(‘received update ‘ + ‘ on ‘ +thingName+ ‘: ‘ +  

thingShadows.on(‘delta’ ,  

function(thingName, stateObject) {  

console.log(‘received delta ‘ + ‘ on ‘ +thingName+ ‘: ‘ +  

thingShadows.on(‘timeout’ ,  

function(thingName, clientToken) {  

console.log(‘received timeout for ‘ + clientToken)  

thingShadows  

    .on(‘close’ , function() {  

console.log(‘close’ );  

thingShadows  

    .on(‘reconnect’ , function() {  

console.log(‘reconnect’ );  

thingShadows  

    .on(‘offline’ , function() {  

console.log(‘offline’ );  

thingShadows  

    .on(‘error’ , function(error) {  

console.log(‘error’ , error);  

if (temperature > 35 ){  

Environment Monitor With AWS IoT

Comments are closed, but trackbacks and pingbacks are open.