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.
Command | Response | Description |
AT | OK | ping the module to check the status. |
AT+CPIN | +CPIN:READY | Check if the SIM card is ready to make calls, messages, or to start the data packet transmission. |
AT+CREG | OK | Regarding APN(Access Point Name) of the Sim card. |
AT+CGATT | OK | Attach and De-attach the device to package domain service. |
AT+CIPSHUT | OK | Closes the PDP context and resets the IP address. |
AT+CIPSTATUS | OK | To check whether the device is connected or not, |
AT+CSTT= “APN of Sim-Card”, “Username”, “Password” | OK | Access 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+CIICR | OK | Bring up the wireless communication. |
AT+CIFSR | OK | Gives local IP Address. |
AT+CIPSTART | OK | Establish a secured connection with the URL as per the protocols. |
AT+CIPSEND | OK | Using the GET method and the HTTP protocol sends the data to the server via URL. |
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
- Sensor – It measures the specific parameters which are included in the datasheet, for example, DHT11 measures the Temperature and the Humidity of the atmosphere.
- Microcontroller – It collects the data from the sensor, process that data and send that acquired data to the web server via IoT device.
- 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.
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.