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 » SIM900/800 HTTP Post Request in JSON Format with Arduino
Arduino Projects IoT Projects

SIM900/800 HTTP Post Request in JSON Format with Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:August 21, 20224 Comments5 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
SIM900 HTTP POST JSON
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

In this post we will learn how to use SIM800 or SIM900 with Arduino & make HTTP Post Request in JSON format to any API Server.


Overview

Apart from Wifi Module or Ethernet Module, the IoT Projects can also be done through SIM800/900 GSM GPRS Module. The main advantage of Cellular IoT compared to Wifi IoT is the availability of network and signal everywhere. In one of my earlier posts, I explained how you can send the sensor data wirelessly using GSM Module to Thingspeak Server. You can check the post here: Send SIM800/900 GPRS Data to Thingspeak with Arduino

But today we will interface the SIM800/900 GSM GPRS Module with Arduino and develop a code to send the data to any web address or web server using API. We need to send the data in JSON format as direct sending of a string data looks difficult. The whole process and the final code is explained in this post.


Bill of Materials

Following are the components required to learn and get practical experience of this tutorial. All the components can be easily purchased from Amazon. The components purchase link is given as well.

S.N.Components QuantityPurchase Links
1Arduino UNO Board1Amazon | AliExpress
2SIM800/900 GSM Module1Amazon | AliExpress
3DHT11 Sensor1Amazon | AliExpress
4RTC Module DS32311Amazon | AliExpress
512/9V Power Supply1Amazon | AliExpress
6Connecting Wires10Amazon | AliExpress
7Breadboard1Amazon | AliExpress




What is API?

API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. Each time you use an app like Facebook, send an instant message or check the weather on your phone, you’re using an API.

Example of an API: When you use an application on your mobile phone, the application connects to the Internet and sends data to a server. The server then retrieves that data, interprets it, performs the necessary actions and sends it back to your phone. The application then interprets that data and presents you with the information you wanted in a readable way. This is what an API is – all of this happens via API.


What is JSON Format?

JSON stands for JavaScript Object Notation. It is a lightweight format for storing and transporting data. It is often used when data is sent from a server to a web page.

For example, the following is an example of a simple User object serialized to XML:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<xml>
   <user>
       <firstName>Jason</firstName>
       <middleName>Alexander</middleName>
       <lastName>Smith</lastName>
       <address>
           <street1>1234 Someplace Avenue</street1>
           <street2>Apt. 302</street2>
           <city>Anytown</city>
           <state>NY</state>
           <postalCode>12345</postalCode>
           <country>US</country>
       </address>
   </user>
</xml>

As you can see, the same data represented in JSON is far more efficient, while retaining all of its human-readability:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"firstName" : "Jason",
"middleName" : "Alexander",
"lastName" : "Smith",
"address" : {
"street1" : "1234 Someplace Avenue",
"street2" : "Apt. 302",
"city" : "Anytown",
"state" : "NY",
"postalCode" : "12345",
"country" : "US"
}
}

JSON is typically used together with IoT protocols that do not provide native support for data structure serialization such as HTTP/Rest, WebSockets, MQTT, and SMQ.

In JSON, data is structured in a specific way. JSON uses symbols like { } , : ” ” [ ] and it has the following syntax:

Data is represented in key/value pairs
1. The colon (:) assigns a value to key
2. key/value pairs are separated with commas (,)
3. Curly brackets hold objects ({ })
4. Square brackets hold arrays ([ ])


Hardware Setup

Let us do some hardware setup now. I am using 2 modules whose data is to be sent to the server via API in JSON format. I am using DHT11 Humidity & Temperature Sensor as I want to send Humidity & Temperature Data. Similarly, I am also using the DS3231 Real Time Clock (RTC) Module to check the time and send it to Server.

Following is the connection diagram below assemble the circuit as shown in the figure.

So I made the same connection here as shown below. So I have powered GSM Module with 12V and Arduino with 5V from computer USB port.

SIM900 HTTP POST API ARduino


Arduino JSON Library

The easiest way to decode and encode JSON strings with the Arduino IDE is using the ArduinoJson library which was designed to be the most intuitive JSON library, with the smallest footprint and most efficient memory management for Arduino. ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).

Features

1. JSON decoding (comments are supported)
2. JSON encoding (with optional indentation)
3. Elegant API, very easy to use
4. Fixed memory allocation (zero mallocs)
5. No data duplication (zero-copy)
6. Portable (written in C++98)
7. Self-contained (no external dependency)
8. Small footprint
9.Header-only library



Source Code: SIM900/800 HTTP post request in JSON Format with Arduino

The source code for making HTTP POST in JSON Format with API & SIM900/800 GSM Module is given below.

Before that you need some libraries. Download the libraries from the following link and add to the Arduino IDE.

1. RTC Lib for DS3231: Download
2. DHT Library for DHT11 Sensor: Download
3. Arduino JSON Library: Download

In the following code, make changes to the APN. I used Airtel APN. Check your Operator APN and make changes. Also make changes to the webserver or add your api webserver address where you want to send the data.

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
148
149
150
151
#include <RTClib.h>  // Download the library from https://github.com/adafruit/RTClib
#include <Wire.h>    // Library for I2C Communication with DS3231 Module
#include <DHT.h>
#include <SoftwareSerial.h>
SoftwareSerial myserial(10, 11); // RX: 10, TX:11
#include <ArduinoJson.h>
StaticJsonBuffer<200> jsonBuffer;
 
 
#define DHTPIN A1
#define DHTTYPE DHT11
 
RTC_DS3231 rtc;
DHT dht(DHTPIN, DHTTYPE);
 
char t[32];
char deviceID[12] = "MYTEST56";
 
 
void setup()
{
  myserial.begin(9600);        // the GPRS baud rate
  Serial.begin(9600);
  Serial.println("Initializing..........");
  dht.begin();
  Wire.begin();
  DynamicJsonBuffer jsonBuffer;
 
 
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  //rtc.adjust(DateTime(2020, 02, 29, 17, 50, 40));
  delay(5000);
}
 
void loop()
{
  Serial.println("");
  Serial.println("************************************************************");
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();
 
  DateTime now = rtc.now();
 
  sprintf(t, "%02d:%02d:%02d %02d/%02d/%02d",  now.hour(), now.minute(), now.second(), now.day(), now.month(), now.year());
 
  Serial.print("Device ID: ");
  Serial.println(deviceID);
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");
  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");
  Serial.print(F("Time/Date: "));
  Serial.println(t);
  delay(1000);
 
 
/********************GSM Communication Starts********************/
 
  if (myserial.available())
  Serial.write(myserial.read());
 
  myserial.println("AT");
  delay(3000);
 
  myserial.println("AT+SAPBR=3,1,\"Contype\",\"GPRS\"");
  delay(6000);
  ShowSerialData();
 
  myserial.println("AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\"");//APN
  delay(6000);
  ShowSerialData();
 
  myserial.println("AT+SAPBR=1,1");
  delay(6000);
  ShowSerialData();
 
  myserial.println("AT+SAPBR=2,1");
  delay(6000);
  ShowSerialData();
 
 
  myserial.println("AT+HTTPINIT");
  delay(6000);
  ShowSerialData();
 
  myserial.println("AT+HTTPPARA=\"CID\",1");
  delay(6000);
  ShowSerialData();
 
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& object = jsonBuffer.createObject();
  
  object.set("deviceID",deviceID);
  object.set("humidity",humidity);
  object.set("temperature",temperature);
  object.set("timedate",t);
  
  object.printTo(Serial);
  Serial.println(" ");  
  String sendtoserver;
  object.prettyPrintTo(sendtoserver);
  delay(4000);
 
  myserial.println("AT+HTTPPARA=\"URL\",\"http://192.xxxxxxxxxxxxxxxxxxxxxxxx.php\""); //Server address
  delay(4000);
  ShowSerialData();
 
  myserial.println("AT+HTTPPARA=\"CONTENT\",\"application/json\"");
  delay(4000);
  ShowSerialData();
 
 
  myserial.println("AT+HTTPDATA=" + String(sendtoserver.length()) + ",100000");
  Serial.println(sendtoserver);
  delay(6000);
  ShowSerialData();
 
  myserial.println(sendtoserver);
  delay(6000);
  ShowSerialData;
 
  myserial.println("AT+HTTPACTION=1");
  delay(6000);
  ShowSerialData();
 
  myserial.println("AT+HTTPREAD");
  delay(6000);
  ShowSerialData();
 
  myserial.println("AT+HTTPTERM");
  delay(10000);
  ShowSerialData;
 
  /********************GSM Communication Stops********************/
 
}
 
 
void ShowSerialData()
{
  while (myserial.available() != 0)
    Serial.write(myserial.read());
  delay(1000);
 
}



Result & Responses

Once you upload the code to the Arduino and Power on the module, the Module will try connecting to the internet and will send data in JSON format.

Sometimes you might miss data and get some errors. This can be reduced by increasing delays after step by step in the above code. Or if the network connectivity and signal strength is good you can get the data most of the times.

Open your serial monitor and you should get the following results.

So this was all about how to make to use SIM900/800 Module & make HTTP post request in JSON Format with Arduino.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleAlcohol Level Meter using Arduino & MQ-135 Alcohol/Gas Sensor
Next Article STM32 & SIM900/800 HTTP Post Request in JSON Format

Related Posts

IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

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
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

Updated:February 1, 20261K
View 4 Comments

4 Comments

  1. ami on August 28, 2020 4:22 PM

    hello
    How can I have php code?

    Reply
  2. Eugene on October 1, 2020 4:00 PM

    Hello, I would like to ask, why did you define three jsonbuffers

    Reply
  3. Vasekar on September 2, 2021 8:49 PM

    Thanks, this is amazing, Relay you have done the extensive efforts for creating step by step connection and data sending commands. so many times serial monitor displays OK. I could make the HTTP POST request to my own website api using this program.

    A small request, there is compilation error for Json Object. It is necessary to upgrade for ver. 6. For my work insted of creating JSON data string using JSON object, I have assigned it directly. However If possible, please try to upgrade the code.

    Reply
  4. Bobby on April 15, 2022 4:21 PM
    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 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
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • 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
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
  • DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display
    DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
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 (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • 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.