How to set up smartphones and PCs. Informational portal
  • home
  • news
  • Sending SMS via Arduino and GSM module NEOWAY M590.

Sending SMS via Arduino and GSM module NEOWAY M590.

I want to introduce you to a very simple way to control power supply remotely.
We will use ready-made radio-controlled sockets, so we don't need to solder anything. This is very cool, because 220V (for beginners) is better left alone.

The code

If you are using not GSMSHIELD, but some other library, then the code of course will be different, but the principle will be the same. At certain time intervals, we check if we have unread SMS, parse them, and if a valid command came from an authorized number, then we send a radio signal using the mySwitch.switchOff or mySwitch.switchOn functions, passing them the socket address.
Approx. In my case, for the Seeedstudio shield, I had to go into GSM.cpp and change the set pins to 7 and 8./ * Arduino GSM-switch example code Switch on / off radio controlled controlled outlets Author: Vladislav Ross, 2014 Contact: [email protected] You need to download: 1. rc-switch https://code.google.com/p/rc-switch/ 2. GSMSHIELD http://www.gsmlib.org/ For GSMSHIELD: * To change pins for Software Serial, use the two lines in GSM.cpp. * If you are using Mega, uncomment "#define MEGA" line in HWSerial.h * You can enable debug messages on serial port by defining DEBUG_ON * / #include "SIM900.h" #include #include "sms.h" #include "call.h" #include // 433MHz transmitter pin const byte RCpin = 12; char groupAddress = "11111"; char smsLetters = "ABC"; char * deviceAddresses = ("10000", // A "01000", // B "00100" // C); char adminNumber = "+74991356235"; // your phone number CallGSM call; SMSGSM sms; RCSwitch mySwitch = RCSwitch (); char number; byte stat = 0; char smsText; byte position; int deviceLetterIdx = -1; byte i, j; void setup () (gsm.begin (2400); delay (10000); for (i = 1; i<= 21; i++) { sms.DeleteSMS(i); } mySwitch.enableTransmit(RCpin); }; void loop() { //hang up all incoming calls /*stat=call.CallStatus(); if(stat==CALL_INCOM_VOICE) { call.HangUp(); }*/ position = sms.IsSMSPresent(SMS_UNREAD); //get new SMS if (position) { sms.GetSMS(position, number, smsText, 10); sms.DeleteSMS(position); if(strcmp(number, adminNumber) == 0) //accept SMS only from defined number { for (i = 0; i < sizeof(smsText) - 1; i++) { if(deviceLetterIdx != -1) { //got letter, now expecting 0 or 1 if(smsText[i] == "0") { mySwitch.switchOff(groupAddress, deviceAddresses); delay(500); } if(smsText[i] == "1") { mySwitch.switchOn(groupAddress, deviceAddresses); delay(500); } deviceLetterIdx = -1; } else { //waiting for letter A,B,C... for(j = 0; j < sizeof(smsLetters) - 1; j++) { if(smsLetters[j] == smsText[i]) { deviceLetterIdx = j; break; } } } } } } delay(10000); }; GitHub .

Problems?

If the sockets do not want to switch to any one, you can try to receive a signal from your own remote control to the receiver. There is a sample code in rc-switch.

What's next?

How can this project be further developed:
Firstly, we still have a bunch of pins left on the Arduino itself and on the GSM shield. You can connect some sensors or devices to them. For example, do remote monitoring of temperature or watering flowers.
Secondly, we used only SMS, and the module can still transmit voice and GPRS. GPRS can transfer much more data. In addition, you can not hang up the phone when you call, but, for example, take a call and let you listen to what is happening on the spot.
It is also possible that you want to receive control SMS not from one number, but from several. In this case, I would recommend storing numbers in the address book in the library there are corresponding functions.

An article for those who want to force Arduino to send SMS through this GSM module ... The NEOWAY M590 module based on the SIM900 chip is suitable for creating a home-made alarm, smart home. There is also an alternative GSM module that connects directly to the Arduino via 5 Volts: Sim800L EVB v2.0

Formulation of the problem

  • Using only Arduino and GSM module, control the LED through a phone call.
  • Send SMS (while through the command coming through the port monitor to the Arduino IDE)

Connecting to Arduino

We connect the GSM module to the Arduino.
5V module -> 5V Arduino
GND module -> GND Arduino
TX module -> digital pin2 Arduino
RX module -> digital pin3 Arduino
You can see the pinout in the photo. The order of contacts is as follows: 1 - + 5V, 2 - GND, 7 - TX, 8 - RX.


You can power the module from 4V to 5V, I used a 5 volt output.

The module requires a separate power supply, because it consumes up to 2A peak. The capacitor will most likely not save you. Therefore, when powered from Arduino, it may not work or be buggy.

The ground of Arduino and the GSM module must be connected with separate power supply, but first you need to measure the voltage between these "grounds" with a multimeter. Some computer power supplies have a voltage drop of up to 100V across the USB chassis and ground. The current there is scanty and cannot kill, but it is easy to destroy the Arduino or the GSM module, or both.

Sketch

#include< SoftwareSerial... h> SoftwareSerial mySerial (2, 3); // RX, TX int ch = 0; int led = 13; String val = ""; void setup () (
delay (2000); // time to initialize the module pinMode (led, OUTPUT); digitalWrite (led, LOW); Serial... begin (9600); // port speed Serial... println ("GSM tester v1.0"); mySerial. begin (9600); mySerial. println ("AT + CLIP = 1"); // turn on AON delay (100); mySerial. println ("AT + CMGF = 1"); // SMS encoding mode - normal (for English) delay (100); mySerial. println ("AT + CSCS = \" GSM \ ""); // text encoding mode delay (100); ) void loop () (if (mySerial. available ()) ( // if the GSM module has sent something to us, then while (mySerial. available ()) ( // save the input string to the variable val ch = mySerial. read (); val + = char (ch); delay (10); ) if (val. indexOf ("RING")> - 1) ( // if a call is found, then check the number if (val. indexOf ("71234567890")> - 1) ( // if the caller's number is ours. Enter your number without "+" Serial... println ( "--- MASTER RING DETECTED ---"); mySerial. println ("ATH0"); // break the connection digitalWrite (led, HIGH); // turn on the LED for 3 sec delay (3000); digitalWrite (led, LOW); // turn off the relay)) else Serial... println (val); // print the received line to the port monitor val = ""; ) if ( Serial... available ()) ( // if something is entered in the port monitor while ( Serial... available ()) ( // save the string to the variable val ch = Serial... read (); val + = char (ch); delay (10); ) //mySerial.println(val); // transfer of all commands typed in the port monitor to the GSM module if (val. indexOf ("sendsms")> - 1) ( // if you saw the command to send SMS sms (String ("hello world"), String ("+71234567890")); // send SMS to the number +71234567890) val = ""; // clear)) void sms (String text, String phone) // procedure for sending SMS { Serial... println ("SMS send started"); mySerial. println ("AT + CMGS = \" "+ phone +" \ ""); delay (500); mySerial. print (text); delay (500); mySerial. print ((char) 26); delay (500); Serial... println ("SMS send complete"); delay (2000); )

Examination


GPRS

In the considered version of the 1.30 module, the GPRS support is cut down. I was unable to connect to the server by its DNS name (for example mysite.ru), it turned out only by the IP address. There were no such problems in another SIM800L module.

List of some AT commands:

Over the past decade, car thefts have occupied one of the most important places in the structure of crimes committed in the world. This is due not so much to the specific weight of this category of theft in relation to the total number of crimes, but to the significance of the damage caused due to the high cost of cars. The weak effectiveness of the measures taken in the field of combating vehicle theft by the end of the 90s led to the creation of stable groups specializing in the commission of these crimes and having the distinctive features of organized crime; you've probably heard the term "black auto business". The car park of European countries is annually missing ≈ 2% of cars that become the subject of criminal encroachments. Therefore, I got the idea to make a gsm alarm for my car based on Arduino Uno.

Let's get started!

What will we collect

We must choose the heart of our system. In my opinion, there is nothing better for such signaling than the Arduino Uno. The main criterion is a sufficient number of pins and a price.


Key features of Arduino Uno

Microcontroller - ATmega328
Working voltage - 5 V
Input voltage (recommended) - 7-12 V
Input voltage (limit) - 6-20 V
Digital Inputs / Outputs - 14 (of which 6 can be used as PWM outputs)
Analog Inputs - 6
DC current through input / output - 40 mA
DC current for 3.3 V pin - 50 mA
Flash Memory - 32KB (ATmega328) of which 0.5KB is used for bootloader
RAM - 2 KB (ATmega328)
EEPROM - 1 KB (ATmega328)
Clock frequency - 16 MHz


Fits!

Now you need to select a gsm module, because our alarm system should be able to notify the owner of the car. So, you need to google ... Here, an excellent sensor - SIM800L, the size is just wonderful.


I thought and ordered it from China. However, everything turned out to be not so rosy. The sensor simply refused to register the SIM card on the network. Everything that was possible was tried - the result was zero.
There were kind people who provided me with a cooler thing - Sim900 Shield. This is already a serious thing. The Shield has a microphone and headphone jack, a full-fledged phone.


Main features of Sim900 Shield

4 standards of working frequency 850/900/1800/1900 MHz
GPRS multi-slot class 10/8
GPRS mobile station class B
Compliant with GSM phase 2/2 +
Class 4 (2 W @ 850/900 MHz)
Class 1 (1 W @ 1800 / 1900MHz)
Controlled by AT commands (GSM 07.07, 07.05 and SIMCOM extended AT commands)
Low power consumption: 1.5mA (sleep mode)
Operating temperature range: -40 ° C to +85 ° C


Fits!

Ok, but you have to take readings from some sensors to notify the owner. Suddenly the car is evacuated, then the position of the car will obviously change in space. Let's take an accelerometer and a gyroscope. Fine. Dachshund, now we are looking for a sensor.

I think the GY-521 MPU6050 will definitely fit. It turned out that it also has a temperature sensor. It would be necessary to use it, there will be such a "killer feature". Suppose the owner of the car put it under the house and left. The temperature inside the car will change "smoothly". What happens if an intruder tries to break into a car? For example, he will be able to open the door. The temperature in the car will begin to change rapidly, as the air in the passenger compartment begins to mix with the ambient air. I think it will work.


Main features of GY-521 MPU6050

3-axis gyroscope module + 3-axis accelerometer GY-521 on the MPU-6050 chip. Allows you to determine the position and movement of an object in space, the angular velocity during rotation. It also has a built-in temperature sensor. It is used in various copters and aircraft models, it is also possible to assemble a motion capture system based on these sensors.

Microcircuit - MPU-6050
Supply voltage - from 3.5V to 6V (DC);
Gyroscope range - ± 250 500 1000 2000 ° / s
Accelerometer Range - ± 2 ± 4 ± 8 ± 16g
Communication interface - I2C
Size - 15x20 mm.
Weight - 5 g


Fits!

A vibration sensor is also useful. Suddenly, they will try to open the car with "brute force", or, in the parking lot, another car will touch your car. Take the vibration sensor SW-420 (adjustable).


Main features SW-420

Supply voltage - 3.3 - 5V
Output signal - digital High / Low (normally closed)
Used sensor - SW-420
Comparator used - LM393
Dimensions - 32x14mm
Additionally - There is an adjusting resistor.


Fits!

Screw on the SD memory card module. We will also write a log file.


Main characteristics of the SD memory card module

The module allows you to store, read and write to the SD card the data required for the operation of the device based on the microcontroller. The use of the device is relevant when storing files from tens of megabytes to two gigabytes. The board contains an SD card container, a card power stabilizer, a plug for the interface and power lines. If you need to work with sound, video or other volumetric data, for example, to keep a log of events, sensor data or store information from a web server, then the SD memory card module for Arduino will make it possible to use an SD card for these purposes. Using the module, you can study the features of the SD card.
Supply voltage - 5 or 3.3 V
SD card memory capacity - up to 2 GB
Dimensions - 46 x 30mm


Fits!

And let's add a servo, when the sensors are triggered, the servo with a video recorder will turn and shoot video of the incident. Take the MG996R servo.


Main features of MG996R servo

Stable and reliable protection against damage
- Metal drive
- Double row ball bearing
- Wire length 300 mm
- Dimensions 40x19x43mm
- Mass 55 gr
- Angle of rotation: 120 degrees.
- Working speed: 0.17sec / 60 degrees (4.8V no load)
- Working speed: 0.13sec / 60 degrees (6V no load)
- Starting torque: 9.4kg / cm at 4.8V power supply
- Starting torque: 11kg / cm at 6V power supply
- Working voltage: 4.8 - 7.2V
- All drive parts are made of metal


Fits!

We collect

There are a lot of articles about connecting each sensor in Google. And I have no desire to come up with new bicycles, so I will leave links to simple and working options.

You can also send SMS - messages, all you need is a special Arduino GSM / GPRS SIM900 module. This expansion board fits the common Arduino UNO, MEGA and Leonardo boards. With its help, you can make a bunch of different projects using GPRS Internet or access to the GSM network. It will work wherever there is a mobile network. Using this module, you can make a GSM alarm system, which, together with a video surveillance system, will provide excellent protection for your home.

The module allows using networks of standards GSM 850, GSM 900, GSM 1800, GSM 1900 and supports TCP protocol with access to the GPRS network.

Arduino GSM the SIM900 module can also be used to make calls, you can both receive calls and make them. To do this, the board has special connectors for connecting a microphone and a speaker. You can also connect the module to a computer and send and receive data directly from the PC. For example, you can do mass mailing to subscribers recorded on a sim card in an automatic mode.

Features of connecting the GSM board to the Arduino Leonardo and Arduino Mega boards

The GSM extension board works with Arduino directly thanks to the Software Serial library. With standard settings, digital pins No. 2 and No. 3 are connected for the modem to interact with the Arduino. These settings are suitable for the Arduino Uno, but for the correct operation of the shield on the Arduino Leonardo or Arduino Mega, it is necessary to make corrections.

GSM_TX pin, also called pin # 2 on the expansion board, sends information to Arduino. In order to know exactly at what moment it is necessary to read information, Arduino uses an interrupt mechanism: when the digital signal level changes, a corresponding interrupt occurs in this pin. However, in Arduino Leonardo and Arduino Mega pin # 2 does not support interrupts.

For the shield to function normally on the Arduino Mega or Leonardo, you do not need to change the program code at all, the library itself changes the number of the RX pin of the Arduino when you select the correct model in the "Tools" menu of the development environment.

Arduino Leonardo


For correct functioning with Leonardo, the GSM library uses digital pin No. 8. To do this, on the GSM expansion board, connect digital pins No. 2 and No. 8 with a conductor.

On the rear side of the GSM board, bend to the side the pin corresponding to pin # 2 so that it does not come into contact with the Arduino Leonardo.

Arduino Mega2560


The GSM library for the correct robots with Mega uses digital pin No. 10. On the GSM expansion board, it is necessary to close digital pins No. 2 and No. 10 with a conductor, as with Arduino Leonardo. Do not forget to bend at the same time from the back side of the GSM board towards the pin corresponding to pin No. 2, so that it does not touch the Arduino Mega.

Arduino is a hardware platform used to quickly create a variety of 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 along the protected perimeter, the opening of windows and doors, and damage to glass. In addition to security 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 using the Arduino language based on Wiring. Thanks to this, everyone can program the algorithm for the operation of the created burglar alarm as required for a specific protected object and the peculiarities 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. Specialized software Arduino 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 (earlier models) and with ATmega32u4, Atmel ATmega328 controllers (newer models), which are highly functional and reliable.

Principle of operation

To ensure the full-functional operation of security systems or other devices built using Arduino platforms, you need to have a GSM module for Arduino. It can be used to 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. The exchange of information 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 implemented 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 requires an additional 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, a suitable SIM card of one of the mobile operators must be installed in its slot. 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 has a wide selection of different GSM modules for Arduino. Below are the main characteristics of the most popular ones.

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

Compact Sim800l GPRS GSM module refers to devices that are used to support mobile communications. The module is built 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 implemented 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 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 using 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.

Top related articles

AT + CMGF = 1 Incl. text mode (SMS only in Latin)
AT + CSCS = "GSM" Incl. regime
AT + CLIP = 1 enable identification of the incoming call number
If you send a command with 0, the number identification will be disabled and the module will only send the "RING" message instead of the caller's number.
AT + CMGS = "+ 79123456789" Sending SMS
ATI Get device information
AT + IPR = 19200 port speed setting
AT + GSN will return the IMEI of the module
AT + CCLK? read the time from the module
AT + CCLK = "yy / mm / dd, hh: mm: ss + zz" where "year / month / date, hour: minutes: seconds + time zone" goes in order. Data must be sent with leading zeros, that is, for example, if the month we have is "4", then "04" must be sent.
You can get back the current time and date by sending the same command, only with the "?" Sign:
AT + CMEE = 0 error information level. It can be from 0 to 2.
0 - disabled. It will just write ERROR.
1 - error code. Will return a numeric error code.
2 - error description. He will write what exactly he does not like about the team.
To work with the module through the terminal, it is more convenient to use the ATV1, ATE1 AT + CMEE = 2 modes, to communicate with the microcontroller it is better to use ATV0, ATE0 and AT + CMEE = 0 - this will make it easier to process the received responses.
These settings are not saved after the module is rebooted, therefore it is necessary to include these commands in the program code.
AT + CSQ signal quality information.
The module will return two numbers + CSQ: 17.0
17 - signal level. It can be in the range 0..31 or 99. The more the better, but 99 means its absence.
0 - communication error rate (so-called RXQUAL). It can be from 0 to 7, the lower the number, the better the connection quality.
AT + COPS? information about the operator in whose network the module is registered
ATD + 79121234567; dialing a number. (";" necessarily)
The module will call the specified number and return one of the options
BUSY - the number is busy
NO DIALTONE - no signal on the line
NO CARRIER - no network or other problem (for example, there is no money in the account)
NA ANSWER - no answer
CONNECT - there is a contact!
AT + CMGR = 3.0