Browsed by
Category: Arduino

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 :

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.