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

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

GSM GPRS Modules

The GSM module is used to expand the capabilities of conventional Arduino boards - sending SMS, making calls, exchanging data via GPRS. There are different types of modules, the most commonly used are SIM900, SIM800L, A6, A7.

Description of the SIM900 module

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

Specifications:

  • Voltage range 4.8-5.2V;
  • In normal mode, the current reaches 450 mA, the maximum current in pulse mode is 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;
  • Working temperature from -30C to 75C.

Using the device, you can track the route of transport together with a GLONASS or GPS device. The ability to send 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, make calls and exchange data via GPRS. A micro SIM card is installed in the module. The device has a built-in antenna and a connector to which you can connect an external antenna. Power to the module is supplied from an external source or through a DC-DC converter. Control is carried out using a computer via UART, Arduino, Raspberry Pi or similar devices.

Specifications:

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

Description of module A6

The A6 module was developed by AI-THINKER in 2016. The device is used for the exchange of SMS messages and data exchange via GPRS. The board is characterized by low power consumption and small size. The device is fully compatible with Russian mobile operators.

Specifications:

  • Voltage range 4.5 - 5.5V;
  • Power supply 5V;
  • Operating temperature range from -30C to 80C;
  • Maximum current consumption 900mA;
  • GPRS Class 10;
  • Supports PPP, TCP, UDP, MUX protocols.

The module supports microsym cards.

Description of module A7

A7 is the latest module from AI-THINKER. Compared to its predecessor, the A6 has built-in GPS to simplify the design of the device.

Specifications:

  • Operating voltage range 3.3V-4.6V;
  • Supply voltage 5V;
  • Frequencies 850/900/1800/1900 MHz;
  • GPRS Class 10: Max. 85.6 kbps;
  • Echo and noise suppression.

The device supports micro SIM cards. The module supports call exchange, SMS messaging, GPRS data transmission, GPS signal reception.

Where to buy GSM modules for arduino

Traditionally, before starting, a few tips and useful links to Aliexpress sellers.

Very high quality KEYES SIM900 GSM GPRS module SIM800C module for arduino from a trusted supplier
Arduino compatible development shield based on SIM900 GPRS / GSM module Inexpensive mini A6 GPRS GSM module

Connecting GSM GPRS shield to Arduino

In this section, we will consider the issues of connecting GSM modules to the aduino board. Almost all examples are based on Arduino Uno, but most of the examples will go for Mega, Nano, etc.

Connecting the SIM800 module

To connect, you need an Arduino board, a SIM800L module, a step-down voltage converter, wires for connection and a 12V battery. The SIM800L module requires a voltage of 3.7V that is non-standard for Arduino, for this you need a voltage step-down converter.

The pinout of the SIM800 module is shown in the figure.

The Arduino board must be connected to a computer via a USB cable. Connect a 12 V battery through the converter: -12 V to the Arduino ground, from the ground to the converter to negative, + 12V to the converter to positive. The outputs from the TX and RX module must be connected to pins 2 and 3 on the Arduino. Multiple modules can be connected to any digital pins.

Connecting the A6 module

The A6 module is cheaper than the SIM900 and is very easy to connect to the Arduino. The module is powered by 5V, therefore additional voltage-reducing elements are not required for connection.

To connect, you will need an Arduino board (in this case, the Arduino UNO is considered), GSM module A6, connecting wires. The connection diagram is shown in the figure.

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

Connection via GSM-GPRS shield

It is important to pay attention to the shield voltage before connecting. The current at the time of a call or sending data can reach values \u200b\u200bof 15-2 A, so you should not power the shield directly from the Arduino.

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

The connection is made as follows - the first contact (yellow wire in the figure) from the shield must be connected to TX on the Arduino. The second pin (green wire) connects to RX on the Arduino. Shield earth connects to aruino earth. The microcontroller is powered via a USB cable.

The layout of the connection between the shield and the Arduino board is shown in the figure.

To work, you need to install the GPRS_Shield_Arduino library.

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

Brief description of interaction via AT commands

AT commands are a set of modem-specific commands, consisting of short text strings. For the modem to recognize the command given to it, the lines must begin with the letters at. The string will be accepted when the modem is in command mode. AT commands can be sent either using the communications software or manually from the keyboard. Almost all commands can be divided into 3 modes - test mode, in which the module answers whether it supports the command; reading - issuing the current command parameters; recording - new values \u200b\u200bwill be recorded.

List of the most used AT commands:

  • AT - to check if the module is connected correctly. If everything is OK, it returns OK.
  • A / - repeat the previous command.
  • AT + IPR? - getting information about the port speed. The answer will be + IPR: 0 OK (0 in this case is automatic).
  • AT + ICF? - transmission setting. The answer will be + ICF: bit, parity.
  • AT + IFC? - transmission control. The answer will be + IFC: terminal from the module, module from the terminal (0 - no control, 1 - software control, 2 - hardware control).
  • AT + GCAP - shows the capabilities of the module. Sample response - + GCAP: + FCLASS, + CGSM.
  • AT + GSN - getting IMEI module. Example answer 01322600XXXXXXX.
  • AT + COPS? - shows available operators.
  • AT + CPAS - module status. Answer + CPAS: 0. 0 - ready for work, 3 - incoming call, 4 - voice connection, 2 - unknown.
  • AT + CCLK? - information about the current time and date.
  • AT + CLIP \u003d 1 - enable / disable caller ID. 1 - enabled, 0 - disabled.
  • AT + CSCB \u003d 0 - receive special SMS messages. 0 - enabled, 1 - disabled.
  • AT + CSCS \u003d “GSM” - coding of SMS messages. You can select one of the following encodings: IRA, GSM, UCS2, HEX, PCCP, PCDN, 8859-1.
  • AT + CMEE \u003d 0 - getting information about the error.
  • AT + CPIN \u003d XXXX - enter the pin code of the SIM card.
  • AT&F - reset to factory settings.
  • AT + CPOWD \u003d 1 - urgent (0) or normal (1) shutdown of the module.
  • ATD + 790XXXXXXXX - call to number + 790XXXXXXXX.
  • ATA - call answer.
  • AT + CMGS \u003d "+ 790XXXXXXXX"\u003e Test sms - sending an SMS message to the number + 790XXXXXXXX.

In this case, the basic commands for the SIM900 module are considered. For different modules, the commands may differ slightly. Data for the module will be supplied through a special program "terminal", which must be installed on the computer. You can also send commands to the module through the port monitor in the Arduino IDE.

Sketches for working with the GSM module

Sending SMS using SIM900 as an example

Before sending a message, you need to configure the module. First of all, you need to translate the transmitted message into text format. For this there is a command AT + CMGF \u003d 1. It is necessary to transfer the encoding to GSM with the command AT + CSCS \u003d "GSM". This encoding is the most convenient, since there characters are represented in ASCII code, which the compiler can easily understand.

Then you need to type an SMS message. To do this, a command is sent with the subscriber's number AT + CMGS \u003d "+ 79XXXXXXXXX" r, in response, it is suggested to type an SMS text. You need to send a message. Upon completion, you need to send the combination code Ctrl + Z, the module will allow sending the text to the addressee. When the message has been sent, it will return OK.

Interaction with the module is based on indexes that are assigned to each new message. This index can be used to indicate which message to delete or read.

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

Receiving a voice call. First of all, for a conversation, you need to connect a speaker and a microphone to the module. When you receive a call, the number from which it was made will be shown. To carry out the work, you need to enable the GSM library:

#include

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

#define PINNUMBER “”

In setup (), the initialization of data transfer to the computer must be performed. The next step is to create a local variable to track the status of the network connection. The sketch will not run until the SIM card is connected to the network.

boolean notConnected \u003d true;

The gsmAccess.begin () function is used to connect to the network. When the connection is established, the value 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 RECEIVINGCALL. To record the number, use the retrieveCallingNumber () function. When the call is answered, TALKING will return. The sketch will then wait for a newline to abort the conversation.

Establish a GPRS connection and send data to a remote server

First, you need to install the SoftwareSerial library, which allows you to provide serial information transfer and link the GSM module and the Arduino microcontroller.

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

AT + SAPBR \u003d 1.1 - Carrier opening.

The next three commands are related to setting the network connection settings.

AT + SAPBR \u003d 3,1, \\ ”APN \\”, \\ ”internet.mts.ru \\” - select operator mts, access point name.

AT + SAPBR \u003d 3,1, \\ ”USER \\”, \\ ”mts \\” - the choice of the mts user.

AT + SAPBR \u003d 3,1, \\ ”PWD \\”, \\ ”mts \\”

AT + SAPBR \u003d 1.1 - connection establishment.

AT + HTTPINIT - initialize http.

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

AT + HTTPREAD - waiting for a response.

AT + HTTPTERM - stop http.

If everything is done correctly, lines with AT commands will appear in the port monitor. If there is no connection with the modem, it will show one line at a time. If the GPRS connection has been successfully established, the LED on the module will start blinking.

Arduino is a hardware platform used to quickly create various electronic devices, including security ones. Thanks to the simple design, simplicity of the programming language, as well as the use of open codes, even a non-professional can independently make a multifunctional alarm to guard his house, summer cottage, apartment or garage. The Arduino GSM module will be the best option for creating a budget security system that can be optimally configured for a specific object.

Application area

The Arduino hardware platform is widely used in the process of creating various electronic systems and devices that can receive and process signals from variously functional analog or digital sensors and sensors. The results of processing the received signals can be used to control external actuators and systems connected to the Arduino.

An example of using these modules in the video:

Appointment

The Arduino hardware platform makes it possible to effectively interact with the controlled environment through a wide range of functional sensors that can monitor various parameters. Thanks to this, on the basis of such platforms, it is possible to form security complexes that will monitor movements around the protected perimeter, for opening windows and doors, for damage to glass. In addition to security type sensors, temperature sensors, water or gas leakage control sensors can also be used.

Using the Arduino GSM module with the platform, information about a hazard or an emergency situation at the facility can be delivered to the owner as quickly as possible. For this purpose, one of the networks of mobile operators is used.

A distinctive feature of Arduino devices is that their microcontroller can be programmed by the user himself using the Arduino language based on Wiring. Thanks to this, everyone can program the algorithm of the created security alarm system as required for a specific protected object and the features of its application.

Benefits of using

Today there are many hardware platforms and microcontrollers that can receive information from external sensors, process it, and send control signals to executive systems. The Arduino platform simplifies the implementation of the listed processes as much as possible and has a wide range of advantages over other devices of this kind.

  1. Low cost. The platforms are fairly cheap devices compared to their counterparts, which in no way affects their functionality.
  2. Cross-platform. Arduino software works effectively under such operating platforms as Windows, Linux, Macintosh-OSX.
  3. Ease of programming. To configure microcontrollers, the Processing programming environment is used. It is ideal for both professional and inexperienced users who work with Arduino devices.
  4. Upgradeability. Arduino's specialized software is open source, which allows experienced users to adapt it to specific requirements.

High reliability of the hardware platform. Arduino boards are available with ATMEGA8 and ATMEGA168 microcontrollers (older models) and with ATmega32u4, Atmel ATmega328 controllers (newer models), which are highly functional and reliable.

Principle of operation

To ensure the full functioning of security systems or other devices built using Arduino platforms, you need to have a GSM module for Arduino. With its help, you can access the Internet, make voice calls or send SMS messages.

The GSM-board uses a special M10 radio modem, interaction with which is provided by special AT commands. Information exchange with the modem is implemented using a software serial interface that owns digital codes.

The GSM modem used in Arduino is a 4-band modem that can operate on the following frequencies: GSM 850MHz and 900MHz, PCS1900MHz and DCS1800MHz. The modem supports protocols such as TCP / UDP and HTTP, which provide connections via GPRS. The transmission speed of information packets in this mode will be about 90 kbps.

Sending SMS via Arduino and GSM module is realized if there is an installed SIM-card of one of the cellular operators. "

In addition, it will be possible to transmit voice messages, make calls - this additionally requires a microphone and an external speaker. Installing a SIM card will allow the Arduino to be used in cellular or GPRS mode.

How to connect modules to arduino

Before connecting the GSM module to the Arduino in its slot, you should install a suitable SIM card size of one of the mobile operators. After that, the module is connected to the Arduino hardware platform in accordance with the instructions and its firmware is performed. For this purpose, a PC is used, which is connected to the device using a USB cable. After loading the Arduino environment, press the Upload button, which will start the software upload process. Upon completion of this process, the platform can be disconnected from the computer and powered by an external power system.

Comparative characteristics of GSM modules

The consumer market offers a wide selection of different GSM modules for Arduino. Below are the main characteristics of the most popular.

Neoway M590

Arduino GSM module M590 is a wireless communication device used to receive and transmit information in mobile networks. The module of this series is created on a board with minimal strapping and is positioned as a GSM module for the Arduino hardware platform.

Using this device, you can establish mobile communication with an external phone, send SMS messages, exchange information according to the GPRS Class-10 standard. The module of this design does not have a microphone input, which limits the ability to receive voice communication - a connection can be established, but sound will not be transmitted.

The M590 is controlled by AT commands via serial communication. Frequencies from 900 MHz to 1800 MHz are used as working radio frequencies. The supply voltage is in the range of 3.3 ... 5 V. Therefore, the Neoway M590 GSM module is connected to the Arduino through a special voltage converter 5 V "3.3 V.

GSM module SIM800L

The compact Sim800l GPRS GSM module belongs to devices that are used to support mobile communications. The module is based on the SIM-800L meringue, created by SIMCom Wireless Solutions and is designed to provide services to the services of information networks GPRS \\ GSM, using frequencies from 850 MHz to 1900 MHz. It can be used to send SMS-messages, make calls, and exchange information via GPRS-channels.

The GSM module is completed with an antenna; if you need to improve the signal level, you can use additional antennas. To control the module, a PC can be used, connected via a special board for converting USB-UART interfaces or directly through the UART itself. If using Sim800l GPRS GSM module , connection to Arduino must be realized through a logic level converter. This is due to the fact that in SIM800L the voltage value at a logic high level is 2.8 V, and in Arduino - 3.3 ... 5 V.

GPRS Shield by Seeed Studio

Connecting the GSM module to the Arduino will provide the ability to use GSM / GPRS data exchange technologies, as well as make calls and send SMS messages. Devices of this type are built using the SIMCom SIM900 module. They have a slot for installing a SIM card, a connector for connecting an external antenna, a set of 3.5 mm jacks for audio input and output. The Arduino GSM Shield is controlled and operated using Serial connections and a set of specialized AT commands.

This module is a special board used to control digital devices remotely, as well as to exchange information. The use of SIM900 allows Arduino to work on GSM / GPRS technologies, providing voice communication, sending SMS and data exchange using cellular and mobile networks.

For the operation of this module, a control controller, a power source, an antenna are connected to it, and a SIM card of a mobile operator is also installed. Using special jumpers, the method of data exchange with the controller is configured. If necessary, you can connect a speaker and microphone.

Shield GPRS / GSM SIM900 with antenna
SIM900 GPRS / GSM Shield Development Board Quad-Band Kit For Arduino Compatible

A module for the operation of microcontroller devices Arduino and similar in cellular networks using GSM and GPRS standards. Designed for use in automation and control systems. Data exchange with other modules occurs via the UART interface. Shield GPRS / GSM SIM900 with antenna can interface directly with the microcontroller via the UART interface or work in conjunction with a personal computer using a PC-UART interface converter. This is possible due to software compatibility at the level of the class of commands used to control modems - AT commands.
Objects are monitored and managed through the exchange of data within the range of mobile communications. Provides voice communication, sending SMS, MMS and many other functions and services. The module is based on the SIM900 component.

An article in Russian from the magazine about the SIM900 component. The component was developed by SIMCom Wireless Solutions. The SIMCom website has a Russian-language version. The GSM module board on the component side contains connectors for connecting an antenna, headphones and a microphone. On the soldering side of the board, there is a 3-volt CR1220 battery holder that supports the operation of the module clock and a container for installing a sim card.
One of the applications of the device is a tracking system for vehicle movements in conjunction with a GLONASS or GPS device. Sending SMS messages allows the module to be used in dispatching, wireless signaling and security systems. As a result of the events taking place, various SMS can be sent: “Emergency stop of elevator 2 of house No. 34”, “Car door open”, “Basement open”, “Voltage 220 V off”, “Front door of the cottage is open”, “Lighting is on”, “ The temperature in the greenhouse is below critical. ” The module is indispensable for monitoring and controlling moving objects moving over long distances. Or in the case of moving the operator a long distance from a stationary object.

Shield GPRS / GSM SIM900 with antenna provides ample opportunities to study the operation of the SIM900 component. The installation of the SIM900 component is carried out using the most modern technologies, which makes it very difficult to solder to the SIM900 printed circuit board in laboratory conditions. Having a module with SIM900 installed, you can experiment with using the SIM900 component. When using the SIM900 component in our own development, it becomes possible to debug software and check circuit solutions.

Specifications

Nutrition
voltage, V
nominal 5
range 4.8-5.2
current
normal mode 50-450 mA
in sleep mode 1.5 mA
limiting impulse 2 A
Supports sim cards with 1.8 and 3 V power supply
Communication ranges 850, 900, 1800, 1900 MHz
Supports 2G network
Transmission power in different bands
1W 1800 and 1900 MHz
2W 850 and 900 MHz
Compliant with GSM Phase 2/2 +
Built-in TCP and UDP protocols
Data transmission class GPRS multi-slot class 10/8
Audio codecs HR, FR, EFR, AMR, echo cancellation
CSD up to 14.4kbps
PPP stack
MUX (07.10)
HTTP and FTP protocols
It is possible to send DTMF signals and play records as on an answering machine
RTC support
Temperature, ℃
air during operation -30 ... 75
storage -45 ... 90
dimensions 86 x 58 x 19 mm

Control components

The Power select switch sets the power supply: external, connected to the coaxial connector or the power supply of the Arduino microcontroller module.

The Power key turns the power on or off when pressed and held for 2 seconds.

Indication

The module status is indicated by 3 LEDs:
PWR (green) - module power indicator,
Status (red) - power indicator of SIM900 component,
Net Light (green) - network connection.
Net Light LED messages.
Off - SIM900 is not working.
Flashing at intervals, indicated in seconds:
0.064 on and 0.8 off - no network detected,
0.064 on and 0.3 off - network detected,
0.064 is enabled, 0.03 is disabled - GPRS is connected.

Contacts

The SIM900 component contains a UART port, its signals are output to the component pins and are connected to jumpers that establish with which contacts of the Shield GPRS / GSM SIM900 module the UART port of the SIM900 component will be connected to D0, D1 or D7, D8.
UART Shield GPRS / GSM can be connected: to the hardware interface of the MK through the TXD and RXD pins of the Shield GPRS / GSM module, for this, D0, D1 are used. Or to the software emulated by means of arduino, for this, contacts D7 and D8 of the Shield GPRS / GSM module are used. The full UART interface has 10 signals pins in the corner of the board: R1, DCD, DSR, CTS, RTS, GND, 2V8, TX, RX, DTR.
The 12 signed GPIO digital I / O pins are located in the corner of the board. There are 2 PWM outputs PWM1, PWM2. ADC input pin ADC. The built-in time counter interface has 4 pins. Pin designation: DISP_CLK, DISP_DATA, DISP_D / C, DISP_CS.
Contact D9 is used for software control of switching the SIM900 on or off.
An antenna connector is installed on the board.

Pin assignment of component SIM900.

External power on and off

You can turn on or turn off the power supply of the module using a signal at the control input D9. To change the state, a 1 s pulse is sent to D9. The change in state occurs 3.2 s after the start of the pulse.

Enabling the module. Graphs of the module supply voltage, external control pulse and STATUS power indicator.

When the module is controlled by the master device, it should be turned on without using the Power key, i.e. immediately after power is applied. 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 be used to turn off the module. You can also turn off the GSM module by sending an AT command.

Connecting GSM SIM900A to Arduino
The SIM900A modem is built with a dual-module GSM900 / GSM modem SIM900A from SIMCOM. It operates at 900/1800 MHz. SIM900A can search these two bands automatically. Frequency bands can also be set using AT commands. The baud rate is configurable in the range 1200-115200 by AT command. The GSM / GPRS modem has an internal TCP / IP stack so that you can connect to the Internet via GPRS. SIM900A is an ultra-compact and reliable wireless module. It is a full-fledged GSM / GPRS module in SMT type, designed with a very powerful single-chip processor integrating the AMR926EJ-S core, allowing you to use small size and cost-effective solutions.

Specification

Dual-band frequencies 900/1800 MHz

GPRS multi-slot class 10/8 GPRS for class B mobile stations

Corresponds to GSM phase 2/2 +

Dimensions: 24 * 24 * 3mm

Control via AT commands (GSM 07.07, 07.05 and SIMCOM with extended AT commands)

Supply voltage range: 5V

Low power consumption: 1.5mA (sleep)

Working temperature: -40 ° C to +85 °

Step 1: elements

In this article, you will need:

1. GSM SIM900A (MINI V3.9.2)
2. Arduino Uno board
3. Jumpers
4. Power adapter 5V
5. SIM card
6. Development board

1. Insert the SIM card into the GSM module and lock it.
2. Power on your GSM receiver by connecting it to 5V and GND
3. Connect the antenna

4. Now wait a while (say 1 minute) and watch the "Status LED" or "Network LED" (D6) blink. // It will take some time to establish a connection to the mobile network //

5. When the connection is successful, the status / network indicator will flash continuously every 3 seconds. You can try to call the mobile number of the SIM card inside the GSM module. If you hear a call, the gsm module has successfully established a network connection.

Step 3: Connection diagram



You can see TTL pin with 3VR, 3VT, 5Vr, 5VT, VCC and GND on your sim900a near your power pin. You need to connect 5VT GSM to Arduino D9 and 5VR to Arduino D10 for serial communication between arduino and sim900a module.

Step 4: Basic AT Commands

1. To change the SMS sending mode: AT + CMGF \u003d 1

MySerial.println ("AT + CMGF \u003d 1");

2. To read SMS in text mode: AT + CNMI \u003d 2,2,0,0,0

MySerial.println ("AT + CNMI \u003d 2,2,0,0,0");

3. To call: ATD + 60XXXXXXXXX; // replace X with the number you want to call, change +60 to the country code

MySerial.println ("ATD + 60XXXXXXXX;");

4. Disable / Disable: ATH

MySerial.println ("ATH");

5. Redial: ATDL

MySerial.println ("ATDL");

6. To receive a phone call: ATA

MySerial.println ("ATA");

Step 5: Library


SoftwareSerial is an Arduino library that allows serial data transfer through other Arduino digital pins. The library replicates hardware functions and performs the serial communication task. To be able to link the gsm module with the arduino, you will need to download this library and extract it into your Arduino libraries.
Download file: (Downloads: 240)

Step 6: Sample source code




Download the source code for the example below and open it on your Arduino IDE. Select your board and port and upload it to your Arduino Uno board.
Download file: (Downloads: 405)

Step 7: Serial Monitor



Once you have successfully downloaded the source code, open your serial monitor. The serial monitor will be displayed as shown in the picture above.

Step 8: Result: Call / Redial




1. When you enter the c: key to make a call, gsm will read the ATD command and make a call to the phone number you downloaded into the source code.


2. When you enter the h: key to disconnect / talk, gsm will read the ATH command and disconnect the connection.


3. When you enter the e: key to redial, gsm reads the ATDL command and redials the previous number it called


4. When there is an incoming call, you can see the RING printed on the serial monitor, and you can press i: to receive the call, and the ATA GSM command will be executed and you will be connected to the call connection.

Step 9: Result: sending and receiving SMS





1. Enter the key to send SMS. Recipient's number and text message printed on the serial monitor. NOTE. You can edit the recipient's phone number and text message in the source code.

2. When gsm receives the message, the text message and number will be printed on the serial monitor.


Translation of the article "

Review of GSM / GPRS SIM900 Shield board

The Arduino GPRS / GSM Shield board (Figure 1) provides us with the ability to use mobile GSM communication to remotely receive and transmit data. This can be done in three ways:

    using sending / receiving short text messages (SMS);

    sending voice (audio) commands based on CSD (standard GSM data transmission technology) and / or DTMF (two-tone multi-frequency analog signal used to dial a telephone number);

    using packet data transmission based on GPRS technology.

    The board is based on SIMCom SIM900 module.

It also contains:

    sIM card slot;

    3.5 mm jack for audio input and output;

    connector for an external antenna.

Communication with the board is carried out through a serial connection using a set of AT commands. With the help of jumpers on the board, it is possible to set the contacts used for communication: hardware contacts 0-1 or 2-3 (on some boards) 7-8 for work via SoftwareSerial.

Figure 1. GPS GPRS shield.

The GSM GPRS SIM900 Shield board can be enabled in two ways:

    hardware (pressing the PWRKEY button);

    software.

Connecting to Arduino board

The GSM GPRS SIM900 Shield is made in the Shield format for Arduino boards. The contacts of the shield (combs) are easily inserted into the board connectors, thus forming a "sandwich" (Figure 2).


Figure 2. Installing the GPS GPRS shield on the Arduino board.

Controlling the GSM GPRS SIM900 module using AT commands

Consider controlling the GSM GPRS shield module using AT commands. To do this, install the module on and connect it to the computer. An Arduino sketch of sending and receiving data between the computer and the GSM GPRS shield via the board is shown in Listing 1.


Listing 1

#include

// create object

SoftwareSerial grs (7, 8); // RX, TX

// exchange rate

#define GSMbaud 9600

Serial.begin (9600);

gsm.begin (GSMbaud);

Serial.println ("Start");

if (Serial.available ()) (

str1 \u003d Serial.readStringUntil ("\\ n");

str1.toCharArray (buffer, hh.length () + 1);

gsm.write (buffer);

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

if (gsm.available ()) (

Serial.write (gprs.read ());

Load the sketch onto the arduino board, open the serial port monitor and type in the mode setting commands:

The command for checking the module's connection to the GPRS network, which must be repeated constantly when you answer COMMAND NO RESPONSE

We connect to the operator's access point. For Beeline:

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

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

Internet connection setup:

AT + CGACT \u003d 1.1

Referring to the Internet resource

The entire connection process is shown in Figure 3.


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

An example of sending sms messages from the Arduino board

Let's consider an example of using sending sms messages when the room temperature drops below a certain value. We need the following details:

    gSM GPRS Shield module - 1 pc;

    sIM card of a mobile operator with a positive balance;

    power supply unit 12V - 1 piece;

The connection diagram is shown in Figure 4.


Figure 4. Connection diagram for sending sms messages at low air temperatures.

Let's start writing a sketch. Every 30 seconds, we receive humidity and temperature data from the DHT11 sensor. We use the DHT library. If the temperature is below the critical one, we 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"

// phone for sending sms

#define PHONE_NUMBER "+7928222222"

// create objects

SoftwareSerial gsm (7, 8);

DHT sensorDHT (2, DHT22);

// temperature threshold

#define TEMPP 18

unsigned long millissend;

// start the serial port

Serial.begin (9600);

// start DHT sensor

sensorDHT.begin ();

// start SoftwareSerial

gsm.begin (9600);

if (millis () - millissend\u003e 30 * 1000) (// readings every 30 seconds?

// get data from DHT sensor

int h \u003d sensorDHT.readHumidity ();

int t \u003d sensorDHT.readTemperature ();

if (t

// send sms

// wait 10 minutes

delay (10 * 60 * 1000);

millissend \u003d millis ();

// send sms

void SendSMS (int t) (

// set text mode

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

// phone

gsm.println (PHONE_NUMBER);

gsm.println ("\\" ");

// send data t

// end of transfer

gsm.println ((char) 26);

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


Figure 5. Assembly diagram.

Let's create a firmware for receiving data when sending an SMS message to the 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"

// create objects

SoftwareSerial gsm (7, 8);

DHT sensorDHT (2, DHT22);

// variables

String phone \u003d ""

String str1 \u003d ""; //

boolean isSMS \u003d false;

// connect the serial port

Serial.begin (9600);

// start DHT sensor

// start SoftwareSerial

gsm.begin (9600);

// Configuring message reception

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 line - sms message,

if (! str1.compareTo ("tmp")) (// text sms - tmp

// send sms to the incoming number

// get data

int t \u003d dht.readTemperature ();

// AT command to set text mode

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

// recipient's phone number

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

gsm.println (phone);

gsm.println ("\\" ");

// message - temperature data

// end of transfer

gsm.println ((char) 26);

Serial.println (currStr);

if (str1.startsWith ("+ CMT")) (

Serial.println (str1);

// extract the phone number from the message

phone \u003d str1.substring (7,19);

Serial.println (phone);

// if the current line starts with "+ CMT",

// then the next line is the message

else if ("\\ n"! \u003d c) (

str1 + \u003d String (c);

We load the sketch onto the board, send an SMS message with the text tmp to the sim card and receive an SMS message with temperature data in response.

Frequently Asked Questions FAQ

1. There is no communication with the Arduino via the serial port.

    Check board power supply.

    Check if the jumpers are set correctly.

2. SMS messages are not sent

    Check for external power supply GSM GPRS shield.

    Check your SIM card balance.

Did you like the article? To share with friends: