Things used in this project

Hardware components:
Intel.web.720.405
Intel Edison
×1
13036 01
SparkFun Block for Intel® Edison - Arduino
×1
10988 01
Temperature Sensor
×1
10167 01
DHT22 Temperature Sensor
×1
Software apps and online services:
Ha 2up iot
Amazon Web Services AWS IoT
Simpleicon sns
Amazon Web Services AWS SNS
Iam logo
Amazon Web Services AWS IAM
Intel XDK IoT Edition

Schematics

Temperature/Humidity Notifier Circuit
Intel Edison, HSM-20G T/H Sensor
H t notofier bb
Fritzing Source
h-t-notofier.fzz

Code

JavaScript Source CodeJavaScript
This code is for Intel Edison to publish notification to Amazon SNS
/*

MRAA - Low Level Skeleton Library for Communication on GNU/Linux platforms
Library in C/C++ to interface with Galileo & other Intel platforms, in a structured and sane API with port nanmes/numbering that match boards & with bindings to javascript & python.

Steps for installing MRAA & UPM Library on Intel IoT Platform with IoTDevKit Linux* image
Using a ssh client: 
1. echo "src maa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/intel-iotdk.conf
2. opkg update
3. opkg upgrade

*/
var awsIot = require('aws-iot-device-sdk'); //require for aws iot 
var mraa = require('mraa'); //require mraa for analog/digital read/write
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console

var myThingName = 'raspberry-pi';

var thingShadows = awsIot.thingShadow({
   keyPath: './b91fc77cfb-private.pem.key',
  certPath: './b91fc77cfb-certificate.pem.crt',
    caPath: './rootCA.pem',
  clientId: myThingName,
    region: 'us-west-2'
});

mythingstate = {
  "state": {
    "reported": {
      "ip": "unknown"
    }
  }
}

var networkInterfaces = require( 'os' ).networkInterfaces( );
mythingstate["state"]["reported"]["ip"] = networkInterfaces['wlan0'][0]['address'];

var temperaturePin = new mraa.Aio(2); //setup access analog input Analog pin #2 (A2)
var humidityPin = new mraa.Aio(1); //setup access analog input Analog pin #1 (A1)
var temperatureValue = temperaturePin.read(); //read the value of the analog pin
var humidityValue = humidityPin.read();
console.log(temperatureValue); //write the value of the analog pin to the console
console.log(humidityValue);

// calculate humidity
var humVoltage = ((humidityValue*5.0)/1023.0);
var humidity = (3.71*Math.pow(humVoltage,3))-(20.65*Math.pow(humVoltage,2))+(64.81*humVoltage)-27.44;
console.log(humidity);

// calculate temperature
var tmpVoltage = ((temperatureValue*5.0)/1023.0); // convert analog value to voltage
var temperature = (5.26*Math.pow(tmpVoltage,3))-(27.34*Math.pow(tmpVoltage,2))+(68.87*tmpVoltage)-17.81;
console.log(temperature);


  thingShadows.on('connect', function() {
  console.log("Connected...");
  console.log("Registering...");
  thingShadows.register( myThingName );

  // An update right away causes a timeout error, so we wait about 2 seconds
  setTimeout( function() {
    console.log("Updating my IP address...");
    clientTokenIP = thingShadows.update(myThingName, mythingstate);
    console.log("Update:" + clientTokenIP);
  }, 2500 );


  // Code below just logs messages for info/debugging
  thingShadows.on('status',
    function(thingName, stat, clientToken, stateObject) {
       console.log('received '+stat+' on '+thingName+': '+
                   JSON.stringify(stateObject));
    });

  thingShadows.on('update',
      function(thingName, stateObject) {
         console.log('received update '+' on '+thingName+': '+
                     JSON.stringify(stateObject));
      });

  thingShadows.on('delta',
      function(thingName, stateObject) {
         console.log('received delta '+' on '+thingName+': '+
                     JSON.stringify(stateObject));
      });

  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);
    });
	
  
  //Watch for temperature & humidity
if(temperature > 35 && humidity < 60){//SNS terget: arn:aws:sns:us-west-2:316723939866:TemperaturAlarm
   thingShadows.publish('arn:aws:sns:us-west-2:316723939866:TemperaturAlarm', 
                        'Your room temperature is greater than 35deg C');
   }
if(humidity > 60 && temperature < 35){
   thingShadows.publish('arn:aws:sns:us-west-2:316723939866:TemperaturAlarm', 
                        'Humidity is greater than 60% which is not desireable');
   }
if(humidity > 60 && temperature > 35){
   thingShadows.publish('arn:aws:sns:us-west-2:316723939866:TemperaturAlarm', 
                        'Both, Humidity & Temperature are in abnormal condition');
   }

});

Credits

Taifur1
Md. Khairul Alam

I love Electronics, I love Programming, I love Programmable Device. I try to learn and take action what I learn.

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Personal Healthcare Assistant PHA
Intermediate
  • 2,532
  • 119

Full instructions

Wearable for monitoring the health condition of patients who have suffered or are in risk of having a cardiac arrest.

Arduino Altair 8800 simulator
Intermediate
  • 6,565
  • 37

Full instructions

Ever wanted to play with the computer that sparked the personal computer age but don't have the cash to buy an Altair? Build your own!

Convo-Care: Alexa-Controlled E-Health App
Intermediate
  • 291
  • 8

Protip

Convo-Care provides a better e-health experience through a conversational UI.

OIKOS
Intermediate
  • 303
  • 8

Work in progress

OIKOS is a smart social-connected home for everyone. Our goal is to put the society in connection with homeless through IoT.

OIKOS

OIKOS NGO TEAM

Where'sMyPhone
Intermediate
  • 186
  • 3

Ever lose your phone under the couch? Find any mobile phone in seconds with Where'sMyPhone.

Smart and Safe Cabinets
Intermediate
  • 485
  • 10

Full instructions

With 41% of poisonings happening to children under 4, more needs to be done. We use Amazon Alexa and Intel IoT to lock and unlock cabinets.

Smart and Safe Cabinets

Magic Smoke Replacement Team

ProjectsCommunitiesContestsLiveJobsFree StoreBlogAdd projectSign up / Login
Respect project