I'm building a weather station that sends the data to a webserver via GET request.

I was wondering if you guys can look into my code and help me.

I looked all over the internet and can't find what's wrong. I'm using an Arduino mega, an Arduino/Telefonica GSM shield and an EE sim card. Thank you very much!

#include <GSM.h>

GSM gsmAccess;
GPRS gprs;
GSMClient client;

const boolean gprsCheck = true;

char server[] = "";

int value = 112358132134;

void setup(){


  if(gprsCheck) {

    boolean notCon = true;

    Serial.println("Establishing connection...");

    while(notCon) {

      if((gsmAccess.begin("") == GSM_READY) & (gprs.attachGPRS("everywhere","eesecure","secure") == GPRS_READY)) {

        notCon = false;

        Serial.println("GPRS connection successful.");

      else {

        Serial.println("GPRS connection failed. Trying again.");


  if(!client.available() && !client.connected()) {


  if (client.connect(server, 80)) {

    Serial.println("Connection successful.");

    client.print( "GET /add.php?");
    client.print(" HTTP/1.1\n");
    client.print("Host: ");
    client.print("\nConnection: close\n\n");

    Serial.println("Data sent.");

  else {


void loop() {
  • You never said what is happening that is wrong. Please describe the actual problem and also include the serial output. – Jake C Aug 5 '15 at 16:15
  • It does not work as I wanted. I want it to run the url just like a brower would do (i got this from arduino.cc: A typical web request looks like "GET pathname HTTP/1.0". print will send the message, just as a browser would.) And when i type on a browser the url i want the arduino to perform, it works just fine. There's no error message. – Rodrigo Sasse Aug 5 '15 at 16:31
  • Either you have implemented this incorrectly, your server is not reachable from your mobile provider, or your GSM device is not in communication with its mobile network, or your arduino is not in communication with your GSM device. Think about other tests you can run to identify which sort of issue you have. – Chris Stratton Aug 5 '15 at 16:40
  • I say this because you think the code is fine? – Rodrigo Sasse Aug 5 '15 at 16:50
  • int value = 112358132134; - the largest number an int can hold is 32767. Why are you calling client.stop(); twice? – Nick Gammon Aug 5 '15 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.