Arduino and GSM module SIM900A. How to flash and use?

In this article, I will talk about working with the GSM-module SIM900A. With it, you can make automated calls and send messages in the same way. Also, it supports the GPRS protocol.

Thanks to this module, it is convenient to manage your devices remotely, via messages or the Internet using GPRS (the speed will be low, but there is no dependence on the Wi-Fi network).

Some may get a SIM900A module for the Asian region. Accordingly, it will not work on our frequencies. But it's not a problem. Just to use the module you will need to reflash it. If your module works with the necessary frequencies - you can skip the next part.

So, to work with the module, we need:
  • SIM900A Mini V 4.0 module
  • CP2102 to USB-UART TTL Converter
  • 400-point breadboard
  • Jumper wires kit

Before the start of the firmware, we will prepare the necessary software. To do this, you need a program called SIM900 Series download Tools Develop, a firmware file and a serial port monitor - I used a program with a lot of Terminal functionality, but we download everything since both of us will need to configure it.

DOWNLOAD SIM900 DOWNLOAD TOOLS 1.9

DOWNLOAD TERMINAL 1.9 B

After installing Terminal, we connect the SIM900A module to the computer using a USB-UART converter. I used the converter CP2102.

WIRING DIAGRAM FOR CP2102

SIM900 CP2102
Gnd Gnd
VCC_MCU +5V power
SIMR TX
SIMT RX
VCC5 +5V (external power supply)
Gnd Gnd (external power supply)

An external power supply must be connected to the module since, in theory, it can consume up to 2 A, which the converter cannot provide. The CP2102 does not have a restart pin, and the SIM900A does not have a button for this.

If your converter also does not have a reset pin, then for the firmware you will have to connect the RST GSM module with the ground, and before that leave it unconnected. Or connect it with the derived reset pin on the USB-UART converter.

Now we will configure SIM900A. By default, it runs at 9600 baud / s. The firmware at this speed takes about 55 minutes. We specify in Terminal the speed and port number, the end of the line should be “CR”. Connect to the device.

SETTING SIM900A
The module is fully controlled by AT commands. Let's start with the simplest one by sending the message “AT” to the module. He should answer "OK". Now we change the speed of work with the command “AT + IPR = 115200”. Must do the same answer. Now the firmware should take a little more than six minutes.

It remains to configure the program SIM900 Series download Tools Develop. Open it.

In the "Target" field, select the desired module, I indicated "SIM900", because it was not possible to flash the module as "SIM900A". Select the port number, the speed indicates 115200 baud / s. In the field “Core File” we write the name of the firmware file, it has the extension “.cla”.

Setup is over!

SIM900A FIRMWARE
We start the firmware. In a strict sequence, repeat the following steps:

We supply power to the device;
We connect it to the computer through the converter;
Connect RST with the ground;
Open the SIM900 Series download Tools Develop and click on “Start Download”;
We wait three seconds and disconnect the RST;
We are waiting for the end of the firmware.
Done! Now SIM900A works at local frequencies. But that's not all. We installed the extended (“All-in-One”) firmware and now the module can determine its location, detect signal jammers (jammers), work with e-mail, play audio records stored in memory, and more.

It can also use 2.5 megabytes of user memory.

We proceed to work with the module.

Enter the PIN code with the command “AT + CPIN = XXXX”. If not, skip this step. We get the following answer "+ CPIN: READY.".

You can get the following information from the module:

AT+GMR firmware version
AT+GSN IMEI
AT+CPAS device status (0 - command waiting, 2 - unknown, 3 - incoming call, 4 - conversation)
AT+COPS? mobile operator

Now we will try to call SIM900. Sent to UART ATD + 7XXXXXXXXXXX; . Do not forget the semicolon at the end of the command.

When an incoming call is connected to the computer, the module will send a RING message to the serial port.

The ATA command allows you to pick up the phone. With a headset, you can talk like a mobile phone.

The ATH0 command allows you to reset the call.

Check the sending messages. Turn on SMS mode by sending AT + CMGF = 1. Change coding with AT + CSCS = “GSM”. Now the phone number is indicated by numbers and messages are typed in ASCII.

Set the destination number AT + CMGS = "+ 7XXXXXXXXXXX". Line feed should be designated by a combination of characters CR + LF. Specify it in the terminal, or manually append to the & 0D & 0A command (the numbers of these two ASCII characters). In response, we get the symbol>, now you can type the text.

We type any message, for example, the standard Hello, World !. The end of the set denotes the 26th character from the ASCII table - $ 1A or # 026. Add it to the post. To cancel typing you need the 27th character - $ 1B or # 027.

If a message arrives at the module, a + CMTI message will be sent to the serial port: “SM”, 3.

3 - the sequence number of the unread message. You can see it by sending it to the serial port AT + CMGR = 3. The following answer will come:

+ CMGR: “REC READ”, ”+ 7XXXXXXXXXX”, ””, ”17/07 / 23.22: 00: 12 + 24 ″

Message text

OK.

The SIM900 can manage its GPIO ports by itself, but in most cases, they are not shared on the board and the module has to be used in conjunction with a microcontroller.

Use the Arduino UNO or Nano. Data exchange between Arduino occurs via the serial port.

The wiring diagram is as follows:

SIM 900 Arduino UNO
Gnd Gnd
VCC_MCU +5V
SIMT RX (0 digital)
SIMR TX (1 digital)

 

Now let's load a sketch into Arduino, which, when receiving a message, will turn on the embedded 13-pin LED for 2 seconds.

const String spin = "1234";
const int rel_pin = 13;
String ss = "";

void sendPin(){
String cmd = "AT+CPIN="+spin+char(0x0D);
Serial.print(cmd);
}

void receiveSMS(String s){
digitalWrite(rel_pin, HIGH);
delay(2000);
digitalWrite(rel_pin, LOW);
}

void parseString(String src){
bool collect = false;
String s = "";
for( byte i=0; i<src.length(); i++ ){
if( src[i] == '+' ){
collect = true;
}
else if( src[i] == ':' ){
if( s == "CMTI" )
receiveSMS(s.substring(i+1));
collect = false;
}
else if(collect){
s += src[i];
}
}
}

void receiveString(){
static byte b;
if( Serial.available() ){
b = Serial.read();
if( b == 0x0D ){
parseString(ss);
ss = "";
}
else{
ss += char(b);
}
}
}

void setup() {
pinMode(rel_pin, OUTPUT);
delay(4000);
Serial.begin(115200);
delay(500);
sendPin();
delay(1000);
}

void loop() {
receiveString();
}

This sketch will simulate a remote control of a device. By slightly changing it, it will be possible to turn on, for example, a relay, and control lighting or other electrical appliances.

Leave a comment

Name .
.
Message .

Please note, comments must be approved before they are published