Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with arduino uno and sim 900: incoming call and get togeteher in a sketch

Status
Not open for further replies.

Scaurus

Newbie level 2
Joined
Jun 12, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,296
Problem with arduino uno and sim 900: incoming call and get together in a sketch

My goal is to run a "get" after receiving a phone call.
I took as a cue the following sketch that works properly :
Code:
]#include "SIM900.h"
#include <SoftwareSerial.h>
//We don't need the http functions. So we can disable the next line.
//#include "inetGSM.h"
#include "sms.h"
#include "call.h"

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to check if an incoming call is from an authorized
//number and in this case, send to this number an SMS with the value
//of a digital input.

//We have to create the classes for SMSs and calls.
CallGSM call;
SMSGSM sms;

char number[20];
byte stat=0;
int value=0;
int pin=1;
char value_str[5];

void setup() 
{
  pinMode(pin,INPUT);
  //Serial connection.
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(2400))
    Serial.println("\nstatus=READY");
  else Serial.println("\nstatus=IDLE");
};

void loop() 
{
  //Chekcs status of call
  stat=call.CallStatusWithAuth(number,0,0);
  //If the incoming call is from an authorized number
   if(stat==CALL_INCOM_VOICE_AUTH){
    //Hang up the call.
    call.HangUp();
    delay(2000);
    //Check the value of the input.
    value=digitalRead(1);
    //Convert the int to a string.
    itoa(value,value_str,10);
    //Send an SMS to the previous number with
    //the value read previously.
    sms.SendSMS(number,value_str);
  }
  delay(1000);
};

I modified the code to execute the "get" instead of sending a text message(sms).

Code:
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "inetGSM.h"
//#include "sms.h"
#include "call.h"

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to start a connection as client.

InetGSM inet;
CallGSM call;
//SMSGSM sms;

char msg[50];
int numdata;
char inSerial[50];
int i=0;
boolean started=true;
int pin=1;
byte stat=0;
char number[20];


void setup() 
{
  pinMode(pin,INPUT);
  //Serial connection.
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(4800)){
    Serial.println("\nstatus=READY");

  }
  else Serial.println("\nstatus=IDLE");
  
};

void loop() 
{

 stat=call.CallStatusWithAuth(number,0,0);
 //If the incoming call is from an authorized number
  //saved on SIM in the positions range from 1 to 3.
  if(stat==CALL_INCOM_VOICE_AUTH){
  //Hang up the call.
    call.HangUp();
    delay(2000);
    started=true;
              if(started){
                started=false;
//                //GPRS attach, put in order APN, username and password.
//                //If no needed auth let them blank.
               if (inet.attachGPRS("wap.tim.it", "", ""))
                  Serial.println("status=ATTACHED");
                else Serial.println("status=ERROR");
                delay(1000);
//                
//                //Read IP address.
                gsm.SimpleWriteln("AT+CIFSR");
                delay(5000);
//                //Read until serial buffer is empty.
                gsm.WhileSimpleRead();
//              
//                //TCP Client GET, send a GET request to the server and
//                //save the reply.
              numdata=inet.httpGET("www.google.com", 80, "/", msg, 50);
//                //Print the results.
                Serial.println("\nNumber of data received:");
                Serial.println(numdata);  
             
                Serial.println(msg); 
          
              }
  }
  delay(1000);
};

Unfortunately on the serial monitor appear a series of "g".
If I try to comment on the party who is responsible for receiving the call, "get" runs, contrary if I try to comment on
inet.attachGPRS and hence get, the code that takes care of waiting calls is executed.
Is it possible to run both the two activities together, as is the case for the sketch waiting calls and sending text messages.
A help would be invaluable.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top