HarshaNagthej Manangi Ravindraraokarthik_siddalingappa
Published © GPL3+

Smart lighting system

Real-time monitoring to save energy and provide a medium to find if the lighting system is defective by using Internet of Things (IoT).

BeginnerWork in progressOver 1 day1,575
Smart lighting system

Things used in this project

Hardware components

Intel Edison
Intel Edison
×1
Grove starter kit plus for Intel Edison
Seeed Grove starter kit plus for Intel Edison
×1

Software apps and online services

AWS IoT
Amazon Web Services AWS IoT
AWS SNS
Amazon Web Services AWS SNS
AWS IAM
Amazon Web Services AWS IAM
Intel XDK

Story

Read more

Schematics

Block diagram

Code

Code for Smart lighting system

JavaScript
Node.js (written in javascript)
/*
 * Blank IoT Node.js starter app.
 *
 * Use this template to start an IoT Node.js app on any supported IoT board.
 * The target board must support Node.js. It is helpful if the board includes
 * support for I/O access via the MRAA and UPM libraries.
 *
 *
 */


// keep these lines (below) for proper jshinting and jslinting
/*jslint node:true, vars:true, bitwise:true */
/*jshint unused:true, undef:true */
// see http://www.jslint.com/help.html and http://jshint.com/docs


var mraa = require("mraa") ;
var a;

// Load Grove module
var groveSensor = require('jsupm_grove');
/* IOT*/


//
// Replace the values of '<YourUniqueClientIdentifier>' and '<YourAWSRegion>'
// with a unique client identifier and the AWS region you created your
// certificate in (e.g. 'us-east-1').  NOTE: client identifiers must be
// unique within your AWS account; if a client attempts to connect with a
// client identifier which is already in use, the existing connection will
// be terminated.
//
var awsIot=require('aws-iot-device-sdk');
var device = awsIot.device({
   keyPath: '/home/root/KEY/c66fce73cb-private.pem.key',
  certPath: '/home/root/KEY/c66fce73cb-certificate.pem.crt',
    caPath: '/home/root/KEY/root_key.pem.key',
  clientId: 'Edison',
    region: 'us-west-2' 
});

// Create the light sensor object using AIO pin 0
var light = new groveSensor.GroveLight(0);
// Read the input and print both the raw value and a rough lux value,
// waiting one second between readings
//Initialize PWM on Digital Pin #3 (D3) and enable the pwm pin
var pwm3 = new mraa.Pwm(3);
pwm3.enable(true);

//set the period in microseconds.
pwm3.period_us(2000);


function readLightSensorValue() {
    console.log(light.name() + " raw value is " + light.raw_value() +
            ", which is roughly " + light.value() + " lux");
    
    var value = light.raw_value();
    pwd(value);
    
    device.publish('test',JSON.stringify({test_data: value}));
    
}


setInterval(readLightSensorValue, 1000);
// add any UPM requires that you need
// and the rest of your app goes here

console.log(mraa) ;     // prints mraa object to XDK IoT debug output panel





//------------------code for PWD----------------//



function pwd( a) {
     console.log("printing a "+a);
    var b=(750-a)/600;
    pwm3.write(b); //Write duty cycle value.  
     
    console.log(pwm3.read());//read current value that is set before.
   // device.publish('value of a ',JSON.stringify({test_a: b}));
    
}

Credits

Harsha

Harsha

1 project • 1 follower
Nagthej Manangi Ravindrarao

Nagthej Manangi Ravindrarao

1 project • 0 followers
karthik_siddalingappa

karthik_siddalingappa

1 project • 0 followers

Comments

Add projectSign up / Login