GPRS shield with AT Commands for SIM900

Hi all....

I am working on a GPRS shield from seeedstudio and it can be found here http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0 with the following AT Command library http://garden.seeedstudio.com/images/a/a8/SIM900_AT_Command_Manual_V1.03.pdf.

The library has a AT command that allows for the system to process DTMF codes. My problem is that I do not know how to integrate it in a program.. I have a simple program that allows me to make a phone call...The program will read the serial window and wait for an input. Entering 'd' will execute the program and dial a phone number set in there.... I get it to connect, but all I hear on the dialed phone (I dialed my own phone and picked it up too) is echo... I don't know if it was because I used earphones, that have a speaker integrated, and a microphone... All are plugged in a 3.5mm inputs.

#include <SoftwareSerial.h>
#include <String.h>
 
SoftwareSerial mySerial(7, 8);
 
void setup()
{
  mySerial.begin(19200);               // the GPRS baud rate   
  Serial.begin(19200);    // the GPRS baud rate 
  delay(500);
}
 
void loop()
{
  //after start up the program, you can using terminal to connect the serial of gprs shield,
  //if input 'd' in the terminal, it will execute DialVoiceCall(), etc.
 
  if (Serial.available())
    switch(Serial.read())
   {
     
     case 'd':
       DialVoiceCall();
       break;
   } 
  if (mySerial.available())
    Serial.write(mySerial.read());
}
 
 
///DialVoiceCall
///this function is to dial a voice call
void DialVoiceCall()
{
  mySerial.println("ATD + +86138xxxxx615;");//dial the number
  delay(100);
  mySerial.println();
}

If anyone is familiar with the AT library for this device, can you help me out with the DTMF function and if there is an AT command that will inform the arduino that the connection has been made....

Thank you,
Yesenia

Hi, look at the AT+VTS and AT+VTD commands in your manual. They are used to generate a tone. The status of the call can be inquired with the AT+CLCC command, it may generate a long response message where you should check for the state (third parameter).

check this sample code. I have modified a bit but you may get what you are actually looking for.
Best of luck...

#include <SoftwareSerial.h>
 

// EN: String buffer for the GPRS shield message
String msg = String("");
// EN: Set to 1 when the next GPRS shield message will contains the SMS message
int SmsContentFlag = 0;
//control pins of relay.
int relay_a=4;
int relay_b=5;
int relay_c=6;
int relay_d=7;
int led = 13; // Interrupt monitor
int door = 12; // Door Status monitor
int button=2; // Door Sensor monitor

 // Interrupt Service Routine (ISR)
void doormonitor ()
{
  if (digitalRead (12) == HIGH && digitalRead (2)==HIGH )
   digitalWrite (led, HIGH);
  else
    digitalWrite (led, LOW);
}  // end of pinChange
void setup()
{
  Serial.begin(19200);                 // the GPRS baud rate
  // Initialize  PINs
  pinMode( 4, OUTPUT ); 
  pinMode( 5, OUTPUT ); 
  pinMode( 6, OUTPUT ); 
  pinMode( 7, OUTPUT ); 
  digitalWrite( 4, HIGH ); 
  digitalWrite( 5, LOW ); 
  digitalWrite( 6, LOW );
  digitalWrite( 7, LOW );
  Serial.println( "AT+CMGF=1" ); 
 delay(2000);
 Serial.print( "AT+CMGDA=" ); 
Serial.write(34);
Serial.print("DEL ALL");
Serial.write(34);
Serial.write(13);
Serial.write(10);
delay(6000);
Serial.println( "Let's Test..." ); 
 pinMode(13, OUTPUT); // Interrupt monitor
 pinMode(12, INPUT); // Door status monitor
 pinMode(2, INPUT); //Door sensor monitor
 digitalWrite (2, LOW);  // internal pull-up resistor
 attachInterrupt(0, doormonitor, RISING); //Interrupt 0 is Digital Pin 2
  //When the Input goes from High to Low it will trigger a function called "doormonitor"
}
 
void loop()
{
  char SerialInByte;
    if(Serial.available())
    {       
        SerialInByte = (unsigned char)Serial.read();
       delay(5);
        
        // -------------------------------------------------------------------
        // EN: Program also listen to the GPRS shield message.
        // -------------------------------------------------------------------
       // EN: If the message ends with <CR> then process the message
        if( SerialInByte == 13 ){
          // EN: Store the char into the message buffer
          ProcessGprsMsg();
         }
         if( SerialInByte == 10 ){
            // EN: Skip Line feed
         }
         else {
           // EN: store the current character in the message string buffer
           msg += String(SerialInByte);
         }
     }   
}
// EN: Make action based on the content of the SMS. 
//     Notice than SMS content is the result of the processing of several GPRS shield messages.
void ProcessSms( String sms ){
  
  if( sms.indexOf("ona") >= 0 ){
    digitalWrite( relay_a, LOW );
  }
   if( sms.indexOf("onb") >= 0 ){
    digitalWrite(  relay_b, HIGH );
  }
   if( sms.indexOf("onc") >= 0 ){
    digitalWrite(  relay_c, HIGH );
  }
  if( sms.indexOf("ond") >= 0 ){
    digitalWrite(  relay_d, HIGH );
  }
  if( sms.indexOf("offa") >= 0 ){
    digitalWrite(  relay_a, LOW );
  }
  if( sms.indexOf("offb") >= 0 ){
    digitalWrite(  relay_b, LOW );
  }
  if( sms.indexOf("offc") >= 0 ){
    digitalWrite(  relay_c, LOW );
  }
  if( sms.indexOf("offd") >= 0 ){
    digitalWrite(  relay_d, LOW );
  }
}
// EN: Request Text Mode for SMS messaging
void GprsTextModeSMS(){
  Serial.println( "AT+CMGF=1" );
}

void GprsReadSmsStore( String SmsStorePos ){
  Serial.print( "AT+CMGR=" );
  Serial.println( SmsStorePos );
}

// EN: Clear the GPRS shield message buffer
void ClearGprsMsg(){
  msg = "";
}

// EN: interpret the GPRS shield message and act appropiately
void ProcessGprsMsg() {
  if( msg.indexOf( "Call Ready" ) >= 0 ){
   //  Serial.println( "*** GPRS Shield registered on Mobile Network ***" );
     GprsTextModeSMS();
  }
  
  // EN: unsolicited message received when getting a SMS message
  if( msg.indexOf( "+CMTI" ) >= 0 ){
   //  Serial.println( "*** SMS Received ***" );
     // EN: Look for the coma in the full message (+CMTI: "SM",6)
     //     In the sample, the SMS is stored at position 6
     int iPos = msg.indexOf( "," );
     String SmsStorePos = msg.substring( iPos+1 );
   //  Serial.print( "SMS stored at " );
  //   Serial.println( SmsStorePos );     
     // EN: Ask to read the SMS store
     GprsReadSmsStore( SmsStorePos );
  }
  
  // EN: SMS store readed through UART (result of GprsReadSmsStore request)  
  if( msg.indexOf( "+CMGR:" ) >= 0 ){
    // EN: Next message will contains the BODY of SMS
    SmsContentFlag = 1;
    // EN: Following lines are essentiel to not clear the flag!
    ClearGprsMsg();
    return;
  }
  
  // EN: +CMGR message just before indicate that the following GRPS Shield message 
  //     (this message) will contains the SMS body 
  if( SmsContentFlag == 1 ){
 //   Serial.println( "*** SMS MESSAGE CONTENT ***" );
 //   Serial.println( msg );
 //   Serial.println( "*** END OF SMS MESSAGE ***" );
    ProcessSms( msg );
  }
  
  ClearGprsMsg();
  // EN: Always clear the flag
  SmsContentFlag = 0; 
}

Thank you for the fast response!!! I will definitely try the code provided and look into the functions provided by you guys!!! Hopefully I will be able to eliminate an entire component of my prototype....

Thanks again,
Yesenia

Glad to help you...

"Sharing is caring"

hello, I too come to acquire a shield sim900 (Seeedstudio) and I love that hen I send an sms with my laptop card activates an LED or a motor that is connected to an input or output of the map .. But being a novice I can not design my program. I saw that it was necessary to use specific AT commands for this shield: GoGprs/GoGprs.h at master · mchobby/GoGprs · GitHub
but I do not know if I should contact the arduino software or if I need to download another software .. If you had a program outline that could be useful to me thank you very much friends