Things used in this project

Hardware components:
Intel.web.720.405
Intel Edison
×1
Grove 20starter 20kit 20plus 20  20intel c2 ae 20iot2 01
SeeedStudio Grove starter kit plus for Intel Edison
Light Sensor, Moisture Sensor, Temperature and humdity sensor
×1
Software apps and online services:
Ha 2up iot
Amazon Web Services AWS IoT
Screen%20shot%202015 07 20%20at%206.11.48%20pm
Amazon Web Services AWS DynamoDB
Intel XDK
Ide web
Arduino IDE
Iam logo
Amazon Web Services AWS IAM

Schematics

Schematics 'Plantopia'
4vxjgmoyrmdorbvnyud2

Code

PlantopiaJavaScript
/*
 * testPcode 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.
 *
 * https://software.intel.com/en-us/xdk/docs/lp-xdk-iot
 */



"use strict" ;

var mraa = require("mraa") ;
var mqtt = require('mqtt');
var fSystem = require('fs');

var LightSensorPin_A0 = new mraa.Aio(0);
var MoistureSensorPin_A2 = new mraa.Aio(2);

var ReadSensorValue = false;


var options = {
  host: 'a28xfzz2n1aori.iot.us-west-2.amazonaws.com',
  key: fSystem.readFileSync('/home/root/connect_device_package/myEdison.private.key'),
  cert: fSystem.readFileSync('/home/root/connect_device_package/myEdison.cert.pem'),
  ca:  [fSystem.readFileSync('/home/root/connect_device_package/root-CA.crt')],
  requestCert: true,
  rejectUnauthorized: true,
  port: 8883,
  cleanSession: true,
  //protocolId: 'MQIsdp',
  //protocolVersion: 
};


var mqttClient  = mqtt.connect('mqtts://data.iot.us-west-2.amazonaws.com',options);
console.log("Connecting to AWS MQTT ...");
mqttClient.on('connect', function onConnect(data) {
  console.log("Connected to AWS MQTT: " + data);
  if (ReadSensorValue == false) {
    fnLoop(); 
  }
});


var LightSensorStatus = 0;
var TempSensorStatus = 0;
var MoistureSensorStatus = 0;
var HumiditySensorStatus = 0;

var min_Moist_val = 0;
var max_Moist_val = 1023;
var min_Moist_perc = 0;
var max_Moist_perc = 100;

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

var fnLoop = function(){
    
    ReadSensorValue = true;
    var ReadLightSensor = false;
    var ReadMoistureSensor = false;
    
    var LightSensorValue    = LightSensorPin_A0.read();
    var MoistureSensorValue = MoistureSensorPin_A2.read();
    console.log("\nLight Intensity:", LightSensorValue);
    console.log("--------------------------------------");
    var moisture_percent = mapMoistureValue(MoistureSensorValue, 0, 1023, 0, 100);
    console.log("\nPercentage of Soil-Moisture:", moisture_percent + "%");
    console.log("--------------------------------------");
    
    var pubMessage = {reading_timestamp:new Date().getTime(), Illuminance:LightSensorValue};
        mqttClient.publish('Plantopia/Sensors/Illuminance/LightSensor', JSON.stringify(pubMessage),{
        }, function() {
          ReadLightSensor = true;
        }); 

    var pubMessage = {reading_timestamp:new Date().getTime(), Moisture:moisture_percent};
        mqttClient.publish('Plantopia/Sensors/Moisture/MoistureSensor', JSON.stringify(pubMessage), { 
        }, function() {
          ReadMoistureSensor = true;
        });

};

board.on("ready", function() {
    var mul = new five.Multi({
        controller: "TH02"
});

    mul.on("change", function() {
        
        console.log("Thermometer");
        //console.log("  celsius           : ", this.thermometer.celsius);
        //console.log("  fahrenheit        : ", this.thermometer.fahrenheit);
        //console.log("  kelvin            : ", this.thermometer.kelvin);
        console.log("--------------------------------------");

        console.log("Hygrometer");
        //console.log("  relative humidity : ", this.hygrometer.relativeHumidity);
        console.log("--------------------------------------");


        });
});

function mapMoistureValue(val, min_Moist_Val, max_Moist_val, min_Moist_perc, max_Moist_perc){
    return Math.round((val - min_Moist_val) * (max_Moist_perc - min_Moist_perc) / (max_Moist_val - min_Moist_val) + min_Moist_perc);
}


var intervalID = setInterval(fnLoop, 2000) ;  // read interval = 2s

process.on("exit", function(code) {
    clearInterval(intervalID) ;
    console.log("\nExiting " + ", with code:", code) ;
}) ;

Credits

N6doiusgtjbuxyyqiucv
Sampreeti Alam

Graduate Student in Dept. of ECE, New York University

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,053
  • 118

Full instructions

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

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

Protip

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

Rocky Rover: Robotic Vision System PixyCam & Arduino 101
Intermediate
  • 4,522
  • 48

Full instructions

Using PixyCam and Intel Arduino 101 to drive this rover. Easy Robotic Vision system using PixyCam, rover reacts to the ball using Pan/Tilt.

OIKOS
Intermediate
  • 256
  • 6

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

Family, friend or foe - PIR arm/disarm using BLE
Intermediate
  • 98
  • 2

Full instructions

It's a BLE-enabled, cloud-connected smartphone app used to control & monitor who/when PIR is armed/disarmed. Uses Slack for notifications.

Robot for supercool indoor navigation
Intermediate
  • 899
  • 12

Full instructions

The robot navigates indoor, in a pre-defined path, with high accuracy, and allows its real-time tracking on a phone. No GPS, No WiFi, No Map

ProjectsCommunitiesContestsLiveJobsFree StoreBlogAdd projectSign up / Login
Respect project