GSM SIM900A module. Firmware and use. Connecting GSM SIM900A to Arduino

The experience of using SIM900, described below will be more useful for those who have already managed to work a little with the module. For the same readers who are just starting studying this chip and plans to use it to exchange data via the Internet, we have prepared a series of lessons on this topic. Here.

So, the SIM900 - SIM COM GSM module is managed by AT commands, can send SMS, make calls, organize a direct CSD connection, exchange information on GPRS.

In my hands, the SIM900 GPRS SHIELD was ordered from China - compatible with the Arduino platform.

On the board there is a SIM900 chip, the connectors for the microphone and headphones, the power supply switch (from the external connector or from Arduino), an antenna, several LEDs to indicate the operating modes, the battery connector (if you need a real-time clock), the on / off button. Good description I found a manufacturer on Wiki . There is also a code for managing a modem in various modes.

As the manufacturer declares us, the board is great compatible with Arduino Uno. Indeed, the SIM900 board simply sticks into Uno and immediately starts working. However, as it turned out, Arduino Uno may be "weak" to implement some functions, but I will tell about this just below.

With Arduino Mega, the board works with some restrictions. This is due to the fact that Megi, unlike UNO, Pina 7 and 8 is not available for use as a Software Serial (Software USart). This is solved by switching the USArt interface to the feet 0 and 1, for this, jumpers are provided on the SIM900 card.

In general, the board can be connected to any controller with the USart interface. For example, I tried to control the modem using the STM32F4 controller.

SIM900: SMS messages and calls

The test of the module for exchanging SMS messages and calls were "Hurray"! The module coped with these tasks without any problems, for this I just copied C of the same site, compiled and flashed in Arduino Uno this code:

// Serial Relay - Arduino Will Patch A // Serial Link Between The Computer and the GPRS Shield // AT 19200 BPS 8-N-1 // Computer Is Connected To Hardware Uart // GPRS SHIELD IS Connected to the Software Uart #Include SoftWareSerial GPRS (7, 8); Unsigned Char Buffer; // Buffer Array for Data Recieve Over Serial Port Int Count \u003d 0; // Counter for Buffer Array void setup () (GPRS.Begin (19200); // The GPRS Baud Rate Serial.begin (19200); // The Serial Port of Arduino Baud Rate.) Void Loop () (IF (GPRS .Vailable ()) // If Date Is Comming From SoftwareSerial Port \u003d\u003d\u003e Data Is Comming From GPRS SHIELD // Reading Data Into Char Array (Buffer \u003d GPRS.Read (); // Writing Data Into Array If (Count \u003d\u003d 64) Break;) Serial.Write (Buffer, Count); // If No Data Transmission Ends, Write Buffer to Hardware Serial Port ClearBuffERRAY (); // Call ClearBufferarray Function to Clear the Storaged Data from the Array Count \u003d 0; // Set Counter of While Loop to Zero) if (serial.available ()) // If Data Is Available on HardwareSerial Port \u003d\u003d\u003e Data Is Comming From PC or Notebook GPRS.WRITE (Serial .read ()); // write it to the gprs shield) void clearbufferarray () // FUNCTION TO CLEAR BUFFER ARRAY (FOR (INT I \u003d 0; I

In order to send the command to the module, you need to connect it to the computer. This can be done using the USB port Arduino. On the computer for this you need any COM port monitor. It can download it from hereAnd you can use the monitor built into Arduino IDE.

Everything that the Arduino program does, "catches the user commands and sends them to the module, and then returns the user SIM900 responses to the user. Thus, by passing the AT command in manual mode, I tried the reception and transmit SMS messages, while connecting the microphone and headphones to the appropriate connectors - I used the SIM900 module as a mobile phone.

GPRS data transmission using SIM900

Its first experiments on data transmission via GPRS I started using the Arduino Uno Platform to control the SIM900 (just because it was at hand). To begin with, I bought a hosting with the server under APATCHE and turned on it the simplest application that skillfully respond to GET requests. Happened! I still sent commands from the PC to the Arduino Controller, which in turn sent them to SIM900.

Everything worked correctly until the GET queries were short enough (up to 100 characters). But as soon as the requests have become longer - failures began: requests were not fully transmitted. It was noted that glitches may appear or disappear even with an increase in / reducing the Arduino control program for several lines. Subsequently, it turned out that the failures are associated with the program USArt, which Arduino UNO uses to communicate with SIM900, because Such a USArt entirely depends on the controller kernel program cycle. With a small amount of data, they always have passed to transmit, and with an increase in their number - the result of the transmission depends on the duration of the program cycle.

Conclusion from all over the foregoing: use the software USart when communicating with SIM900 cannot be taken, especially when it comes to a large number of data transmitted.

ARDUINO UNO has only one "iron" USArt interface, which was busy with a PC, so I had to abandon UNO, replacing it on Arduino Mega, which does not suffer from the lack of "iron" usarts. After such a "casting", the operation of the device has become stable and correct.

SIM900: TCP-IP stack or http? What's better?

After studying the Modem Management Guide, I found that there are two AT command groups. The first group is used to transfer data through the built-in TCP-IP stack, and the second uses the HTTP protocol already implemented by the internal logic of SIM900. How much I neither tormented Google and Yandex trying to find out what the data differences are different, what are the pros and cons of each of them, "did not find anything, so I tried both and share my practical experience here.

Both working methods and have the right to exist.

The TCP-IP stack is a bit more difficult to initialize (more commands need to transfer the module), they are slightly difficult for them. In order to send a request, you must open the connection, wait for the answer and correctly close it.

HTTP is, in simple words, the browser is embedded in SIM900. It is easy to initialize, in order to start sharing with the server, you must open a session. At the same time, the opening and closing of the connection each time the query and the solution of other "organizational tasks" go to the shoulders of SIM900. It is convenient, moreover, data transmission is somewhat faster, just because the SIM900 is faster to perform all "auxiliary operations" than the controller controller can do.

Thus, when choosing a method of exchanging, I still stopped on the HTTP protocol.

Incorrect GET request to the server

At the very beginning of its work on GPRS data transmission, I made a mistake that cost me not one day of torment. Without having sufficient experience in interacting with the server through GET requests, I, having mastered the surface knowledge on the Internet, made a request of the form:

Get http://xxx.ru/d_command.php?uc\u003d1111 http / 1.1
Host: xxx.ru.

This request is not correct, but it is excellent "drone" the browser and proxy server from which I sent requests for debugging - that is why I considered the request is true.

The most amazing thing is that the SIM900 also coped perfectly with the "bad" query (and sent requests I then through a TCP-IP stack). However, one day, the server began to answer such requests to 404 errors. This happened so and not clarified circumstances, whether the hosting provider changed the algorithms of the request processing (it is rejected from this), whether it made a mobile operator. But the fact remains a fact. Then I tried to transfer the same request via HTTP - everything worked. It is explained by this by the fact that the internal HTTP protocol of the SIM900 module (as I said, in fact, the built-in browser) knows how to "burst" incorrect requests and broadcast in the network already in the correct form. This is another plus (doubtful, of course) use HTTP, because it allows the programmer some inaccuracies. In general, of course, the request must be written correctly and look like this:

Get /d_command.php?uc\u003d1111 http / 1.1
Host: xxx.ru.

With such a correct query, SIM900 is successfully exchanged through the TCP-IP stack, and through HTTP.

Hanging SIM900.

Sometimes when exchanging the GPRS there are situations after which the module may hang. This wine may be incorrect data that came across the network and the SIM900 stupor, or interference on the exchange line of the module and the controller, in which SIM900 received "not what was waiting for", or some other unknown problems. The chip manufacturer warns that this can occur and offers in such cases to restart the module using a special pulse sequence supplied to the PWRKEY input.

However, as it turned out, it does not always help - after such a reboot, the module can "wake up" still "gluchny". And the manufacturer warns us too much if you carefully read the Datasheet on the module. This is what is recommended in the documentation:

Note: IT IS Recommended to Cut Off The VBat Power Supply Directly Instead of Using External Reset Pin WHEN SIM900 CAN NOT RESPOND TO THE AT COMMAND "AT + CPOWD \u003d 1" AND PWRKEY PIN.

Therefore, the most correct way to restart the module is the full removal of power from it (from the VBAT leg), shutter speed of some pause (at least a second just in case) and re-supplying power. To restart the module on the board, it is better to provide a relay or transistor key controlled by the controller.

Conclusion

In the future, I plan to release a series of articles - lessons, in which I will tell you how to organize the exchange between the server web application and SIM900, starting with the purchase of hosting from the provider ending with writing the code of control programs.

Bye! Watch for updates to Lazy Smart. .

I finally managed to study, perhaps the most popular GSM module in the DIY environment - GSM900. What is a GSM module? This is a device that implements the cell phone features. In other words, GSM900 allows you to call other cellular subscribers, receive calls, send and receive SMS messages. And also, of course, transmit data on the GPRS protocol.

I need this module for quite a specific goal: a project of the lighting system controlled remotely appeared. The easiest thing is that this task is solved by SMS messages: sent one SMS - the light turned on, sent another - turned off. No remote controls are not necessary, but everyone has the phone (even at homeless). Actually, in this article I will consider this particular use of the GSM900 module.

1. Firmware

The will of the fate, I had a GSM900A module in my hands. After reading the first forum about the revival of this thing, it turned out that the letter A in the title means belonging the module to the Asian region. And, consequently, it will not work with our operators. Despondency 🙁

Fortunately, in the following posts, the same forum contained soothing information :) It turned out that everything was not so bad and that the module earned in our region, it would be necessary to reflash it. This process is well described in the blog of our Alex-EXE: All in One SIM900 firmware
I will try to do the same, but even more detail, and taking into account the peculiarities of my module.

If you have the correct module and the firmware is not required, you can immediately jump to section number 2.

Instruments

So, first will prepare all the necessary tools. First, directly for the firmware will require the SIM900 Series Download Tools Develop, which can be easily found on the Internet ().

Secondly, the firmware file itself 1137b02sim900m64_st_enhance, which is also easily mined ().

Finally, thirdly, we need a good terminal for experiments with a module. Usually I use TeraTerm, but this time its capabilities lacked (or I did not figure it out). I had to install a monster with a brilliant name.

Connecting to USB-UART Bridge

Now connect the RX and TX lines to the bridge. As the latter I used CP2102. In my case, contrary to logic, Rx and TX bridge were connected to the RX and TX GSM module symmetrically (and not crosswise, as accepted).

You should also save the module from a stable and powerful source, as the peak current on the module can reach 2a (supposedly). 4 batteries are suitable for the AA size. The full inclusion scheme looks like this:

SIM900.
CP2102 GND. GND.
CP2102 + 5V. Vcc_mcu.
CP2102 RX. SIMR.
CP2102 TX. SIMT.
External source + 5V VCC5
External source GND. GND.
RST

This model does not have a reset button, so for the firmware it will be necessary for a couple of seconds to throw the contact RST to the Earth. For this, we will still leave him hanging in the air.

Pre-configuration of the module

Before you start the firmware, we connect with the module, and change the speed of the UART. To do this, launch the Terminal terminal, select the correct port, and set the exchange rate - 9600. After that, click "Connect".

All communication with the module occurs through AT commands.

The first thing we say the module will be the most primitive AT command: "AT." This is such a kind of ping, which the module must respond with the word "OK".

If everything went successfully, and the module really answered us "OK", send the speed settings command:

AT + IPR \u003d 115200

At the end of the command should stand the service symbol of the carriage return - CR. In the ASCII table, it has code 13 (or 0x0d in a hexadecimal system). The symbol will set automatically if you put the "+ CR" daws in front of the input row in our terminal. In other terminals, there are also similar settings.

In response to the entered command, we will again get - "OK".

This setting will be needed to accelerate the firmware procedure. Otherwise, as the Alex-EXE pointed out in his blog, the firmware will take about an hour.

Setting up the program

After all the wires are stuck in the right places, and the module is prepared for the firmware, launch the SIM900 Series Download Tools Develop application. The program setting consists of only several points:

  • in the Target field, we specify the target chip. For some reason, I did not reach the firmware on the SIM900A, so I chose "SIM900";
  • select the correct port in the Port field;
  • BAUD RATE put in 115200;
  • finally, specify the firmware file in the Core File field (file with the CLA extension).

With setting everything.

Firmware

Now we carry out strictly and sequentially six important steps.

  • We connect the power to the module (our 4 batteries). A red nutritional lamp should light up, and the status lamp should flash.
  • We connect a USB-UART to a computer.
  • We clicze the RST wire to the ground (remember that all this time he dangled in the air).
  • Click the Start Download button in the program.
  • We believe in the mind of up to three, and we tear the RST from the Earth.

We are waiting for 6 minutes before the completion of the firmware.

What we have after the firmware

First, the module now knows how to work with our operators. Secondly, we put an extended firmware, among the features of which, for example, obtaining the coordinates of the cellular tower module, work with email and access to an additional 2.5 MB of memory.

2. Experiments with GSM module

Let's try to perform different useful operations with a module. To begin with, we introduce a PIN code (if any):

AT + CPIN \u003d 8899

The answer module will be like this:

CPIN: Ready.

After that, we get some information from the module.

AT + GMR - firmware identifier. AT + GSN - IMEI. AT + CPAS - Condition (0 - Ready for work, 2 - unknown, 3 - incoming call, 4 - voice connection). AT + COPS? - information about the operator.

Telephone calls

Now you want some number. This is done using the team:

ATD + 790XXXXXXXX;

The point with a comma at the end of the team is very important, for forget about it!

If during the UART session on the device someone will call, the message will be back:

Answer a call (take the phone) you can command:

If headphones and microphone are connected to the module, you can communicate with a remote subscriber as an ordinary cell phone.

Completes the call command:

Sending SMS.

First you will turn on the text message mode:

AT + CMGF \u003d 1

and install the encoding:

AT + CSCS \u003d "GSM"

The module supports other encodings, more convenient for automatic systems. But for the experiments it is more convenient to use GSM mode in which the phone is set by numbers, and the message text is written in the ASCII encoding. Now send someone a message:

AT + CMGS \u003d "+ 79123456789"

And the end of the command must add two service symbols at once: cr and lf. In Terminal, it can be made of CR \u003d CR + LF, or manually adding at the end of the line: AT + CMGS \u003d "+ 79123456789" & 0D & 0a

After entering this command, in response, the "\u003e" symbol will be received, meaning the beginning of the message input. Write some text:

Hello WORLD!

At the end of the message, we will need to pass one of two special characters. To send a message Enter the character from the ASCII table with the number 26. To cancel the shipment - the character number 27.

In the Terminal used by us, one of two expressions can be used to send a symbol by code: in hexadecimal format: $ 1a, and in tenual: # 026

Receive SMS.

If SMS comes to the device during a session, the format message will return:

CMTI: "SM", 4

here 4 is the incoming unread message number.

AT + CMGR \u003d 4

In response, we get:

CMGR: "REC READ", "+ 790XXXXXXXX", "", "13/09 / 21,11: 57: 46 + 24" Hello World! OK.

In general, everything is simple. This is enough for us to implement the conceived. For a deeper study of the possibilities of GFM900, I recommend reading another ALEX-EXE article: AT commands gSM modem SIM900.

3. Interaction with microcontrollers

In general to manage external devices It is not necessary to pair the GSM900 module with another microcontroller. You can sew your program to this module that will do anything with free GPIO conclusions. However, in most ready-made GPIO boards, it is not divorced, so to create a prototype of the planned device we will use the most simple Arduino. Uno / Nano.

Communication Arduino and GSM900 will be all on the same UART interface. To do this, connect these two devices according to the following scheme:

GSM900. GND. Vcc_mcu. SIMT. SIMR.
Arduino Uan GND. + 5V. RX TX.

Now we will make a program that will catch SMS, and light the LED on the leg No. 13 for a couple of seconds. By this we imitate the management of a certain external device.

Const String Spin \u003d "1234"; Const int REL_PIN \u003d 13; String SS \u003d ""; // Sending a PIN code Void Sendpin () (String CMD \u003d "AT + CPIN \u003d" + SPIN + CHAR (0x0d); Serial.print (CMD);) // Turn on the LED for 2 seconds Void ReceiveSMS (String S) ( DigitalWrite (REL_PIN, HIGH); Delay (2000); DigitalWrite (REL_PIN, LOW);) // Collaboration of the string came from the Void Parsestring module (Bool Collect \u003d False; String S \u003d ""; for (Byte I \u003d 0; I

Load the program on Arduino, and test the system. If everything is done correctly, sending SMS messages to the device will turn on the LED for 2 seconds. Of course, instead of the LED, you can turn on / off the powerful relay to which the heating boiler is connected in a country house.

GSM and GPRS module in projects Arduino allows you to connect to remote autonomous devices through a regular cellular communication. We can send commands to devices and receive information from it using SMS commands or via an Internet connection, open by GPRS. In this article, we will consider the most popular modules for Arduino, we will deal with connecting and consider programming examples.

Modules GSM GPRS

GSM Module Used to expand the capabilities of ordinary Arduino boards - sending SMS, making calls, data exchange for GPRS. There are various types of modules, the most commonly used - SIM900, SIM800L, A6, A7.

Description of the SIM900 module

The SIM900 module is used in various automated systems. Using the UART interface, data exchange is made with other devices. The module provides the ability to make calls, sharing text messages. The operation of the module is released on the SIM900 component created by Simcom Wireless Solution.

Specifications:

  • Voltage range is 4.8-5.2V;
  • In the usual mode, the current reaches 450 mA, the maximum current in the pulse mode 2 A;
  • 2G support;
  • Transmission power: 1 W 1800 and 1900 MHz, 2 W 850 and 900 MHz;
  • There are built-in TCP and UDP protocols;
  • GPRS MULTI-SLOT Class 10/8;
  • Operating temperature from -30C to 75C.

With the help of the device, you can track the route of transport in conjunction with GLONASS or GPS device. The possibility of sending SMS messages is used in wireless alarm and various security systems.

Description of the SIM800L module

The module is based on the SIM800L component and is used to send SMS, the implementation of calls and data exchange by GPRS. The micro sim card is installed in the module. The device has a built-in antenna and connector to which you can connect an external antenna. Power to the module comes from an external source or via a DC-DC converter. Management is carried out using a computer via UART, Arduino, Raspberry PI or similar devices.

Specifications:

  • Voltage range 3.7V - 4.2V;
  • Support for 4 range network 900/1800/1900 MHz;
  • GPRS Class 12 (85.6 Kb / s);
  • Maximum current 500 mA;
  • 2G support;
  • Automatic search in four frequency bands;
  • Operating temperature from -30C to 75C.

Description of the A6 module

The A6 module was developed by Ai-Thinker in 2016. The device is used to exchange SMS messages and data exchange by GPRS. The board is characterized by low energy consumption and small size. The device is fully compatible with Russian mobile operators.

Specifications:

  • Voltage range 4.5 - 5,5V;
  • Nutrition 5V;
  • Range of operating temperatures from -30c to 80c;
  • Maximum current consumption 900mA;
  • GPRS Class 10;
  • Support PPP, TCP, UDP, MUX protocols.

The module supports microsite format cards.

Description of the A7 module

A7 is the newest module from Ai-Thinker. Compared with its predecessor A6 has a built-in GPS, which allows you to simplify the design of the device.

Specifications:

  • Range of operating stresses 3.3V-4,6V;
  • 5V supply voltage;
  • Frequencies 850/900/1800/1900 MHz;
  • GPRS Class 10: Max. 85.6 kbps;
  • Suppression of echo and noise.

The device supports microsis cards. The module supports the exchange of calls, the exchange of SMS messages, transmitting data for GPRS, receiving signals to GPS.

Where to buy GSM modules for Arduino

Traditionally, before you start, several tips and useful links to aliexpress sellers.

Very high quality module KEYES SIM900 GSM GPRS Module SIM800C for Arduino from Verified Supplier
SHILD for development compatible with Arduino based on the SIM900 GPRS / GSM module Inexpensive MINI A6 GPRS GSM module

Connecting GSM GPRS Shild to Arduino

In this section, we consider the issues of connecting GSM - modules to the Aduino board. In almost all examples, Arduino Uno is taken in almost all examples, but for the most part of the examples will go for MEGA, Nano boards, etc.

Connecting the SIM800 module

For connection, the Arduino board is needed, the SIM800L module, which reduces the voltage converter, wires for connection and battery by 12V. The SIM800L module requires a 3.7V voltage for arduino, for this, it is necessary to reduce the voltage converter.

The SIM800 module pinout is shown in the figure.

Arduino board must be connected to a computer via USB cable. Connect the battery at 12 to connect through the converter: -12V to the land of Arduino, from the ground to the converter in minus, + 12V to the converter in plus. Outputs from the TX and RX module must be connected to the Pins 2 and 3 to Arduino. Several modules can be connected to any digital pin.

Connecting the A6 module

The A6 module is cheaper than SIM900, and it is very easy to connect to Arduino. The module is powered by a voltage of 5V, so the connection does not require additionally lowering the stress elements.

For connection, Arduino is required (in this case, Arduino Uno is considered), GSM Module A6, connecting wires. Connection diagram is shown in the figure.

RX output from the GSM module must be connected to the TX on the Arduino board, the TX output is connected to the RX pin to Arduino. Earth from the module is connected to the ground on the microcontroller. The VCC output on the GSM module must be connected to the PWR_KEY.

Connection using GSM-GPRS Shilda

Before connecting, it is important to pay attention to Sild's supply voltage. The current at the time of the call or sending data can reach the values \u200b\u200bof 15-2 A, so it is not necessary to power the SCILD directly from Arduino.

Before connecting to Arduino, you need to install a SIM card on GSM-GPRS shield. You also need to install TX and RX jumpers, as shown in the figure.

Connection is performed as follows - the first contact (in the image of the yellow wire) from shield must be connected to the TX on Arduino. The second contact (green wire) is connected to the RX on Arduino. Earth with Shilda is connected to the ground with Aruino. The meal on the microcontroller comes through the USB cable.

Sild connection layout and Arduino board is shown in the figure.

To work, you will need to install the GPRS_SHIELD_ARDUINO library.

To check the correctness of the collected circuit, you need to do the following: connect to Arduino RESET and GND (this will lead to the fact that the data will be transmitted directly from shield to the computer), insert the SIFD SIFD SIFDE and turn on shield power. Arduino board must be connected to a computer and press the power button. If everything is connected correctly, the red LED will light up and green will flash.

Brief description of interaction through AT commands

AT commands are a set of special modem commands consisting of short text strings. To make the modem recognized the command filed by him, the lines should begin with the letters at. The string will be perceived when the modem is in the command mode. AT commands can be sent both using communication software and manually from the keyboard. Practical all commands can be divided into 3 modes - the test, in which the module responds whether the command supports; Reading - issuing current command parameters; Recording - There will be a record of new values.

List of the most used AT commands:

  • AT - to verify the correct connection of the module. If everything is fine, OK is returned.
  • A / - Repetition of the previous command.
  • AT + IPR? - Getting information about the port speed. The answer will be + IPR: 0 OK (0 in this case - automatically).
  • AT + ICF? - Admission setting. The answer will come + ICF: bits, parity.
  • AT + IFC? - Transmission control. The answer will be + IFC: the terminal from the module, the module from the terminal (0 - there is no control, 1 - program control, 2 - hardware).
  • AT + GCAP - Displays the capabilities of the module. An example of a response - + GCAP: + FCLASS, + CGSM.
  • AT + GSN - Getting the IMEI module. An example of response 01322600xxxxxxx.
  • AT + COPS? - shows available operators.
  • AT + CPAS - module status. The answer + CPAS: 0. 0 - Readiness for work, 3 - incoming call, 4 - voice connection, 2 - unknown.
  • AT + CCLK? - Information about current time and date.
  • AT + CLIP \u003d 1 - Turn on / off AON. 1 - Enabled, 0 - Disabled.
  • AT + CSCB \u003d 0 - Receiving special SMS messages. 0 - Allowed, 1 - prohibited.
  • AT + CSCS \u003d "GSM" - Coding an SMS message. You can choose one of the following encodings: IRA, GSM, UCS2, HEX, PCCP, PCDN, 8859-1.
  • AT + CMEE \u003d 0 - Obtaining an error information.
  • AT + CPIN \u003d XXXX - Entering the SIM card pin.
  • AT & F - Reset to factory settings.
  • AT + CPOWD \u003d 1 - Urgent (0) or Normal (1) Switching off the module.
  • ATD + 790XXXXXXXX - Call to the number + 790xxxxxxxx.
  • ATA - answer to the challenge.
  • AT + CMGS \u003d "+ 790XXXXXXXX"\u003e Test SMS - sending SMS messages to the number + 790xxxxxxxx.

In this case, the main commands for the SIM900 module are considered. For different modules, the commands may differ slightly. The data for the module will be supplied through special program "Terminal" to be installed on a computer. You can also file commands module via the port monitor in Arduino IDE.

Sketches for working with the GSM module

Sending SMS on SIM900 example

Before sending a message, you need to configure the module. First you need to translate into text format Transmitted message. To do this, there is a command AT + CMGF \u003d 1. You need to translate the encoding on the GSM command at + CSCS \u003d "GSM". This encoding is most convenient, as the characters are presented in ASCII code, which easily understands the compiler.

Then you need to dial an SMS message. To do this, the command with the subscriber number AT + CMGS \u003d "+ 79XXXXXXXXX" R, in response, it is proposed to dial the SMS text. You need to send a message. At the end, you need to send a Ctrl + Z combination code, the module will allow sending text to the addressee. When the message is sent, OK will return.

The interaction with the module is based on indexes that are assigned to each new message. By this index, you can specify which of the messages to delete or read.

Obtaining SMS. AT + CNMI \u003d 2,2,2,2,0,0 is used to read the SMS message. When a text message comes to the module, it will send to serial port + CMTI: "SM", 2 (in this case 2 is the sequence number of the message). To read it, you need to send AT + CMGR \u003d 2 command.

Reception voice call. First of all, for a conversation, you need to connect the speaker and microphone to the module. When receiving a call, the number from which it is perfect is shown. To work, you need to enable the GSM library:

#Include.

If the SIM card is blocked, you need to enter its PIN code. If the PIN code is not required, this field must be left blank.

#Define Pinnumber ""

In SETUP (), data transfer to a computer must be initialized. The next step will be the creation of a local variable to track the status of the network connection. Sketch will not be launched until the SIM card is connected to the network.

boolean Notconnected \u003d True;

Using the GSMAccess.begin () function, a network connection occurs. When you establish a connection, GSM_Ready will return.

vcs.hangcall (); - A function showing that the modem is ready to receive calls.

getVoiceCallStatus () - determines the status of the sketch. If someone calls, it returns the value of the receivingcall. To record the number you need to use the RetrieveCallingNumber () function. When the call is made to the call, Talking will return. Then the sketch will wait for the symbol new Stringto interrupt the conversation.

Install GPRS connection and send data to a remote server

First you need to install the SoftWareSerial library, which allows you to provide consistent information and link the GSM module and the Arduino microcontroller.

To send data to the server you need to send the following commands:

AT + SAPBBR \u003d 1.1 - Opening Carrier.

The following three commands are associated with the installation of network connection settings.

AT + SAPBBR \u003d 3.1, \\ "APN \\", \\ "internet.mts.ru \\" - choice operator MTS., Access point name.

AT + SAPBR \u003d 3.1, \\ "User \\", \\ "MTS \\" - Selecting a MTS user.

AT + SAPBR \u003d 3.1, \\ "PWD \\", \\ "MTS \\"

AT + SAPBR \u003d 1,1 - Installing the connection.

AT + httpinit - HTTP initialization.

AT + httppara \u003d "URL", - URL address.

AT + Httpread - Waiting for Answer.

AT + Httpterm - HTTP stop.

If everything is performed correctly, lines with AT commands will appear in the port monitor. If there is no connection with the modem, it will show one row. For successful installation GPRS connections on the module will flash the LED.

GSM / GPRS SIM900 SHIELD Board Overview

The Arduino GPRS / GSM SHIELD (Figure 1) board provides us with the ability to use for remote reception and transmission of mobile GSM communication data. This can be done in three ways:

    using sending / receiving short text messages (SMS);

    sending voice (audio) commands based on CSD technologies (standard data transfer technology in gSM networks) and / or DTMF (two-tonal multi-frequency analog signalused for dialing telephone number);

    using batch data transmission based on GPRS technology.

    The board is based on the SIMCOM SIM900 module.

Also on it are located:

    sIM card slot;

    jack 3.5 mm for audio input and output;

    the connector for the external antenna.

Communication with the board is made through the Serial connection using the AT command set. Using jumpers on the board it is possible to install the contacts used for communication: hardware 0-1st or 2-3 (on some boards) 7-8th to work through SoftWareSerial.

Figure 1. GPS GPRS SHIELD.

The GSM GPRS SIM900 SHIELD board can be included in two ways:

    hardware (pressing the PWRKEY button);

    software.

Connect to Arduino board

GSM GPRS SIM900 SHIELD card is made in Shild format for Arduino boards. Shield contacts (comb) are easily inserted into the board connectors, while forming a "sandwich" (Figure 2).


Figure 2. Installing GPS GPRS SHIELD on Arduino Hard.

Management of the GSM GPRS SIM900 module using AT commands

Consider management module GSM. GPRS SHIELD with AT commands. To do this, set the module on and connect it to the computer. Arduino-Sketch Sending and receiving data between the computer and the GSM GPRS Shield module via the fee is shown in Listing 1.


Listing 1.

#Include.

// Creating an object

SoftWareSerial GRS (7, 8); // RX, TX

// Exchange Speed

#Define GSMBAUD 9600.

Serial.begin (9600);

gsm.begin (gsmbaud);

Serial.println ("Start");

if (serial.available ()) (

sTR1 \u003d Serial.ReadStringuntil ("\\ n");

str1.Tocararray (Buffer, HH.Length () + 1);

gSM.WRITE (Buffer);

gsm.board.write ("\\ n");

if (gsm.available ()) (

Serial.write (GPRS.Read ());

We load the sketch on the Arduino fee, open the serial port monitor and type the mode setup commands:

Module connection check command to the GPRS network, which, when answering Command No Response, you must constantly repeat

Connect to the access point of the telecom operator. For Beeline:

AT + CGDCont \u003d 1, "IP", "internet.beeline.ru"

AT + CSTT \u003d "internet.beeline.ru", "", ""

Installing Internet Connection:

AT + CGACT \u003d 1,1

Appeal to the Internet Resource

The entire connection process is shown in Figure 3.


Figure 3. The process of working with the GSM GPRS SIM800 module in the serial port monitor.

Example of sending SMS messages from Arduino fee

Consider an example of using sending SMS messages with a decrease in the air temperature in the room below a certain value. We need the following details:

    gSM GPRS SHIELD Module - 1 pc;

    sIM-card cellular operator with a positive balance;

    12V power supply - 1 pc;

Connection diagram is shown in Figure 4.


Figure 4. Connection diagram for sending SMS messages at low air temperature values.

We will start writing the sketch. Every 30 seconds, we obtain humidity and temperature data from the DHT11 sensor. Use the DHT library. When the temperature value is slightly critical send SMS to the number specified in the Phone constant. And we pause for 10 minutes.

The contents of the Sketch are shown in Listing 2.


Listing 2.

// Connecting libraries

#Include.

#include "Dht.h"

// Telephone to send SMS

#Define Phone_Number "+7928222222"

// Creating objects

SoftWareSerial GSM (7, 8);

DHT SENSORDHT (2, DHT22);

// Threshold temperature value

#Define Tempp 18.

unsigned long Millissend;

// Start Serial Port

Serial.begin (9600);

// Running the DHT sensor

sensordht.begin ();

// Running SoftWareSerial

gsm.begin (9600);

if (Millis () - Millissend\u003e 30 * 1000) (// Indications every 30 seconds?

// Getting data from the DHT sensor

int h \u003d sensordht.readhumidity ();

int t \u003d sensordht.Readtemperature ();

iF (T.

// Send SMS.

// We are waiting for 10 minutes

delay (10 * 60 * 1000);

millissend \u003d Millis ();

// Sending SMS.

void Sendsms (int t) (

// Install Text Mode

gsm.print ("AT + CMGF \u003d 1 \\ R");

// telephone

gSM.PrintLN (Phone_Number);

gsm.println ("\\" ");

// Send data T

// ending transmission

gSM.PrintLN ((Char) 26);

We load the sketch, check the SMS arrival event to the selected phone number at a critical temperature value.


Figure 5. Scheme assembly.

Create a data firmware when sending an SMS message to a SIM card located in the GSM GPRS Shield module. The contents of the Sketch are shown in Listing 3.


Listing 3.

// Connecting libraries

#Include.

#include "Dht.h"

// Creating objects

SoftWareSerial GSM (7, 8);

DHT SENSORDHT (2, DHT22);

// Variables

String Phone \u003d ""

String Str1 \u003d ""; //

boolean Issms \u003d False;

// Connect Serial Port

Serial.begin (9600);

// Running the DHT sensor

// Running SoftWareSerial

gsm.begin (9600);

// Setting up receiving messages

gsm.print ("AT + CMGF \u003d 1 \\ R");

gsm.print ("AT + IFC \u003d 1, 1 \\ R");

gsm.print ("AT + CPBS \u003d \\" SM \\ "\\ R");

gsm.print ("AT + CNMI \u003d 1,2,2,1,0 \\ R");

if (gsm.available ()) (

char c \u003d gsm.read ();

if ("\\ r" \u003d\u003d c) (

if (ISSMS) (// Current Row - SMS-message,

if (! Str1.comPareto ("TMP")) (// text SMS - TMP

// Send SMS to the coming number

// Obtaining data

iNT T \u003d DHT.Readtemperature ();

// AT-command TEXT MODE

gsm.print ("AT + CMGF \u003d 1 \\ R");

// recipient phone number

gsm.printLN ("AT + CMGS \u003d \\" ");

gSM.PrintLN (Phone);

gsm.println ("\\" ");

// Message - Data Temperature

// ending transmission

gSM.PrintLN ((Char) 26);

Serial.PrintLN (CURRSTR);

if (Str1.startSwith ("+ CMT")) (

Serial.PrintLN (STR1);

// Select the phone number from the message

phone \u003d Str1.Substring (7.19);

Serial.printLN (Phone);

// If the current line begins with "+ CMT",

// then the next string is a message

eLSE if ("\\ n"! \u003d C) (

sTR1 + \u003d STRING (C);

We load the sketch on the fee, send an SMS message with the text TMP to the SIM card and get in response to an SMS message with temperature data.

Frequently asked questions FAQ

1. No connection with Arduino on a serial port.

    Check the board.

    Check the adjustment of the jumpers.

2. SMS messages are not sent.

    Check for external power supply GSM GPRS SHIELD.

    Check the balance of the SIM card.

SHIELD GPRS / GSM SIM900 with antenna
SIM900 GPRS / GSM SHIELD Development Board Quad-Band Kit for Arduino Compatible

Module for the operation of Arduino microcontroller devices and similar in cellular networks according to GSM and GPRS standards. Focusing on automation and control systems. Data exchange with other modules occurs through the UART interface. SHIELD GPRS / GSM SIM900 with an antenna can be conjugate directly with the microcontroller via the UART interface or work in conjunction with a personal computer when using the Portpk-Uart interface converter. This is possible thanks to software compatibility at the command class level used to control modems - AT team.
Monitoring objects and management of them occurs due to the exchange of data within the reach of mobile communications. Voice communication is provided, sending SMS, MMS and many other functions and services. The operation of the module is based on the SIM900 component.

Article in Russian from the SIM900 component magazine. The component is designed by Simcom Wireless Solutions. SIMCOM website has a Russian-speaking version. The GSM module board on the component side contains connectors for connecting antenna, headphones and microphone. On the side of the soldering board, the CR1220 3 Volta battery holder is located supporting the module clock operation and a container for installing a sim card.
One of the device applications is a transport tracking system together with GLONASS or GPS device. Sending SMS messages allows you to use a module in dispatching, wireless alarm and in security systems. As a result of occurring events, various SMS can be sent: "Emergency stop of the elevator 2 houses No. 34", "The car door is open", "the basement is open", "voltage 220 in turn off", "the input door of the cottage is open", "the lighting is turned on," Temperature in the greenhouse is lower critical. " The module is indispensable to control and control moving objects moving over long distances. Or in case of removal of the operator for a large distance from the stationary object.

SHIELD GPRS / GSM SIM900 with an antenna gives ample opportunities to study the SIM900 component. Installation of the SIM900 component is performed according to the most modern technologies, because of which it is very difficult to solder to the SIM900 printed circuit board in the laboratory. Having a module with the SIM900 installed, you can conduct experiments using the SIM900 component. When using the SIM900 component, the SIM900 component appears the possibility of debugging software and verification of circuit decisions.

Characteristics

Food
Voltage, B.
Nominal 5.
Range 4.8-5,2
current
Normal mode 50-450 mA
In sleeping mode 1.5 mA
Extreme pulse 2 A
Supports sim cards with meals 1.8 and 3 V
Communication ranges 850, 900, 1800, 1900 MHz
Supports network 2G.
Transmission Power in various ranges
1 W 1800 and 1900 MHz
2 W 850 and 900 MHz
Complies with GSM Phase 2/2 + Standard
Built-in TCP and UDP protocols
GPRS MULTI-SLOT CLASS 10/8 Data Class 10/8
Audio codecs HR, FR, EFR, AMR, echo suppression
CSD to 14.4kbit / s
PPP stack
MUX (07.10)
HTTP and FTP protocols
It is possible to send DTMF signals and play records as on an answering machine
Real-Time Support RTC
Temperature, ℃
air when working -30 ... 75
storage -45 ... 90
Sizes 86 x 58 x 19 mm

Control components

The POWER SELECT switch is set to the power supply: external connected to the coaxial connector or the ARDUINO microcontroller module power supply.

The Power Key button turns on or off the power when pressed and holding for 2 s.

Indication

3 LEDs are reported on the state of the module:
PWR (green) - Module power indicator,
Status (red) - SIM900 component power indicator,
NET LIGHT (green) - connection to the network.
NET LIGHT LED messages.
Disable - SIM900 does not work.
Flashing at intervals, indicated in seconds:
0.064 turned on and 0.8 off - the network is not detected,
0.064 turned on and 0.3 off - the network is detected,
0.064 Enabled, 0.03 Disabled - GPRS connected.

Contacts

The SIM900 component contains the UART port, its signals are displayed on the component pins and are connected to jumpers that set with which shield GPRS / GSM SIM900 module contacts will be connected to the SIM900 component with D0, D1 or D7, D8.
URT SHIELD GPRS / GSM can be connected: to the MK hardware interface through the contacts TXD and RXD module SHIELD GPRS / GSM, for this purpose D0, D1 are used. Or to programmatically emulated means of Arduino, for this, contacts D7 and D8 SHIELD GPRS / GSM module are used. The complete UART interface has 10 signals withdrawn into contacts in the corner of the board: R1, DCD, DSR, CTS, RTS, GND, 2V8, TX, RX, DTR.
12 signed contacts of digital I / O lines GPIO are located in the corner of the board. There are 2 contact of the output signals with PWM1, PWM2 pulse modulation. ADC entry contact ADC. The interface of the built-in time counter has 4 contacts. Contact designation: DISP_CLK, DISP_DATA, DISP_D / C, DISP_CS.
Contact D9 is used to power on or off SIM900.
The board has a connector for connecting an antenna.

Assign the output of the SIM900 component.

External power on and off

You can turn on or off the power of the module using the signal to the D9 control input. To change the state on D9, a pulse is supplied with a duration of 1 s. Changing the state occurs after 3.2 ° C after the start of the pulse.

Turning on the module. Module power voltage graphics, external control pulse and Status power indicator.

When controlling the module, the steering device must occur without using the POWER KEY button, i.e. immediately after power supply. To do this, add several commands to the MK program.

Void Powerupordown ()
{
Pinmode (9, Output);
DigitalWrite (9, Low);
Delay (1000);
DigitalWrite (9, HIGH);
Delay (2000);
DigitalWrite (9, Low);
Delay (3000);
}

This group of commands in the program can also be used to turn off the module. You can also turn off the GSM module you can send an AT command.

Did you like the article? To share with friends: