I have the below code working from https://www.youtube.com/watch?v=Y30iEOxl1To - to receive temperature & humidity as an sms when i give a missed call to a specific number (sim on the gsm shield)
The above code is like on demand sms. I also want to alter this code so it can automatically send me another sms if the temperature exceeds a threshold.
Please help.
Below is the code...
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "call.h"
#include <DHT.h>
#include "sms.h"
SMSGSM sms;
#define DHTPIN 7
#define DHTTYPE DHT22
CallGSM call;
boolean started=false;
char sms_text[160];
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
dht.begin();
Serial.begin(9600);
if (gsm.begin(9600))
{
Serial.println("\nstatus=READY");
started=true;
}
else
Serial.println("\nstatus=IDLE");
}
void loop()
{
float humidity, temperature;
String smsText ="";
if(temperature>29)
{
switch (call.CallStatus())
{
case CALL_NONE: // Nothing is happening
break;
case CALL_INCOM_VOICE : // Yes! Someone is calling us
Serial.println("RECEIVING CALL");
call.HangUp();
delay(1000);
humidity = dht.readHumidity();
temperature = dht.readTemperature();
delay(1000);
smsText = "Temperature: "+String(temperature,1)+"C Humidity: "+String(humidity,1)+"%";
smsText.toCharArray(sms_text,160);
//Serial.println(smsText);
sms.SendSMS("+91**********",sms_text);
break;
case CALL_COMM_LINE_BUSY: // In this case the call would be established
Serial.println("TALKING. Line busy.");
break;
}
delay(1000);
}
}