2

I am using Arduino UNO R3 micro controller and GSM-900a SIM module. I want to activate the data connection of the SIM card and and want to send some data to a specific server or hit a specific .php file which is uploaded in the server. I have tried this code but unable to send data in the server. But I Have tested SMS, which is working but data connection based work is doing nothing. besides no exception is showing in case of misinterpretation. I have done this block of code.

#include <avr/io.h>
#include <avr/interrupt.h>
#include <SoftwareSerial.h>

SoftwareSerial GPS(12,13); //RX,TX
SoftwareSerial GSMM(10,11); //RX,TX

#define SIZE 64

//volatile word seconds = 0;
//byte state = 1;
//long lati = 0;
//long longi = 0;
//long lati_temp;
//long longi_temp;

//const unsigned char UBX_HEADER[] = { 0xB5, 0x62 };
unsigned char buffer[SIZE]= ""; 
int count=0;




void setup() 
{
  Serial.begin(9600);
  delay(500);
  GSMM.begin(9600);
  delay(20000);
  delay(20000);
  delay(20000);
}

void gsm_read()
{
  if (GSMM.available()){         // if date is comming from softwareserial port ==> data is comming from gprs shield
      while(GSMM.available()){          // reading data into char array 
        buffer[count++]=GSMM.read();     // writing data into array
        if(count == SIZE)break;
      }
  Serial.write(buffer,count);            // if no data transmission ends, write buffer to hardware serial port

  count = 0;
  }  
}
void SendData(String a,String b)
{

  GSMM.println("AT");
  delay(1000);
  GSMM.println("AT+CREG?");
  delay(1000);
  GSMM.println("AT+SAPBR=1,1");
  delay(2000);
  GSMM.println("AT+SAPBR=2,1");
  delay(2000);
  GSMM.println("AT+HTTPINIT");
  delay(1000);
  GSMM.println("AT+HTTPPARA=\"URL\",\"ehealthmonitor.comli.com/pritam.php?lat=20.0&lon=55.66\"");
  delay(1000);
  GSMM.println("AT+HTTPPARA=\"CID\",1[[|]]");
  delay(1000);
  GSMM.println("AT+HTTPACTION=0");
  delay(10000);
  GSMM.println("AT+HTTPREAD");
  delay(300);
  GSMM.println("AT+HTTPTERM");
  delay(1000); 
}

void loop() {

  Serial.println("Sending");
      SendData("a","b");  
      delay (5000);
      count=0;
      Serial.println("Sent");
}
Ananda G
  • 2,389
  • 23
  • 39
  • 1
    Do not expect any meaningful answer if you don't provide details about your problem. For example, to you get responses from the AT commands? What are those for each command you send? What kind of other debugging have you tried? – Fotis Panagiotopoulos Apr 16 '16 at 19:06
  • 1
    Also keep in mind that this is not the complete sequence of commands needed. For example you do not setup the PIN, or the APN username/password etc. – Fotis Panagiotopoulos Apr 16 '16 at 19:07
  • Ya. I have tried both putty and Arduino. It's working fine in putty. AT command is perfectly working in command line interface. but not working in Arduino – Ananda G Apr 16 '16 at 19:20
  • Again. Provide details. What does the modem respond to each command while communicating with the Arduino? – Fotis Panagiotopoulos Apr 16 '16 at 19:28
  • You haven't set APN , so connection wont be made! Further more you need to tell us What is the response for each response. I would recommend using an arduino gsm libarary. – dmSherazi Apr 18 '16 at 16:05

0 Answers0