GSM-based humidity measurement system

i am doing a project using arduino, GSM and DHT11. i want the system to work so that whenever i call the number on GSM i get humidity and temperature values. Also, i want the GSM to send an sms whenever upper or lower limit of humidity that i have set is exceeded. however, the call part is not sending the values back. the code is given below

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "call.h"
#include <DHT.h>
#include "sms.h"

SMSGSM sms;
#define DHTPIN 7
#define DHTTYPE DHT11

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 = "";
  humidity = dht.readHumidity();
  temperature = dht.readTemperature();
  delay(2000);
  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(2000);

      smsText = "Temperature: " + String(temperature, 1) + "C Humidity: " + String(humidity, 1) + "%";
      smsText.toCharArray(sms_text, 160);
      //Serial.println(smsText);
      sms.SendSMS("+***********", sms_text);
      break;

    case CALL_COMM_LINE_BUSY:  // In this case the call would be established

      Serial.println("TALKING. Line busy.");

      break;
  }
  delay(1000);

  if (humidity >= 90)
  {

    smsText = " Humidity above setpoint: " + String(humidity, 1) + "%";
    smsText.toCharArray(sms_text, 160);
    //Serial.println(smsText);
    sms.SendSMS("+***********", sms_text);
    delay (3600000);
  }
  if (humidity <= 80)
  {
    smsText = " Humidity below setpoint: " + String(humidity, 1) + "%";
    smsText.toCharArray(sms_text, 160);
    //Serial.println(smsText);
    sms.SendSMS("+***********", sms_text);
    delay (3600000);

  }
}

however, the call part is not sending the values back.

And yet you shared no serial output and did not describe what happens instead.

Please use Tools + Auto Format before you post crappy looking code again.

the code has no error its only not sending data whenever i call nor even displaying "receiving call" on serial output

its only not sending data whenever i call nor even displaying "receiving call" on serial output

So, the Arduino does not see that you are calling the SIM900, so it doesn't send a text message, and somehow that is a problem with not sending a text message when a call comes in.

Well, OK. I don't think I'd be attacking the problem from that end.

Did the example work? That is, did it acknowledge that it was being called when you called it?

before i introduced the if condition the code works well. that is when you call it sends back an sms with the data
but with the if condition, it fails to acknowledge the call when i make it

iderealfred:
before i introduced the if condition the code works well. that is when you call it sends back an sms with the data
but with the if condition, it fails to acknowledge the call when i make it

This if condition?

  if (humidity >= 90)
  {

    smsText = " Humidity above setpoint: " + String(humidity, 1) + "%";
    smsText.toCharArray(sms_text, 160);
    //Serial.println(smsText);
    sms.SendSMS("+***********", sms_text);
    delay (3600000);
  }

The one that says ignore EVERYTHING that happens for the next hour?

Is it during that hour that you call the SIM900?

even without the delay the call part does not work. that one hour delay was actually meant that if the humidty is above the set value it will send the sms after every hour that humidity is above the set point but i can still call in between to get humidity and temperature data.

iderealfred:
even without the delay the call part does not work. that one hour delay was actually meant that if the humidty is above the set value it will send the sms after every hour that humidity is above the set point but i can still call in between to get humidity and temperature data.

During the delay(), you can call, but don't expect the Arduino to answer. It's got its head stuck in the sand.

You could record when the humidity was too high, or too low, and set a flag indicating that a message had been sent, when you discover that the humidity is too high or too low. Then, it it is still too high or too low, check to see if it has been more than an hour since you sent the message. If so, send again, and record the new message time. If not, don't send a message. No delay()s needed.

If you change your code, you need to post it again, but put every { on a line BY ITSELF, put every } on a line BY ITSELF, and use Tools + Auto Format before posting the code again.

With your unaligned braces, it is difficult to see the structure of your program.

i have tried without delay() it actually send too many sms when the if condition is true and still it does not acknowledge the call

i have send the code again i dont if i get the alignment of { and } right

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "call.h"
#include <DHT.h>
#include "sms.h"

SMSGSM sms;
#define DHTPIN 7
#define DHTTYPE DHT11

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 = "";
  humidity = dht.readHumidity();
  temperature = dht.readTemperature();
  delay(2000);
  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(2000);

      smsText = "Temperature: " + String(temperature, 1) + "C Humidity: " + String(humidity, 1) + "%";
      smsText.toCharArray(sms_text, 160);
      //Serial.println(smsText);
      sms.SendSMS("+***********", sms_text);
      break;

    case CALL_COMM_LINE_BUSY:  // In this case the call would be established

      Serial.println("TALKING. Line busy.");

      break;
  }
  delay(1000);

  if (humidity >= 90)
{

    smsText = " Humidity above setpoint: " + String(humidity, 1) + "%";
    smsText.toCharArray(sms_text, 160);
    //Serial.println(smsText);
    sms.SendSMS("+***********", sms_text);

   }
  if (humidity <= 80)
 {
    smsText = " Humidity below setpoint: " + String(humidity, 1) + "%";
    smsText.toCharArray(sms_text, 160);
    //Serial.println(smsText);
    sms.SendSMS("+***********", sms_text);


  }
  }

you'd better off go for raw AT commands to get the job done pretty quick

when you dial the number, gsm sends a word 'RING' to the serial buffer of arduino

all you have to do is check if buffer has 'RING' in it then you can call that ' if ( hummidity >= 90 ) ' right away

but you must work on how to deal with raw AT commands, stay away from 'call/sms.h' library and gain yourself some couple of extra ram too

i am still new in programming and in the learning process i will really appreciate if you can alter that code to make it send the data at any time when i call it have really tried but still its giving me problems