In this tutorial, I will be introducing the Ai-Thinker A7 module, as well as presenting some guidelines on how to use AT commands to send and receive SMS (Short Message Service) through this device.
- Ai-Thinker A7 module;
- SIM Card for the A7 module;
- Serial-to-USB converter;
- MicroUSB-to-USB cable;
- Some jumper wires;
- Computer with Putty installed;
- Mobile phone with SIM card;
Ai-Thinker A7 module
A7 is a 3-in-1 module from Ai-Thinker that is controlled by AT commands via UART and supports 3.3V and 4.2V logical levels. It supports GSM/GPRS Quad-Band (850/900/1800/1900) network. Also, it supports SMS messages, voice calls, GPRS data service (maximum of 85.6 kbps download speed and 42.8 kbps upload speed), GPS and AGPS functions. You can use it to make a simple phone.
This module is available on some development boards with slightly different configurations with an average cost of 10€.
AT are commands that can be used to control a modem. They are called AT commands because the characters AT must precede each command to get the ATtention of the modem. There are two types of AT commands: basic commands and extended commands. Basic commands are AT commands that do not start with “+”. For example, D (Dial), A (Answer), H (Hook control) and O (Return to online data state) are basic commands. Extended commands are AT commands that start with “+”. I will be introducing the AT commands according to the needs of each tutorial, but you can find plenty of information available online.
Sending and Receiving SMS
Insert an unlocked SIM card in the A7 SIM card slot and connect the GSM antenna. Connect the USB to Serial converter to the A7 module according to the following image.
Supply power to the A7 module using a MicroUSB-to-USB cable connected to either a computer USB port or other power supply. Connect the USB to Serial converter to your computer and open the Putty terminal. Press the “POWER” button for 2 or 3 seconds and when you leave it the red “LED1” should be turned on.
Before opening the Putty terminal set your baud to 115200, and the correct COM port to which your converter is connected. First, you need to check if AT commands are working – enter AT” and press Enter key. This should print “OK” which means correct connection and operation of the module. Second, you need to set the module to SMS mode – enter “AT+CMGF=1” and press Enter key, this should print “OK”. Third, set the module to send SMS data to serial out upon receipt – enter “AT+CNMI=2,2,0,0,0“, this should print “OK”. In order to send an SMS from the A7 to your mobile phone enter AT+CMGS=”+351999999999″, using you country prefix and the phone number you want to send the SMS. Finally, you need to write your message after the “>” and end the AT command with a ^Z (keyboard CTRL+Z). Check your phone!