In this blog, we will learn how to make HTTP Post with SIM7600 GSM 4G LTE and Arduino. We will use SIM7600 4G LTE commands with Arduino and send the DHT11 Sensor data to Thingspeak Server. Previously, we used the SIM800/900 2G GSM Module to make an HTTP post request. Considering wireless communication, for most circumstances, LTE 4G is still an appropriate solution.
As a result, the SIM7600 4G LTE Module is a viable option for all 2G modems. With the 4G GSM LTE Module, you can integrate location tracking, voice, text, SMS, and data into your app. The main benefit of 4G LTE Modem Connectivity is that it covers a large region and has signal/connection practically everywhere.
We will learn about the Internet of Things utilizing a 4G LTE Module, commonly known as Cellular IoT, in this project. The humidity and temperature data will be delivered to the Thingspeak server using SIM7600 LTE AT Commands using the HTTP Post method.
- SIM7600 Board-Maduino Zero 4G LTE(SIM7600X)
- DHT11 Sensor Humidity & Temperature Sensor
- Male-to-Female Jumpers
SIM7600 4G LTE Arduino Customized Board
The SIM7600A-H/SIM7600E-H is a multi-band LTE-FDD/LTE-TDD/HSPA+/UMTS/EDGE/GPRS/GSM LCC module solution. It enables LTE CAT4 data transfer rates of up to 150Mbps downlink and 50Mbps uplink, which is quicker and more popular than 2G/3G.
You can purchase this board from Maduino Zero 4G LTE(SIM7600X) as it is manufactured by Makerfabs.
Makerfabs Maduino Zero 4G LTE module is based on the ATSAMD21G18A microcontroller, which is Arduino compatible. As a result, you may use the Arduino IDE to control and program the SIM7600 Module, as well as send HTTP posts. The board’s front and rear sides appear similar to this.
A 3.7V Lithium-Ion Battery can be connected to the battery connector on the front side. The switch can be used to turn the module on and off. One USB TypeC port is for microcontrollers, while the other is for LTE. MCU and LTE reset are controlled by two pushbuttons. The network connectivity status is indicated by the stat LED. The primary antenna, an auxiliary antenna, and a GPS antenna can all be connected to the board. A microphone or earphones can be connected via a 3.5mm jack, while speakers can be connected via an audio jack.
A micro-sim slot for a 4G SIM card is located on the reverse. There are two SD card slots, one for the microcontroller and the other for the memory.
Note: When the device is turned on, do not plug or unplug the antenna, SIM cards, or SD card. It may cause short-circuiting, which could cause the IC to burn out.
HTTP Post with SIM7600 & Arduino
Let’s utilize the SIM7600 and Arduino to communicate data from the DHT11 Sensor to the Thingpspeak Server. We’ll use the HTTP Post method and SIM7600 AT Commands for this. In the previous post, we tried the AT commands for checking HTTP data. Testing SIM7600 AT Commands can be found under the SIM7600 fundamentals section.
For this, we’ll utilize a DHT11 Humidity and Temperature Sensor. The DHT11 is a basic digital temperature and humidity sensor that is extremely inexpensive. It measures the ambient air with a capacitive humidity sensor and a thermistor and outputs a digital signal on the data pin.
Connect the DHT11’s VCC and GND pins to the 3.3V and GND pins on the board. Connect the sensor’s output pin to the D3 pin on the board, which is an Arduino digital pin.
Setting up Arduino IDE
The Arduino IDE does not include the ATSAMD21G18A board. As a result, we must use the Board Manager to install the “Arduino Zero Board.”
Manager, open the Boards To launch the Boards Manager dialogue box, select Tools-> Board-> Boards Manager... from the top Arduino IDE menu. Install Arduino SAMD Boards (ARM Cortex-M0+ 32-bits).
After the installation is finished, pick the Arduino Zero board as indicated in the image below. A USB TypeC Data Cable is required to program this board.
Setting up Thingspeak
ThingSpeak is an excellent tool for IoT-related applications. Using the Channels and web pages supplied by ThingSpeak, we can monitor and operate our system over the Internet. To begin, you must first sign up for ThingSpeak. So visit https://thingspeak.com and create an account.
Then make a new channel and add a DHT11 Humidity and Temperature Value widget.
Create the API keys after that. This key is necessary for programming changes and data settings.
Source Code/Program to make SIM7600 HTTP Post
The following Arduino code is used for making SIM7600 HTTP Post request. Copy the following code and make some changes as indicated.
Change the Apikey with the API Key of your Thingspeak Server.
|String Apikey = “***************”;|
Change the APN in the following line to the APN of your SIM Card’s cellular Network Provider.
|sendData(“AT+CGDCONT=1,\”IP\”,\”apn\””, 1000, DEBUG);|
Here is the complete code. You can use a native USB port on the ATSAMD Controller to upload it.
//Change the API key to yours
String Apikey = “***************”;
#define DEBUG true
#define LTE_RESET_PIN 6
#define LTE_PWRKEY_PIN 5
#define LTE_FLIGHT_PIN 7
#define Sensor_PIN 3 //D3-DHT11
; // wait for Arduino serial Monitor port to connect
//Serial1.begin(UART_BAUD, SERIAL_8N1, MODEM_RXD, MODEM_TXD);
digitalWrite(LTE_FLIGHT_PIN, LOW);//Normal Mode
/*ModuleState = moduleStateCheck();
if (ModuleState == false) //if it’s off, turn on it.
SerialUSB.println(“Now turnning the SIM7600 on.”);
sendData(“AT+CCID”, 3000, DEBUG);
sendData(“AT+CREG?”, 3000, DEBUG);
sendData(“AT+CGATT=1”, 1000, DEBUG);
sendData(“AT+CGACT=1,1”, 1000, DEBUG);
sendData(“AT+CGDCONT=1,\”IP\”,\”apn\””, 1000, DEBUG);
//sendData(“AT+CIPSTART=\”TCP\”,\”www.mirocast.com\”,80″, 2000, DEBUG);
SerialUSB.println(“4G HTTP Test Begin!”);
//——–Get temperature and humidity————-
float h = dht.readHumidity();
float t = dht.readTemperature();
String http_str = “AT+HTTPPARA=\”URL\”,\”https://api.thingspeak.com/update?api_key=” + Apikey + “&field1=” + (String)t + “&field2=” + (String)h + “\”\r\n”;
sendData(“AT+HTTPINIT\r\n”, 2000, DEBUG);
sendData(http_str, 2000, DEBUG);
sendData(“AT+HTTPACTION=0\r\n”, 3000, DEBUG);
sendData(“AT+HTTPTERM\r\n”, 3000, DEBUG);
int i = 0;
bool moduleState = false;
for (i = 0; i < 5; i++)
String msg = String(“”);
msg = sendData(“AT”, 1000, DEBUG);
if (msg.indexOf(“OK”) >= 0)
SerialUSB.println(“SIM7600 Module had turned on.”);
moduleState = true;
String sendData(String command, const int timeout, boolean debug)
String response = “”;
long int time = millis();
while ( (time + timeout) > millis())
char c = Serial1.read();
response += c;
Testing & Results
Wait for the blue light on the board to blink after uploading the code.
Then open your Serial Monitor. The output from the Serial Monitor should look like this.
This indicates that your 4G modem is operational. A 204 appears on occasion. The number 204 is not an error code; it indicates that the server has completed your request but has no answer to provide. It’s essentially (and very roughly) an ACK with no further explanation.
Now proceed to Thingspeak Server’s private view. The following data of Humidity and Temperature will be plotted on the Thingspeak private view by the Thingspeak Server.
I hope all of you understand how to make HTTP Post using SIM7600 4G LET Modem & Arduino and send DHT11 sensor data to Thingspeak Server. We MATHA ELECTRONICS will be back soon with more informative blogs.