IOT

How to Send SIM800/900 GPRS Data to Thingspeak with Arduino: Cellular IoT

Nowadays, we utilize ESP8266, ESP32, or any other wifi module to wirelessly transmit any sensor data to the Internet. As a result, Wifi comes into play, and we require a Wi-Fi connection to communicate wirelessly with any server. However, one downside of using Wifi is that it is not always available. The wifi signal is only available in some areas and has a limited range of a few meters. We can’t rely on Wifi to use IoT Connectivity and obtain data from the farmer’s fields, for example, due to its unreliability. Forests, river zones, and mountains, for example, are all places where wifi is not available.

As a result, in today’s global world and technology, GSM GPRS is the only viable option. You can use the GSM GPRS Module to add location tracking, voice, text, SMS, and data to your app. The main benefit of GSM/GPRS connectivity is that it spans a large region and has signal/connection practically everywhere.

Proposed System

So in this project, we will learn about the Internet of Things (IoT) utilizing a GSM GPRS Module, often known as Cellular IoT. We’ll use the SIM900A GSM GPRS Module as a starting point and connect it to an Arduino board. Using the DHT11 Humidity/Temperature Sensor, we will detect the surrounding humidity and temperature. The humidity and temperature data will be transferred to the Thingspeak server using AT Commands for GSM Module. ThingSpeak is an open data platform and API for the Internet of Things that lets you gather, store, analyze, visualize, and act on sensor data. So, let’s learn everything there is to know about GSM Modules using Thingspeak and Arduino.

Hardware Required

  • Arduino UNO R3 Development Board
  • SIM800/SIM900 GSM GPRS Module
  • DHT11 Humidity Temperature Sensor
  • 12/9V Power Supply
  • Connecting Wire
  • Breadboard

SIM900A GSM/GPRS Module

The SIM900A is a common GSM/GPRS module found in various cell phones and PDAs. The module can also be used to create Internet of Things (IoT) and Embedded Apps. It operates over the 900/ 1800 MHz band. The modem has an RS232 interface that can be used to connect a PC and a microcontroller with an RS232 chip (MAX232). The baud rate can be changed from 9600 to 115200 using the AT command. The inbuilt TCP/IP stack on the GSM/GPRS Modem allows you to connect to the internet through GPRS. In the M2M interface, it is suited for SMS, Voice, and DATA transmission applications.

SIM900A GSM Module

You can connect a variety of unregulated power supplies to the onboard Regulated Power Supply. Through easy AT commands, you can make and receive voice calls, send and read SMS, use GPRS Internet, and more with this modem.

SIM900A GSM/GPRS Modem Features

  • Input Voltage: 12V DC
  • Supports MIC, Audio Input & Speakers
  • Dual-Band GSM/GPRS 900/ 1800 MHz
  • RS232 interface for direct communication with computer or MCU kit
  • Configurable baud rate
  • Wire Antenna ( SMA connector with GSM Antenna Optional )
  • SIM Cardholder
  • Built-in Network Status LED
  • Inbuilt a Powerful TCP/IP protocol stack for internet data transfer over GPRS
  • DATA GPRS: download transfer max is 85.6KBps, Upload transfer max 42.8KBps

Circuit/Connection between GSM Module Arduino & DHT11

This circuit design shows how to connect a SIM800/900 GSM Module to an Arduino and a DHT11 to send data to a Thingspeak server. As demonstrated here, the link is quite straightforward.

GSM Arduino Thingspeak

SIM800/900 is a UART Module. For serial communication, we use the Software Serial command. Connect the TX and RX pins of the device to Arduino pins 2 and 3, respectively. Provide a 9V/12V power source to the GSM Module. Connect the VCC and GND Pins of the DHT11 Sensor to the Arduino 5V and GND. Connect its output pin to Arduino’s pin A0.

SIM80 900 GSM Arduino

Setting up Thingspeak

ThingSpeak is an excellent tool for IoT-related applications. We may use ThingSpeak to monitor and operate our system over the Internet by using the Channels and web pages supplied by ThingSpeak. To begin, you must first sign up for ThingSpeak. So visit https://thingspeak.com and create an account.

Thingspeak Setup

Then make a new channel and configure it to your liking. The video below has an instruction. For additional information, watch the video.

After that, make the API keys. This key is necessary for programming changes and data settings.

Now click on channels so that you can see the online data streaming

Source Code/Program

The Arduino source code for sending GSM SIM800/900 GPRS data to Thingspeak is provided below. There are no libraries required. Simply copy and paste the code onto the Arduino Board.

However, you must first make two adjustments to the code. First, change your APN Services. In my instance, I’m using an Airtel SIM card, and Airtel’s default APN is airtelgprs.com. You may look up your SIM APN on Google or through your cellphone operator.

You’ll also need to make adjustments to the Thingspeak API key.

#include <SoftwareSerial.h>
SoftwareSerial gprsSerial(2,3);

#include <String.h>
#include <DHT.h>

#define DHTPIN A0

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);

}

Results & Observations

The module will begin reacting once the code has been uploaded to the Arduino UNO Board. You can see the following responses if you open the Serial Monitor.

Similarly, you may view the temperature and humidity logged data in Thingspeak’s private view.

Conclusion:

I hope all of you understand how to send GSM SIM800/900 GPRS Data to Thingspeak with Arduino. We MATHA ELECTRONICS will be back soon with more informative blogs 

Leave a Reply

Your email address will not be published.