Reader small image

You're reading from  Learning C for Arduino

Product typeBook
Published inMar 2017
Reading LevelBeginner
PublisherPackt
ISBN-139781787120099
Edition1st Edition
Languages
Right arrow
Author (1)
Syed Omar Faruk Towaha
Syed Omar Faruk Towaha
author image
Syed Omar Faruk Towaha

Syed Omar Faruk Towaha is a data scientist, and currently working at Meta. He has two bachelor's degrees, one in Physics, another in Computer Science and a Master's in Data Science. He is based in London, England, and has interests in data science and IoTs. While Syed is not busy with his jobs, he uses his time to write something about new technologies. His recent publications include Building Smart Drones With ESP8266 and Arduino, Introduction to Rust Programming, Learning C for Arduino, and JavaScript Projects for Kids.
Read more about Syed Omar Faruk Towaha

Right arrow

Receiving an SMS


In this section, we will learn how we can receive an SMS using our GSM Shield and Arduino. We will display the SMS on the Serial Monitor.

To receive an SMS and display it on the Serial Monitor, we need to use the SoftwareSerial library. Receiving an SMS is simpler than sending an SMS. We just need to make the GSM Shield understand that the Shield is working and ready to receive a text.

To make the GSM Shield ready for receiving a text message, the command we should use is the following:

GSMSerial.println("AT+CNMI=2,2,0,0,0");

We can assign the received SMS to a string variable and print it on the Serial Monitor.

The full source code for receiving text messages is as follows:

#include <SoftwareSerial.h> 
SoftwareSerial GSMSerial(2, 3); 
void setup() { 
  String text; 
  Serial.begin(9600); 
  Serial.println("Warming Up the GSM Shield; Look at the Shield's LED"); 
  Serial.println(".........."); 
  Serial.println("..............."); 
...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning C for Arduino
Published in: Mar 2017Publisher: PacktISBN-13: 9781787120099

Author (1)

author image
Syed Omar Faruk Towaha

Syed Omar Faruk Towaha is a data scientist, and currently working at Meta. He has two bachelor's degrees, one in Physics, another in Computer Science and a Master's in Data Science. He is based in London, England, and has interests in data science and IoTs. While Syed is not busy with his jobs, he uses his time to write something about new technologies. His recent publications include Building Smart Drones With ESP8266 and Arduino, Introduction to Rust Programming, Learning C for Arduino, and JavaScript Projects for Kids.
Read more about Syed Omar Faruk Towaha