How to use a GSM/GPRS Module as an IoT device?

by Nov 30, 2020Communication Protocols

The convergence of physical objects and the digital world is known as IoT. IoT stands for the Internet of Things. It has been a trending field in the world of technology. In addition, the IoT describes the network of physical objects known as “things” that are embedded with sensors, software, and other technologies for the purpose of connecting and exchanging data with other devices and systems over the internet. IoT based devices, for instance, ESP8266, GSM/GPRS Module, and ESP32 are available to achieve IoT.

For more information : IoT

GSM/GPRS Module

GSM stands for Global System for Mobile Communication and GPRS is an acronym for General Packet Radio Service. GSM is a Wireless Communication standard for mobile telephone systems and GPRS is an extension of the GSM Network. GPRS is an integrated part of the GSM Network which provides an efficient way to transfer data with the same resources as GSM Network.

AT commands for GPRS Module

AT commands are instructions used to control a modem and is the abbreviation of Attention.

CommandResponseDescription
ATOKping the module to check the status.
AT+CPIN+CPIN:READYCheck if the SIM card is ready to make calls, messages, or to start the data packet transmission.
AT+CREGOKRegarding APN(Access Point Name) of the Sim card.
AT+CGATTOKAttach and De-attach the device to package domain service.
AT+CIPSHUTOKCloses the PDP context and resets the IP address.
AT+CIPSTATUSOKTo check whether the device is connected or not,
AT+CSTT=
“APN of Sim-Card”, “Username”, “Password”
OKAccess Point Name, User name, and Password need to be set before data connectivity can be established. Use the APN name of your SIM card provider. For most service providers PIN and Password are not set.
AT+CIICROKBring up the wireless communication.
AT+CIFSROKGives local IP Address.
AT+CIPSTARTOKEstablish a secured connection with the URL as per the protocols.
AT+CIPSENDOKUsing the GET method and the HTTP protocol sends the data to the server via URL.
AT commands to establish a stable connection with the web server

Using AT commands we can get the status and feedback of the GSM/GPRS module. in addition, it is also used to make a connection with any URL and subsequently, data transmission will take place.

IoT using GSM/GPRS Module

There are three major elements required to do IoT using GSM/GPRS Module.

Block-diagram

Block diagram

  1. Sensor – It measures the specific parameters which are included in the datasheet, for example, DHT11 measures the Temperature and the Humidity of the atmosphere.
  2. Microcontroller – It collects the data from the sensor, process that data and send that acquired data to the web server via IoT device.
  3. GSM/GPRS Module – It renders the facility to establish a stable connection with a web server like Thingspeak, AWS, etc.

DHT11 and GSM/GPRS module interfacing with Arduino UNO

DHT11 will measure temperature and humidity. Arduino UNO collects that data and using serial communication will send that data to the Thingspeak server using GSM/GPRS Module.

Circuit diagram

More about Web server: Thingspeak

Source code

#include <SoftwareSerial.h>
SoftwareSerial gprsSerial(2,3);
 
#include <String.h>
#include <DHT.h> 
 
#define DHTPIN D8
 
DHT dht(DHTPIN, DHT11);
 
void setup()
{
  gprsSerial.begin(9600);               // the GPRS baud rate   
  Serial.begin(9600);    // the GPRS baud rate 
  dht.begin();
 
  delay(1000);
}
 
void loop()
{
      float h = dht.readHumidity();
      float t = dht.readTemperature(); 
      delay(100);   
         
      Serial.print("Temperature = ");
      Serial.print(t);
      Serial.println(" °C");
      Serial.print("Humidity = ");
      Serial.print(h);
      Serial.println(" %");    
      
   
  if (gprsSerial.available())
    Serial.write(gprsSerial.read());
 
  gprsSerial.println("AT");
  delay(1000);
 
  gprsSerial.println("AT+CPIN?");
  delay(1000);
 
  gprsSerial.println("AT+CREG?");
  delay(1000);
 
  gprsSerial.println("AT+CGATT?");
  delay(1000);
 
  gprsSerial.println("AT+CIPSHUT");
  delay(1000);
 
  gprsSerial.println("AT+CIPSTATUS");
  delay(2000);
 
  gprsSerial.println("AT+CIPMUX=0");
  delay(2000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CSTT=\"airtelgprs.com\"");//start task and setting the APN,
  delay(1000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIICR");//bring up wireless connection
  delay(3000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIFSR");//get local IP adress
  delay(2000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSPRT=0");
  delay(3000);
 
  ShowSerialData();
  
  gprsSerial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//start up the connection
  delay(6000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSEND");//begin send data to remote server
  delay(4000);
  ShowSerialData();
  
  String str="GET https://api.thingspeak.com/update?api_key=O13AOCHYYNU2LQ19&field1=" + String(t) +"&field2="+String(h);
  Serial.println(str);
  gprsSerial.println(str);//begin send data to remote server
  
  delay(4000);
  ShowSerialData();
 
  gprsSerial.println((char)26);//sending
  delay(5000);//waitting for reply, important! the time is base on the condition of internet 
  gprsSerial.println();
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSHUT");//close the connection
  delay(100);
  ShowSerialData();
} 
void ShowSerialData()
{
  while(gprsSerial.available()!=0)
  Serial.write(gprsSerial.read());
  delay(5000); 
  
}

GSM/GPRS module uses an access point via a sim card. Using related protocols it initiates a stable connection with any website. It is used to make a portable and movable IoT-based device to send the data to a specific web server and access via anywhere in the world.

Creating a multiplication Skill in Alexa using python

Written By Monisha Macharla

Hi, I'm Monisha. I am a tech blogger and a hobbyist. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning!

RELATED POSTS

Longwave Wireless Communication

Longwave Wireless Communication

Longwave wireless communication acts as a foundation for a Low power Wide Area Network. Mostly low energy is consumed in these types of networks. The reason is that most sensors are used for extracting data. These data are used for transmitting in long-range...

Architecture of a Bluetooth IoT Application

Architecture of a Bluetooth IoT Application

What is Bluetooth? To understand the architecture of Bluetooth first lets understand what actually Bluetooth is. Bluetooth is a radio-wave technology that is mainly designed to enable wireless communications over short distances. The frequency of these waves ranges...

Most Commonly Used Web Frameworks

Most Commonly Used Web Frameworks

Web Frameworks are software frameworks that are designed to help create Web apps, Web APIs and other resources. Web Frameworks help us solve two of the major hurdles of developing web apps - templates and routing. Now that we know what web frameworks are, lets get...

Communication between XBee modules

Communication between XBee modules

The wireless networking device, XBee is a user friendly, popular and is a technology worth knowing about. It can transmit and receive data wirelessly, and thus can be used for many IoT applications. As the popularity of the XBee module has grown massively, there are...

Role of WiFi in IoT

Role of WiFi in IoT

Internet of Things(IoT) applications has diverse connectivity requirements in terms of range, data throughput, energy efficiency, and device cost. WiFi is often an obvious choice in-building WiFi coverage is almost ubiquitous. It is not always an appropriate...

VIDEOS – FOLLOW US ON YOUTUBE

EXPLORE OUR IOT PROJECTS

IoT Smart Gardening System – ESP8266, MQTT, Adafruit IO

Gardening is always a very calming pastime. However, our gardens' plants may not always receive the care they require due to our active lifestyles. What if we could remotely keep an eye on their health and provide them with the attention they require? In this article,...

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

All you need to know about integrating NodeMCU with Ubidots over MQTT

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

All you need to know about integrating NodeMCU with Ubidots over Https

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

Sending Temperature data to ThingSpeak Cloud and Visualize

In this article, we are going to learn “How to send temperature data to ThingSpeak Cloud?”. We can then visualize the temperature data uploaded to ThingSpeak Cloud anywhere in the world. But "What is ThingSpeak?” ThingSpeak is an open-source IoT platform that allows...

Amaze your friend with latest tricks of Raspberry Pi and Firebase

Introduction to our Raspberry Pi and Firebase trick Let me introduce you to the latest trick of Raspberry Pi and Firebase we'll be using to fool them. It begins with a small circuit to connect a temperature sensor and an Infrared sensor with Raspberry Pi. The circuit...

How to implement Machine Learning on IoT based Data?

Introduction The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data....

Smart Display Board based on IoT and Google Firebase

Introduction In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD. Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are...

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....