Project ICICLE

ICICLE: Intelligent Control of Internal CLimate Equalization. Use localized control to ensure building wide climate control.

Work in progress961
Project ICICLE

Things used in this project

Hardware components

Grove starter kit plus for Intel Edison
Seeed Studio Grove starter kit plus for Intel Edison
×1
Electric heating pad
×3
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×3
Breadboard (generic)
Breadboard (generic)
×5
PC fan
×1

Software apps and online services

AWS IoT
Amazon Web Services AWS IoT
Johnny-Five
Johnny-Five

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

Final Product

Code

device-example.js

JavaScript
modified example code for connecting with cloud that turns on and off light.
/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */


 var five = require("johnny-five");
 var Edison = require("edison-io");
 var board = new five.Board({
   io: new Edison()
 });
//node.js deps

//npm deps

//app deps
//const deviceModule = require('..').device;
//const cmdLineProcess = require('./lib/cmdline');

//begin module

function processTest(args) {
   //
   // The device module exports an MQTT instance, which will attempt
   // to connect to the AWS IoT endpoint configured in the arguments.
   // Once connected, it will emit events which our application can
   // handle.
   //
   const device = deviceModule({
      keyPath: args.privateKey,
      certPath: args.clientCert,
      caPath: args.caCert,
      clientId: args.clientId,
      region: args.region,
      baseReconnectTimeMs: args.baseReconnectTimeMs,
      keepalive: args.keepAlive,
      protocol: args.Protocol,
      port: args.Port,
      host: args.Host,
      debug: args.Debug
   });

   var timeout;
   var count = 0;
   const minimumDelay = 250;

   if (args.testMode === 1) {
      device.subscribe('topic_1');
   } else {
      device.subscribe('topic_2');
   }
   if ((Math.max(args.delay, minimumDelay)) !== args.delay) {
      console.log('substituting ' + minimumDelay + 'ms delay for ' + args.delay + 'ms...');
   }
   timeout = setInterval(function() {
      count++;

      if (args.testMode === 1) {
         device.publish('topic_2', JSON.stringify({
            mode1Process: count
         }));
      } else {
         device.publish('topic_1', JSON.stringify({
            mode2Process: count
         }));
      }
   }, Math.max(args.delay, minimumDelay)); // clip to minimum

   //
   // Do a simple publish/subscribe demo based on the test-mode passed
   // in the command line arguments.  If test-mode is 1, subscribe to
   // 'topic_1' and publish to 'topic_2'; otherwise vice versa.  Publish
   // a message every four seconds.
   //
   device
      .on('connect', function() {
         console.log('connect');
      });
   device
      .on('close', function() {
         console.log('close');
      });
   device
      .on('reconnect', function() {
         console.log('reconnect');
      });
   device
      .on('offline', function() {
         console.log('offline');
      });
   device
      .on('error', function(error) {
         console.log('error', error);
      });
   device
      .on('message', function(topic, payload) {
         console.log('message', topic, payload.toString());

         var relay = new five.Relay({
         pin: 5,
         type: "NC"
       });

         if (Number(payload)==1) {
           relay.close();
         }
         if (Number(payload)==0) {
           relay.open();
         }

      });

}

module.exports = cmdLineProcess;

if (require.main === module) {
   cmdLineProcess('connect to the AWS IoT service and publish/subscribe to topics using MQTT, test modes 1-2',
      process.argv.slice(2), processTest);
}

Credits

Eli Johnson

Eli Johnson

1 project • 2 followers
Mohsen Omrani

Mohsen Omrani

1 project • 2 followers
Marcos Rodriguez

Marcos Rodriguez

1 project • 2 followers
Marcos Rodriguez
Vincent Wu

Vincent Wu

1 project • 1 follower
John Wojcik

John Wojcik

2 projects • 2 followers
Gregory O. Voronin

Gregory O. Voronin

12 projects • 106 followers
biomedical researcher - hope & cures through research; making in my spare time - don't hesitate to reach out!

Comments