Experiment 3
Experiment 3
Aim: To send the recorded values of temperature and humidity to the internet using a
GSM module interfaced with an Arduino.
Components Required:
1. Hardware:
2. Software:
- Arduino IDE
Theory:
GSM Module: GSM (Global System for Mobile Communications) modules like SIM900A
or SIM800L allow Arduino to communicate with the internet via a mobile network.
These modules use AT commands to interact with the SIM card, connect to the
internet, and send data to a web server.
- Connect the GSM module to the Arduino using the SoftwareSerial library. The TX
and RX pins of the GSM module are connected to digital pins (e.g., 7 and 8) on the
Arduino.
- Connect the DHT sensor to the Arduino. The VCC pin of the sensor goes to the 5V
pin on the Arduino, GND to GND, and the Data pin to a digital pin (e.g., 2) on the
Arduino.
3. Programming:
- Write a program to initialize the GSM module and establish a GPRS connection.
- Read the temperature and humidity data from the DHT sensor.
- Format the data and send it to a web server using an HTTP POST request via the
GSM module.
4. Testing:
- Monitor the serial output to ensure that the data is being sent successfully.
- Verify the data on the web server or through an API endpoint to confirm that the
temperature and humidity values have been received.
Code:
#include <SoftwareSerial.h>
#include <DHT.h>
void setup() {
Serial.begin(9600);
gsm.begin(9600);
dht.begin();
delay(1000);
gsm.println("AT");
delay(1000);
gsm.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
delay(1000);
gsm.println("AT+SAPBR=1,1");
delay(3000);
gsm.println("AT+SAPBR=2,1");
delay(1000);
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
return;
gsm.println("AT+HTTPINIT");
delay(1000);
gsm.println("AT+HTTPPARA=\"CID\",1");
delay(1000);
delay(1000);
gsm.println("AT+HTTPPARA=\"CONTENT\",\"application/x-www-form-
urlencoded\"");
delay(1000);
delay(1000);
gsm.print(data);
delay(10000);
gsm.println("AT+HTTPACTION=1");
delay(5000);
gsm.println("AT+HTTPREAD");
delay(1000);
gsm.println("AT+HTTPTERM");
delay(1000);
Result: Successfully interfaced Arduino with a GSM module to send temperature and
humidity data to the internet. The data was sent via an HTTP POST request to a web
server, where it can be logged and monitored.