GsmWebServer Problems

My apn is wap.gocbw.com and the username is cbw, no password

I can send and receive sms messages but I cannot get the web server to work. I am using the arduino gsm shield with the gsm library. I will provide any information and do any testing you ask to get this problem solved.

Thanks!

BTW I tried to ping once the serial monitor gave the ip address, and it timed out every time. NO response.
I also have another gsm shield with a SIM900 but cannot find any webserver examples anywhere. I am able to send sms messages with that one also.

1 Like

Bump

Bump

BTW I tried to ping once the serial monitor gave the ip address, and it timed out every time. NO response.
I also have another gsm shield with a SIM900 but cannot find any webserver examples anywhere. I am able to send sms messages with that one also.

So what makes you think you can run a web server on a GSM system? What is the IP address of your web server on the GSM system?

The fact that there is a GsmWebServer example code in the GSM library makes me think that I can have a webserver on my arduino by using the GSM shield. The IP address is apparently generated when the arduino runs the code and can be seen by using the serial monitor. It takes a minute to do its thing and then it displays the IP address of the server. I then ping that IP address and get no results. This is by using the arduino GSM shield straight from their store. I also have the other shield but I don't know how to get that working. I can't find any sample code for that.

displays the IP address of the server

Is the IP address in the 192.168.x.x range, or something else?

Thanks for the reply. Sorry, I didn't understand what you were asking. NO, the IP address is certainly not in that range. Give me one minute and I will update with the IP address it generates.

Update: Okay, here is exactly what the serial monitor displays, the server is still running:

Connected to GPRS network
Server IP address=
10.69.162.129

BTW I am using an arduino UNO just in case that becomes relevant at some point.

/*
 GSM Web Server
 
 A simple web server that shows the value of the analog input pins.
 using a GSM shield.

 Circuit:
 * GSM shield attached
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 8 Mar 2012
 by Tom Igoe
 */

// libraries
#include <GSM.h>

// PIN Number
#define PINNUMBER ""

// APN data
#define GPRS_APN       "wap.gocbw.com" // replace your GPRS APN
#define GPRS_LOGIN     "cbw"    // replace with your GPRS login
#define GPRS_PASSWORD  "" // replace with your GPRS password


// initialize the library instance
GPRS gprs;
GSM gsmAccess;     // include a 'true' parameter for debug enabled
GSMServer server(80); // port 80 (http default)

// timeout
const unsigned long __TIMEOUT__ = 10*1000;

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  
  // connection state
  boolean notConnected = true;
  
  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected)
  {
    if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }
  
  Serial.println("Connected to GPRS network");
  
  // start server
  server.begin();
  
  //Get IP.
  IPAddress LocalIP = gprs.getIPAddress();
  Serial.println("Server IP address=");
  Serial.println(LocalIP);
}

void loop() {


  // listen for incoming clients
  GSMClient client = server.available();



  if (client)
  {  
    while (client.connected())
    {
      if (client.available())
      {
        Serial.println("Receiving request!");
        bool sendResponse = false;
        while(char c=client.read()) {
          if (c == '\n') sendResponse = true;
        }

     // if you've gotten to the end of the line (received a newline
     // character) 
       if (sendResponse)
       {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("
");       
          }
          client.println("</html>");
          //necessary delay
          delay(1000);
          client.stop();
        }
      }
    }
  }
}

The 10.69.162.129 appears to be a private LAN IP address of your mobile service provider. Doubtful if you will be able to connect to it from the outside world.

IANA-reserved private IPv4 network ranges
Start End No. of addresses

24-bit block (/8 prefix, 1 × A) 10.0.0.0 10.255.255.255 16777216
20-bit block (/12 prefix, 16 × B) 172.16.0.0 172.31.255.255 1048576
16-bit block (/16 prefix, 256 × C) 192.168.0.0 192.168.255.255 65536

Is there a way that I can find a GSM mobile provider that will allow outside connections?

Bump

A number of network operators do not allow for incoming connections from the public internet, but will allow them from inside their own. Check with your operator to see what restrictions there are on data use.

How can I find a msp that will allow me to have a webserver accessible from the public internet?

Bump

Hello

Arduino 1.0.3
Arduino uno R3
GPRS shield SIMCOM SIM900
Library: GSMSHIELD (GSM.cpp, ...)

I have a problem with set up a webserver. Server attached to GSM network and ping is OK, but I dont know how to configure a server to replay "Hello" or return to client a analoge value. I have no idea any more.

The library in Arduino 1.0.5 for GSM shield (Telefonica -GSMwebServer) is very simple because include command clientprint () similar as Ethernet shield clientprint().
I offer a small prize (paypal) those that solve this problem:
clientprint (value of analog pin) - 1.0.5 with Telefonica Arduino GSM shield === similar to this with SIMCOS SIM900 library ????
I spend hours and hours and I'm stuck in this problem.

best regards
Atkam

#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 server.

InetGSM inet;
//CallGSM call;
//SMSGSM sms;

char msg[50];
int numdata;
char inSerial[50];
int i=0;
boolean started=false;
long lasttime=millis();

void setup() 
{
  //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");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
  
  if(started){
    //GPRS attach, put in order APN, username and password.
    //If no needed auth let them blank.
    if (inet.attachGPRS("internet.t-2.net", "", ""))
      Serial.println("status=ATTACHED");
    else Serial.println("status=ERROR");
    delay(1000);
    
    //Read IP address.
    gsm.SimpleWriteln("AT+CIFSR");
    delay(5000);
        int i=0;
    while(i<20){
      gsm.SimpleRead();
      i++;
    }

    //TCP Server. Start the socket connection
    //as server on the assigned port.
    Serial.println(msg);
    delay(5000);
    if (inet.connectTCPServer(80))
      Serial.println("status=TCPSERVERWAIT");
    else Serial.println("ERROR in Server");
    lasttime=millis();
  }
};


void loop(){
  if(started){
    //Check if there is an active connection.
    if (inet.connectedClient()){
      //Read and print the last message received.
      gsm.read(msg, 50);
      Serial.println(msg);
    }
  }
  else{
    serialhwread();
    serialswread();
  }


  //Read for new byte on serial hardware,
  //and write them on NewSoftSerial.
  serialhwread();
  //Read for new byte on NewSoftSerial.
  serialswread();
};


void serialhwread(){
  i=0;
  if (Serial.available() > 0){            
    while (Serial.available() > 0) {
      inSerial[i]=(Serial.read());
      delay(10);
      i++;      
    }
    
    inSerial[i]='\0';
    if(!strcmp(inSerial,"/END")){
      Serial.println("_");
      inSerial[0]=0x1a;
      inSerial[1]='\0';
      gsm.SimpleWriteln(inSerial);
    }
    //Send a saved AT command using serial port.
    if(!strcmp(inSerial,"TEST")){
      Serial.println("SIGNAL QUALITY");
      gsm.SimpleWriteln("AT+CSQ");
    }
    //Read last message saved.
    if(!strcmp(inSerial,"MSG")){
      Serial.println(msg);
    }
    else{
      Serial.println(inSerial);
      gsm.SimpleWriteln(inSerial);
    }    
    inSerial[0]='\0';
  }
}

void serialswread(){
  gsm.SimpleRead();
}

gprs_server_apn_t_2_basic.ino (2.75 KB)

If you want people to view your code, it is better to post the code using the code tag # in the post tool bar.

thx, I correct

Hello all.

I am offering payments (via paypal) to those that we solve the problem/solution WEB server (UNO+GPRS SIM900) where client connect to WEB server and read a value of analog pin (A0-A5).
Please I need a solution anyone know how to do it?
br
ATkam

hello

I correct a basic code (server SIM900) and now working better but still not as I like. Client connect to the server but problem is how to regular disconect from sending mode (AT+CIPSEND), becouse Ctrl+Z (1a0x) not accept. And server non stop sending "MHE TEST", look code bellow.

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "inetGSM.h"
InetGSM inet;

char msg[50];
int numdata;
char inSerial[50];
int i=0;
boolean started=false;
long lasttime=millis();

void setup() 
{
  //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");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
  
  if(started){
    //GPRS attach, put in order APN, username and password.
    //If no needed auth let them blank.
    if (inet.attachGPRS("internet.xxx.net", "", ""))
      Serial.println("status=ATTACHED");
    else Serial.println("status=ERROR");
    delay(1000);
    
    //Read IP address.
    gsm.SimpleWriteln("AT+CIFSR");
    delay(5000);
        int i=0;
    while(i<20){
      gsm.SimpleRead();
      i++;
    }

    //TCP Server. Start the socket connection
    //as server on the assigned port.
    Serial.println(msg);
    delay(5000);
    if (inet.connectTCPServer(80))
      Serial.println("status=TCPSERVERWAIT");
       else Serial.println("ERROR in Server");
    lasttime=millis();
  }
};


void loop(){
 
  if(started){
    //Check if there is an active connection.
    if (inet.connectedClient()){
      //Read and print the last message received.
      gsm.read(msg, 50);
      Serial.println(msg);
    }
  }
  else{
    serialhwread();
    serialswread();
  }


  //Read for new byte on serial hardware,
  //and write them on NewSoftSerial.
  serialhwread();
  //Read for new byte on NewSoftSerial.
  serialswread();
};


void serialhwread()
{

gsm.SimpleWriteln("AT+CIPATS=1,5");
delay(1000);
gsm.SimpleWriteln("AT+CIPSEND");
delay(1000);
gsm.SimpleWriteln("<!DOCTYPE html><html><body><h1>MHE</h1><p>TEST</p></body></html>");
gsm.SimpleWriteln(A1);
delay(200);
delay(1500);
gsm.SimpleWriteln(0x1a);
delay(500);
gsm.SimpleWriteln('\0');
  i=0;
  if (Serial.available() > 0){            
    while (Serial.available() > 0) {
      inSerial[i]=(Serial.read());
      delay(10);
      i++;      
    }
    
    inSerial[i]='\0';
    if(!strcmp(inSerial,"/END")){
      Serial.println("_");
      inSerial[0]=0x1a;
      inSerial[1]='\0';
      gsm.SimpleWriteln(inSerial);
    }
    //Send a saved AT command using serial port.
    if(!strcmp(inSerial,"TEST")){
      Serial.println("SIGNAL QUALITY");
      gsm.SimpleWriteln("AT+CSQ");
    }
    //Read last message saved.
    if(!strcmp(inSerial,"MSG")){
      Serial.println(msg);
    }
    else{
      Serial.println(inSerial);
      gsm.SimpleWriteln(inSerial);
    }    
    inSerial[0]='\0';
  }
}

void serialswread(){
  gsm.SimpleRead();
}

hello

I have a problem with webserver SIM900:

client > server GET HTTP/1.1 Connection: keep-alive ....

server (SIM900) always response with: HTTP/1.1 200 OK Connection: keep-alive - how to change ??.

Anone know how to save request and parse Connection: keep-alive and change keep-alive with "Connection: close" header.

br
Atkam