Nicky
Created December 1, 2016

child monitor

monitor your child health at ease. just ask alexa what is your child's temperature and know whether he/she is good.

80
child monitor

Things used in this project

Story

Read more

Code

intent schema

JSON
{
    "intents": [
        {
            "intent": "AMAZON.ResumeIntent"
        },
        {
            "intent": "AMAZON.PauseIntent"
        },
        {
            "intent": "GetTempIntent"
        },
        {
            "intent": "AMAZON.HelpIntent"
        },
        {
            "intent": "AMAZON.StopIntent"
        },
        {
            "intent": "AMAZON.CancelIntent"
        }
    ]
}

sample utterances

Tex
GetTempIntent what is the child's temperature
GetTempIntent can you tell me the child's temperatrure
GetTempIntent how is the child
GetTempIntent how is the kid
GetTempIntent is the kid ok

aeduino code

Arduino
#include <ESP8266WiFi.h> 
const char* server = "api.thingspeak.com"; 
String apiKey ="your API key here"; 
const char* MY_SSID = "your SSID here";  
const char* MY_PWD = "your SSID password here"; 
int sent = 0; 
void setup() { 
 Serial.begin(115200); 
 connectWifi(); 
} 
void loop() { 
 float temp; 
 //char buffer[10]; 
 temp = analogRead(A0); 
 //String tempC = dtostrf(temp, 4, 1, buffer);//handled in sendTemp() 
 Serial.print(String(sent)+" Temperature: "); 
 Serial.println(temp); 
 //if (temp != prevTemp) 
 //{ 
 //sendTeperatureTS(temp); 
 //prevTemp = temp; 
 //} 
 sendTeperatureTS(temp); 
 int count = myPeriodic; 
 while(count--) 
 delay(1000); 
} 
void connectWifi() 
{ 
 Serial.print("Connecting to "+*MY_SSID); 
 WiFi.begin(MY_SSID, MY_PWD); 
 while (WiFi.status() != WL_CONNECTED) { 
 delay(1000); 
 Serial.print("."); 
 } 
 Serial.println(""); 
 Serial.println("Connected"); 
 Serial.println("");   
}//end connect 
void sendTeperatureTS(float temp) 
{   
  WiFiClient client; 
  if (client.connect(server, 80)) { // use ip 184.106.153.149 or api.thingspeak.com 
  Serial.println("WiFi Client connected "); 
  String postStr = apiKey; 
  postStr += "&field1="; 
  postStr += String(temp); 
  postStr += "\r\n\r\n"; 
  client.print("POST /update HTTP/1.1\n"); 
  client.print("Host: api.thingspeak.com\n"); 
  client.print("Connection: close\n"); 
  client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n"); 
  client.print("Content-Type: application/x-www-form-urlencoded\n"); 
  client.print("Content-Length: "); 
  client.print(postStr.length()); 
  client.print("\n\n"); 
  client.print(postStr); 
  delay(1000); 
  }//end if 
  sent++; 
client.stop(); 
}//end send 

lambda function

JavaScript
'use strict'; 
var Alexa = require('alexa-sdk'); 
var request = require('aws-sdk/lib/request'); 

var url = 'https://api.thingspeak.com/channels/161182/fields/1.json?results=2'; 
var APP_ID = 'amzn1.ask.skill.dab4a8db-1c4c-4ab5-989f-0d2dbcff17cc'; //OPTIONAL: replace with "amzn1.echo-sdk-ams.app.[your-unique-value-here]"; 
var SKILL_NAME = 'Child health'; 
/** 
* Array containing space facts. 
*  
*/ 
var output ; 
request({ 
   url: url, 
   json: true 
}, function (error, response, body) { 
   if (!error && response.statusCode === 200) { 
       var obj = JSON.parse(body); 
       var arr = obj.feeds; 
       output = arr[0].field1; 
   } 
}); 

exports.handler = function(event, context, callback) { 
   var alexa = Alexa.handler(event, context); 
   alexa.APP_ID = APP_ID; 
   alexa.registerHandlers(handlers); 
   alexa.execute(); 
}; 
var handlers = { 
   'LaunchRequest': function () { 
       this.emit('GetTemp'); 
   }, 
   'GetNewAdviceIntent': function () { 
       this.emit('GetTemp'); 
   }, 
   'GetTemp': function () { 
      
       var speechOutput = output; 
       this.emit(':tellWithCard', speechOutput, SKILL_NAME, output) 
   }, 
   'AMAZON.HelpIntent': function () { 
       var speechOutput = "You can say what is the temperature, or, you can say exit... What can I help you with?"; 
       var reprompt = "What can I help you with?"; 
       this.emit(':ask', speechOutput, reprompt); 
   }, 
   'AMAZON.CancelIntent': function () { 
       this.emit(':tell', 'Goodbye!'); 
   }, 
   'AMAZON.PauseIntent': function () { 
       this.emit(':tell', 'paused'); 
   }, 
   'AMAZON.ResumeIntent': function () { 
       this.emit(':tell', 'app is resumed'); 
   }, 
   'AMAZON.StopIntent': function () { 
       this.emit(':tell', 'Goodbye!'); 
   } 
}; 

Credits

Nicky

Nicky

1 project • 0 followers

Comments