i have a gsm module to send a call after a certain range of temperature which i working fine then i have an led to blink after a predefined time also working but i run into a problem when i combine both code together.. after joining the codes only the part of the call works .
here's the code..
#include <SoftwareSerial.h>
#include <dht.h>
dht DHT;
SoftwareSerial mySerial(7, 8);
#define DHT11_PIN 2
int sensor=2;
float temp_read,Temp_alert_val,Temp_shut_val,hum_read;
int call_count=0;
unsigned long startTime;
void setup()
{
pinMode(sensor,INPUT);
mySerial.begin(9600);
Serial.begin(9600);
delay(100);
mySerial.print("AT");
startTime = millis();
pinMode(13, OUTPUT);
}
void loop()
{
//BeatSignal();
CheckHum();
}
void CheckHum()
{
Temp_alert_val=CheckTemp();
if(Temp_alert_val< 25.00)
{
SetAlert(); // Function to send Call Alerts
}
}
float CheckTemp()
{
int chk = DHT.read11(DHT11_PIN);
temp_read = DHT.temperature;
hum_read = DHT.humidity;
return temp_read;
return hum_read;
}
void SetAlert()
{
while(call_count<3) //Number of Calls Alerts to be sent
{
MakeCall(); // Function to send AT Commands to GSM module
}
}
void MakeCall()
{
Serial.println(temp_read);
Serial.println(hum_read);
delay(1000);
mySerial.println("ATD;"); // ATDxxxxxxxxxx; -- watch out here for semicolon at the end!!
Serial.println("Calling ; "); // print response over serial port
delay(10000);
mySerial.println("ATH");
Serial.println("Hangup Call");
delay(1000);
call_count=0;
}
void BeatSignal(){
unsigned long inputTime = 0;
inputTime = 10000;
Serial.print("am here");
if(millis() - startTime == inputTime){
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
startTime = millis(); //reset the timer
}
}
Plz any idea is appreciated thank you