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,579
Smart lighting system

Things used in this project


Read more


Block diagram


Code for Smart lighting system

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);

//set the period in microseconds.

function readLightSensorValue() {
    console.log(light.name() + " raw value is " + light.raw_value() +
            ", which is roughly " + light.value() + " lux");
    var value = light.raw_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}));




1 project • 1 follower
Nagthej Manangi Ravindrarao

Nagthej Manangi Ravindrarao

1 project • 0 followers


1 project • 0 followers


Add projectSign up / Login