Make HTTP requests from SIM300 GSM module

Make HTTP requests from SIM300 GSM module

SIM300 is a GSM module by Simcom.

And believe me it’s no less than a piece of shit. I was unlucky enough to have my hands on it. I spent 3-4 days figuring out and testing the correct sequence of AT commands that must be used to make HTTP request via this module. In the following post I’m going to explain how to use it with the Arduino to send and receive data to a web server over HTTP.

Let’s start with the code :

Fist we need to create an object of the SoftwareSerial class. Let’s call it GPRS. The object must be created at the start of the program. The code for this is :

The SoftwareSerial library ships as a default library with the Arduino IDE. Here, 2 and 3 are the pin numbers on the Arduino board where we need to connect our GSM module. Here pin 2 is being used as the Rx pin and pin 3 is being used as the Tx pin. Rx of Arduino should be connected with the Tx of the module and Tx of Arduino with the Rx of the GSM module. The line GPRS.begin(9600) initialises the serial communication with the module with setting a baud rate of 9600. This is the default baud rate for SIM300. The line Serial.begin(9600) initialises the Arduino’s default hardware Serial communication. The Rx and Tx of this default Serial are at pins 0 and 1 of the Arduino. The output that you see in the Serial monitor is also via this default hardware Serial communication.

Upto this point we have done our initialisation part.

Let’s setup our HTTP request with the following code. I’ve provided comments at each line to tell what it does.

Upto this point we’ve initialized our connection to the web server. The following code makes the actual HTTP request.

In the above post you’ll have to change the domain name and put the domain name of your server. Update the line yourphpfile.php?key=value as per your needs. You can add extra parameters if you want.

You can browse the whole code on my Github : https://github.com/omerjerk/Netra/blob/master/sketch_apr19a.ino

And at last I would say if you’ve a choice then better go for SIM900 GSM Module. SIM900 is way better and more reliable than SIM300.

4 thoughts on “Make HTTP requests from SIM300 GSM module

  1. @Haris
    If you’re using the same GSM module, then just use the commands mentioned in the code and in the same sequence.
    Revert to me at which command your implementation is going wrong.

    Thanks.

  2. #include

    SoftwareSerial mySerial(5,6);
    int val;
    int tempPin = 1;

    void setup()
    {
    Serial.begin(9600);
    mySerial.begin(9600);
    delay(2000);
    }
    void loop()
    {

    val = analogRead(tempPin);
    float mv = ( val/1024.0)*5000;
    float cel = mv/10;
    float farh = (cel*9)/5 + 32;

    delay(100);
    mySerial.println(“AT”);
    // set the SMS mode to text
    delay(1000);
    mySerial.println(“AT+CGATT=1”);//
    delay(1000);
    mySerial.print(“AT+CSTT=”);
    mySerial.write(34);
    mySerial.print(“airtelgprs.com”);
    mySerial.write(34);
    mySerial.write(13);
    mySerial.write(10);
    delay(1000);
    mySerial.println(“AT+CIICR”);
    delay(4000);
    mySerial.print(“AT+CIPSTART=”);
    mySerial.write(34);
    mySerial.print(“TCP”);
    mySerial.write(34);
    mySerial.print(“,”);
    mySerial.write(34);
    mySerial.print(“117.203.55.209”);
    mySerial.write(34);
    mySerial.print(“,”);
    mySerial.write(34);
    mySerial.print(“80”);
    mySerial.write(34);
    mySerial.write(13);
    mySerial.write(10);
    delay(3000);
    mySerial.println(“AT+CIPSEND”);
    delay(1000);
    mySerial.print(“get /receive.php?value0=”); //9876543210987″);
    //mySerial.print(“TEMPRATURE = “);
    mySerial.print(cel);
    // Serial.print(“*C”);
    // Serial.println();

    mySerial.write(13);
    mySerial.write(10);
    mySerial.write(26);
    while(1);
    }

    Hello there,
    Im doing a project which is like it uses the temparature sensor to sense temparature and send data(temparature) and the data need to be sent to an online storage unit like a wamp server where in we could access the data. The whole process is to be done using arduino and along with gsm module sim 300!
    The sim i’m using is idea and the above code i have mentioned has a line like “”airtelgprs.com””. Do i need to change it to idea settings and what that might be ?
    Could you help me out if possible!!
    Thanks in advance.

  3. airtelgprs.com is the name of access point in case of Airtel.
    You need to change that to the access point provided by your career.
    A quick Google search reveals that, in case of Idea, it should be set to “internet”.

Leave a Reply

Your email address will not be published. Required fields are marked *