user41035: I am trying to send data to a php file via http GET method.
I am able to send static data but I am unable to send dynamic data.
#include <SoftwareSerial.h>
SoftwareSerial gprsSerial(9, 10);

char inchar;
int ledPin = 13;
int sensorPin = A0;
int sensorValue = 0;

boolean gs = true;
boolean es = true;
boolean ss = false;

void setup()
{
  gprsSerial.begin(9600);
  gprsSerial.println("AT+CNMI = 2,2,0,0");
  Serial.begin(9600);
}
void loop()
{
   currentMillis = millis();
   if(gprsSerial.available()>0)
  {
    inchar = gprsSerial.read();
    if (inchar == '#')
    {
      delay(10);
      inchar = gprsSerial.read();
      if (inchar == '1')
      {
        Serial.println("System Enabled");
        ss = true;
        snd_msg(0);
      }
      else if (inchar == '0')
      {
        Serial.println("System Disabled");
        ss = false;
        snd_msg(1);        
      }
      delay(10);
      inchar = gprsSerial.read();
      if (inchar == '1')
      {
        Serial.println("Geofence Enabled");
        gs = true;
        snd_msg(2);        
      }
      else if (inchar == '0')
      {
        Serial.println("Geofence Disabled");
        gs = false;
        snd_msg(3);        
      }
      delay(10);
    }
  }
    gprs();
    delay(10000);
}

void toSerial()
{
  while(gprsSerial.available()!=0)
  {
    Serial.write(gprsSerial.read());
  }
}
 void snd_msg(int a)
{
  gprsSerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  gprsSerial.println("AT+CMGS=\"+918148090646\"\r"); // Replace x with mobile number
  delay(1000);
  if ( a == 0)
  {
    gprsSerial.println("System Enabled");
  }
  else if ( a == 1)
  {
    gprsSerial.println("System Disabled");
  }
  else if ( a == 2)
  {
    gprsSerial.println("Geofence Enabled");
  }
  else if ( a == 3)
  {
    gprsSerial.println("Geofence Disabled");
  }     
  delay(100);
   gprsSerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
  gprsSerial.println("AT+CNMI = 2,2,0,0");
  delay(1000);
}
void vibra_sensor()
{
  sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);
  for(int i = 0; i < 5; i++)
  {
  if (sensorValue > 500)
  {
    es = true;
    break;
  }
  else
    es = false;
  delay(500);
  }  
  delay(1000);
}
void gprs()
{
  vibra_sensor();
  Serial.println("Config SIM900...");
  delay(2000);
  Serial.println("Done!...");
  gprsSerial.flush();
  Serial.flush();

  // attach or detach from GPRS service 
  gprsSerial.println("AT+CGATT?");
  delay(100);
  toSerial();


  // bearer settings
  gprsSerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
  delay(2000);
  toSerial();

  // bearer settings
  gprsSerial.println("AT+SAPBR=3,1,\"APN\",\"www\"");
  delay(2000);
  toSerial();

  // bearer settings
  gprsSerial.println("AT+SAPBR=1,1");
  delay(2000);
  toSerial();
  // initialize http service
  gprsSerial.println("AT+HTTPINIT");
   delay(6000); 
   toSerial();

   // set http param value 
 **gprsSerial.println("AT+HTTPPARA=\"URL\",\"adnansait74.000webhostapp.com/operation.php?timestamp=02:50:00&latitude=11.374545&longitude=76.728986&gfence=OFF&estatus=OFF&sstatus=ON\"");**
   delay(5000);
   toSerial();

   // set http action type 0 = GET, 1 = POST, 2 = HEAD
   gprsSerial.println("AT+HTTPACTION=0");
   delay(6000);
   toSerial();

   // read server response
   gprsSerial.println("AT+HTTPREAD"); 
   delay(1000);
   toSerial();

   gprsSerial.println("");
   gprsSerial.println("AT+HTTPTERM");
   toSerial();
   delay(300);

   gprsSerial.println("");
   delay(10000);
   gprsSerial.println("AT+CNMI = 2,2,0,0");
  delay(1000);
}

What I've Tried
1.) Saving URL in a string
String URL = "adnansait74.000webhostapp.com/operation.php?timestamp=02:50:00&latitude=11.374545&longitude=76.728986&gfence=OFF&estatus=OFF&sstatus=";
    URL += ss;
    gprsSerial.println("AT+HTTPPARA=\"URL\",\"+URL\"");

Doesn't Work
2.)Attaching values using print statement
gprsSerial.println("AT+HTTPPARA=\"URL\",\"adnansait74.000webhostapp.com/operation.php?timestamp=02:50:00&latitude=11.374545&longitude=76.728986&gfence=OFF&estatus=OFF&sstatus=");
gprsSerial.println(ss+"\"");

3.)Entering value directly in URL
gprsSerial.println("AT+HTTPPARA=\"URL\",\"adnansait74.000webhostapp.com/operation.php?timestamp=02:50:00&latitude=11.374545&longitude=76.728986&gfence=OFF&estatus=OFF&sstatus="+ss+"\");

Error
invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'

I'm using an arduino uno and a sim 900a GSM module.
QUESTION
How do I send dynamic values for gfence, sstatus, estatus?
I am also using a messaging service, the code is included. The help I need is in the gprs() function.
The data I need to send is,
gfence from gs 
sstatus from ss 
estatus from es

user4143: You should split it up:
gprsSerial.print(F("AT+HTTPPARA=\"URL\",\"adnansait74.000webhostapp.com/operation.php?timestamp=02:50:00&latitude=11.374545&longitude=76.728986&gfence=OFF&estatus=OFF&sstatus="));
gprsSerial.print(ss);
gprsSerial.println(F("\""));

Note the use of print on each part up until the last part which is the only one that uses println in order to terminate the line.
Also note the use of the F() macro to reduce the wastage of RAM that string constants cause.

41035: <p>I am trying to send data to a php file via http GET method.</p>

<p>I am able to send static data but I am unable to send dynamic data.</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;
SoftwareSerial gprsSerial(9, 10);

char inchar;
int ledPin = 13;
int sensorPin = A0;
int sensorValue = 0;

boolean gs = true;
boolean es = true;
boolean ss = false;

void setup()
{
  gprsSerial.begin(9600);
  gprsSerial.println("AT+CNMI = 2,2,0,0");
  Serial.begin(9600);
}
void loop()
{
   currentMillis = millis();
   if(gprsSerial.available()&gt;0)
  {
    inchar = gprsSerial.read();
    if (inchar == '#')
    {
      delay(10);
      inchar = gprsSerial.read();
      if (inchar == '1')
      {
        Serial.println("System Enabled");
        ss = true;
        snd_msg(0);
      }
      else if (inchar == '0')
      {
        Serial.println("System Disabled");
        ss = false;
        snd_msg(1);        
      }
      delay(10);
      inchar = gprsSerial.read();
      if (inchar == '1')
      {
        Serial.println("Geofence Enabled");
        gs = true;
        snd_msg(2);        
      }
      else if (inchar == '0')
      {
        Serial.println("Geofence Disabled");
        gs = false;
        snd_msg(3);        
      }
      delay(10);
    }
  }
    gprs();
    delay(10000);
}

void toSerial()
{
  while(gprsSerial.available()!=0)
  {
    Serial.write(gprsSerial.read());
  }
}
 void snd_msg(int a)
{
  gprsSerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  gprsSerial.println("AT+CMGS=\"+918148090646\"\r"); // Replace x with mobile number
  delay(1000);
  if ( a == 0)
  {
    gprsSerial.println("System Enabled");
  }
  else if ( a == 1)
  {
    gprsSerial.println("System Disabled");
  }
  else if ( a == 2)
  {
    gprsSerial.println("Geofence Enabled");
  }
  else if ( a == 3)
  {
    gprsSerial.println("Geofence Disabled");
  }     
  delay(100);
   gprsSerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
  gprsSerial.println("AT+CNMI = 2,2,0,0");
  delay(1000);
}
void vibra_sensor()
{
  sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);
  for(int i = 0; i &lt; 5; i++)
  {
  if (sensorValue &gt; 500)
  {
    es = true;
    break;
  }
  else
    es = false;
  delay(500);
  }  
  delay(1000);
}
void gprs()
{
  vibra_sensor();
  Serial.println("Config SIM900...");
  delay(2000);
  Serial.println("Done!...");
  gprsSerial.flush();
  Serial.flush();

  // attach or detach from GPRS service 
  gprsSerial.println("AT+CGATT?");
  delay(100);
  toSerial();


  // bearer settings
  gprsSerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
  delay(2000);
  toSerial();

  // bearer settings
  gprsSerial.println("AT+SAPBR=3,1,\"APN\",\"www\"");
  delay(2000);
  toSerial();

  // bearer settings
  gprsSerial.println("AT+SAPBR=1,1");
  delay(2000);
  toSerial();
  // initialize http service
  gprsSerial.println("AT+HTTPINIT");
   delay(6000); 
   toSerial();

   // set http param value 
 **gprsSerial.println("AT+HTTPPARA=\"URL\",\"adnansait74.000webhostapp.com/operation.php?timestamp=02:50:00&amp;latitude=11.374545&amp;longitude=76.728986&amp;gfence=OFF&amp;estatus=OFF&amp;sstatus=ON\"");**
   delay(5000);
   toSerial();

   // set http action type 0 = GET, 1 = POST, 2 = HEAD
   gprsSerial.println("AT+HTTPACTION=0");
   delay(6000);
   toSerial();

   // read server response
   gprsSerial.println("AT+HTTPREAD"); 
   delay(1000);
   toSerial();

   gprsSerial.println("");
   gprsSerial.println("AT+HTTPTERM");
   toSerial();
   delay(300);

   gprsSerial.println("");
   delay(10000);
   gprsSerial.println("AT+CNMI = 2,2,0,0");
  delay(1000);
}
</code></pre>

<p><strong>What I've Tried</strong></p>

<p>1.) Saving URL in a string</p>

<pre><code>String URL = "adnansait74.000webhostapp.com/operation.php?timestamp=02:50:00&amp;latitude=11.374545&amp;longitude=76.728986&amp;gfence=OFF&amp;estatus=OFF&amp;sstatus=";
    URL += ss;
    gprsSerial.println("AT+HTTPPARA=\"URL\",\"+URL\"");
</code></pre>

<p>Doesn't Work</p>

<p>2.)Attaching values using print statement</p>

<pre><code>gprsSerial.println("AT+HTTPPARA=\"URL\",\"adnansait74.000webhostapp.com/operation.php?timestamp=02:50:00&amp;latitude=11.374545&amp;longitude=76.728986&amp;gfence=OFF&amp;estatus=OFF&amp;sstatus=");
gprsSerial.println(ss+"\"");
</code></pre>

<p>3.)Entering value directly in URL</p>

<pre><code>gprsSerial.println("AT+HTTPPARA=\"URL\",\"adnansait74.000webhostapp.com/operation.php?timestamp=02:50:00&amp;latitude=11.374545&amp;longitude=76.728986&amp;gfence=OFF&amp;estatus=OFF&amp;sstatus="+ss+"\");
</code></pre>

<p><strong>Error</strong></p>

<pre><code>invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'
</code></pre>

<p>I'm using an arduino uno and a sim 900a GSM module.</p>

<p><strong>QUESTION</strong></p>

<p>How do I send dynamic values for <strong>gfence, sstatus, estatus</strong>?</p>

<p>I am also using a messaging service, the code is included. <strong>The help I need is in the gprs() function.</strong></p>

<p>The data I need to send is,</p>

<p>gfence from gs </p>

<p>sstatus from ss </p>

<p>estatus from es</p>
 4143: <p>You should split it up:</p>

<pre><code>gprsSerial.print(F("AT+HTTPPARA=\"URL\",\"adnansait74.000webhostapp.com/operation.php?timestamp=02:50:00&amp;latitude=11.374545&amp;longitude=76.728986&amp;gfence=OFF&amp;estatus=OFF&amp;sstatus="));
gprsSerial.print(ss);
gprsSerial.println(F("\""));
</code></pre>

<p>Note the use of <code>print</code> on each part up until the <em>last</em> part which is the only one that uses <code>println</code> in order to terminate the line.</p>

<p>Also note the use of the <code>F()</code> macro to reduce the wastage of RAM that string constants cause.</p>
