Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » GSM & Arduino Communication with Firebase or Thingspeak
Arduino Projects IoT Projects

GSM & Arduino Communication with Firebase or Thingspeak

Mamtaz AlamBy Mamtaz AlamUpdated:August 20, 20226 Comments6 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
GSM Arduino Firebase
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this tutorial, we will learn how we can use GSM Module with Arduino for communication with Google Firebase or Thingspeak Server. For this we will use an Arduino IoT Box designed using SIM800C and Atmega328 Microcontroller. The Arduino IoT box from Graylogix is a combination of GSM and Arduino for Battery Powered IoT Applications.

We will use the combination of GSM & Arduino to communicate with Firebase or Thingspeak. The DHT11 sensor which measures temperature and Humidity can be interfaced with Arduino easily. Initially, we will send the DHT11 Sensor Data to Thingspeak Server. After that, we will use Google Firebase to receive or monitor the data remotely.



Bill of Materials

You can purchase the required components from the following links.

S.N.ComponentsQuantityPurchase Links
1Arduino IoT Box1Graylogix
3DHT11 Sensor1Amazon | AliExpress
2Connecting Wires1Amazon | AliExpress

About Arduino IoT Box

Arduino IoT Box

The Arduino IoT Box is an Open Source Hardware for Arduino + GSM with Battery and I/O Ports. Due to the small size and properly assembled PCB, it is best Suitable for IoT Projects.

Arduino IoT Box GSM

Inside the Box, there is a PCB board that has SIM800C GSM Module and an Atmega328 Microcontroller with Arduino Bootloader. The box is powered via a 3.7V, 1000mAh Lithium-Ion Battery. To charge the battery the box has TP4056 Battery Management System IC. The battery can be charged micro-USB Cable by plugging it into the Micro-USB Port. The same USB port is also used to dump the code.

The box uses an external GSM Antenna which should be connected before powering the device. You can insert the nano Sim card in the dedicated SIM slot. Remember, SIM800 is a 2G Module and only supports 2G SIM. Dedicated I/O pins on board can be used to interface external sensors and other I/O devices conveniently by soldering berg strips on board. External interfacing can also be done using AD0 to AD3 (pulled high internally) which are connected internally to Arduino nano and one of the pins of the white RMZ is connected to the ground.



LED Indications

There are 5 different LEDs on the box to indicate the power, Network, Battery Charging, Battery Full, etc.

Orange LED indicates charging of the battery through the USB cable and Green LED indicates charging completed and the battery is full. COM port LED is lit at the time of dumping the code or data transmission between the device and the computer.

Blue LED Indicates the status of the GSM network,
1 sec Blinking = in N/W Search Mode.
3 Sec Blinking = Network Acquired Successfully.
½ Sec Blinking = connected to GPRS.


Default Connection

TX of GSM SIM800C is connected to D8 of Arduino Nano
RX of GSM SIM800C is connected to D7 of Arduino Nano
Red colour TEST LED is connected to D9 of Arduino Nano.


Aplications

You can use the Arduino IoT Box for Arduino Projects, IOT Projects, Realtime Projects, GSM based server communication, Data logger, Temperature Monitoring System, Sensor Data Acquisition, SMS Triggering etc.


Sending Sensor Data to Thingspeak Server

First we need to connect a DHT11 Sensor to Arduino IoT Box. You need to solder some male header pins on the PCB or just directly connect the DHT11 Sensor.

Connect the GND and VCC Pin of DHT11 Sensor to Arduino GND & 4V Pin. Similarly, connect the output pin to the D3 of the Arduino. You can also refer to the previous article to Send Sensor Data to Thingspeak.




Setting up Thingspeak

ThingSpeak provides very good tool for IoT based projects. By using ThingSpeak site, we can monitor our data and control our system over the Internet, using the Channels and web pages provided by ThingSpeak. So first you need to sign up for ThingSpeak. So visit https://thingspeak.com and create an account.

Thingspeak Setup

Then create a new channel and set up what you want. The tutorial in the video below. Follow the video for more clarifications.

Then create the API keys. This key is required for programming modifications and setting your data.

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


Source Code/Program

The source code/program to Send GSM SIM800/900 GPRS Data to Thingspeak with Arduino is given below. You can simply copy the code and upload to the Arduino Board.

From the code, change the APN. For example the APN for Airtel is airtelgprs.com. You can check your SIM APN from your google or cellular provider.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <SoftwareSerial.h>
#include <DHT.h>
 
#define DHTPIN 3
 
DHT dht(DHTPIN, DHT11);
 
SoftwareSerial gprsSerial(8, 7);
 
#include <String.h>
 
 
void setup()
{
  gprsSerial.begin(9600);        // the GPRS baud rate
  Serial.begin(9600);          
  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 " + 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);
 
}



Test/Results

After uploading the code, the GSM Module will try connecting to the Cellular Network. Then it will establish the connection with Thingspeak Server. You can open the Serial Monitor to see all the steps.

Similarly go to the Private view of Thingspeak Server. You will see the temperature and Humidity data getting uploaded after 30 seconds.


Sending Sensor Data to Firebase using GSM/Arduino

Now let us see how we can send the DHT11 Sensor Data to Google Firebase using SIM800C GSM Module and Arduino. First we need to setup the Google Firebase.

In earlier post, we learned to Send Sensor Data to Firebase with ESP8266. You can follow basic Google Firebase Setup tutorial to setup the firebase first.

We need the Firebase Host and the Authentication to connect the GSM to Firebase for communication.

You can get the Firebase Host from the Realtime Database.

Firebase GMS Arduino

You can copy the Authentication Token from Database Secrets.


Source Code for Arduino GSM Firebase

Follwing code can help to communicate the GSM & Arduino with Google Firebase. But the code requires TinyGsmClient Library as well as ArduinoHttpClient Library. First download these libraries and add it to the Arduino Library Folder.

1
2
const char FIREBASE_HOST[]  = "********************************************";
const String FIREBASE_AUTH  = "********************************************";

Change the Firebase Host and the Authentication Token from the above lines.

1
char apn[]  = "www";//airtel ->"airtelgprs.com"

Change for SIM or Service Provider APN from the above line.

Now you can copy the below code and upload it to the Arduino Board.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#define TINY_GSM_MODEM_SIM800
#define TINY_GSM_RX_BUFFER 256
 
#include <TinyGsmClient.h> //https://github.com/vshymanskyy/TinyGSM
#include <ArduinoHttpClient.h> //https://github.com/arduino-libraries/ArduinoHttpClient
#include <DHT.h>
#include <SoftwareSerial.h>
 
#define rxPin 7
#define txPin 8
 
SoftwareSerial sim800(txPin, rxPin);
 
#define DHTPIN 3
 
DHT dht(DHTPIN, DHT11);
 
const char FIREBASE_HOST[]  = "***************************************";
const String FIREBASE_AUTH  = "***************************************";
const String FIREBASE_PATH  = "/";
const int SSL_PORT          = 443;
 
char apn[]  = "www";//airtel ->"airtelgprs.com"
char user[] = "";
char pass[] = "";
 
 
TinyGsm modem(sim800);
 
TinyGsmClientSecure gsm_client_secure_modem(modem, 0);
HttpClient http_client = HttpClient(gsm_client_secure_modem, FIREBASE_HOST, SSL_PORT);
 
unsigned long previousMillis = 0;
 
 
void setup()
{
  Serial.begin(115200);
  dht.begin();
  Serial.println("device serial initialize");
 
  sim800.begin(9600);
  Serial.println("SIM800L serial initialize");
 
  Serial.println("Initializing modem...");
  modem.restart();
  String modemInfo = modem.getModemInfo();
  Serial.print("Modem: ");
  Serial.println(modemInfo);
 
  http_client.setHttpResponseTimeout(10 * 1000); //^0 secs timeout
}
 
void loop()
{
 
  Serial.print(F("Connecting to "));
  Serial.print(apn);
  if (!modem.gprsConnect(apn, user, pass))
  {
    Serial.println(" fail");
    delay(1000);
    return;
  }
  Serial.println(" OK");
 
  http_client.connect(FIREBASE_HOST, SSL_PORT);
 
  while (true) {
    if (!http_client.connected())
    {
      Serial.println();
      http_client.stop();// Shutdown
      Serial.println("HTTP  not connect");
      break;
    }
    else
    {
      dht_loop();
    }
 
  }
 
}
 
 
 
void PostToFirebase(const char* method, const String & path , const String & data, HttpClient* http)
{
  String response;
  int statusCode = 0;
  http->connectionKeepAlive(); // Currently, this is needed for HTTPS
 
  String url;
  if (path[0] != '/')
  {
    url = "/";
  }
  url += path + ".json";
  url += "?auth=" + FIREBASE_AUTH;
  Serial.print("POST:");
  Serial.println(url);
  Serial.print("Data:");
  Serial.println(data);
 
  String contentType = "application/json";
  http->put(url, contentType, data);
 
  statusCode = http->responseStatusCode();
  Serial.print("Status code: ");
  Serial.println(statusCode);
  response = http->responseBody();
  Serial.print("Response: ");
  Serial.println(response);
 
  if (!http->connected())
  {
    Serial.println();
    http->stop();// Shutdown
    Serial.println("HTTP POST disconnected");
  }
 
}
 
void dht_loop()
{
  String h = String(dht.readHumidity(), 2);
  String t = String(dht.readTemperature(), 2);
  delay(100);
 
  Serial.print("Temperature = ");
  Serial.print(t);
  Serial.println(" °C");
  Serial.print("Humidity = ");
  Serial.print(h);
  Serial.println(" %");
 
  String Data = "{";
  Data += "\"temp\":" + t + ",";
 
  Data += "\"humid\":" + h + "";
  Data += "}";
 
  PostToFirebase("PATCH", FIREBASE_PATH, Data, &http_client);
 
 
}



Test/Results

After uploading the code, the Nodemcu will connect to the Wifi Network. Now you can open the serial monitor, it will show the temperature and humidity reading.

Google Firebase GSM Arduino

When the temperature and humidity data is displayed on Serial Monitor at the same time, the data is sent to Google Firebase Database. You can just open the google Firebase console window and check the real-time entry of the data.


Video Tutorial/Guide

To learn more about the Arduino IoT Box, follow the video below.

Arduino IoT Box for Cellular IoT Applications || Send GSM Data to Firebase/Thingspeak
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleHow to interface Quectel L80 GPS Module with Arduino
Next Article Indoor Environment Monitoring with ESP32 & LCD Screen

Related Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

Updated:June 14, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

Updated:June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20261K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
View 6 Comments

6 Comments

  1. Hasib on March 28, 2022 11:44 PM

    Need help for A9G pudding module !

    Reply
  2. Coder1448 on April 6, 2022 12:10 AM

    Hello I want to control led via firebase with arduino gsm module

    Reply
  3. Carmine on November 2, 2022 1:58 PM

    Have you done anything similar using firestore?

    Reply
  4. sushant on February 5, 2023 5:05 AM

    can you please share the PCB files ?

    Reply
  5. Devika on March 6, 2023 5:17 AM

    Can we use the same model to send latitude and longitude data instead of temperature and humidity ? If so, how pls ?

    Reply
  6. Muhammad Ali on March 16, 2023 5:56 AM

    did you get any reply?

    Reply

CommentsCancel reply

Latest Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 14, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • How to use LDR Sensor Module with Arduino
    How to use LDR Sensor Module with Arduino
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • Silicon Controlled Rectifier (SCR): Construction, Working & Applications
    Silicon Controlled Rectifier (SCR): Construction, Working & Applications
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.