0% found this document useful (0 votes)
22 views5 pages

Experiment 3

The document outlines an experiment to send temperature and humidity data to the internet using an Arduino and a GSM module. It details the required hardware and software components, the theory behind the setup, and step-by-step procedures for connecting the devices and programming the Arduino. The experiment concludes with successful data transmission via HTTP POST requests to a web server.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views5 pages

Experiment 3

The document outlines an experiment to send temperature and humidity data to the internet using an Arduino and a GSM module. It details the required hardware and software components, the theory behind the setup, and step-by-step procedures for connecting the devices and programming the Arduino. The experiment concludes with successful data transmission via HTTP POST requests to a web server.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment 3

Send the recorded values of Temperature/Humidity to the Internet via GSM


module using Arduino.

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:

- Arduino Uno or any compatible Arduino board

- DHT11/DHT22 sensor (for temperature and humidity measurement)

- GSM module (SIM900A, SIM800L, etc.)

- SIM card with an active data plan

- Breadboard and connecting wires

- Power supply (for GSM module and Arduino)

2. Software:

- Arduino IDE

- DHT sensor library for Arduino

- GSM library for Arduino (e.g., SoftwareSerial)

Theory:

Arduino is an open-source microcontroller platform that is widely used in IoT


projects. It can be easily interfaced with various sensors and modules to collect data
and send it to the internet.

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.

DHT11/DHT22 Sensor: These sensors are commonly used to measure temperature


and humidity. They are digital sensors that can be easily interfaced with Arduino, and
they provide data in a format that can be directly used in the code.
Procedure:

1. Setup the Arduino and GSM Module:

- 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.

2. Connect the DHT Sensor:

- 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:

- Install the DHT sensor library in the Arduino IDE.

- 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.

- Upload the code to the Arduino.

4. Testing:

- Power on the Arduino and GSM module.

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

#define DHTPIN 2 // Pin where the DHT is connected

#define DHTTYPE DHT11 // DHT 11 or DHT22

DHT dht(DHTPIN, DHTTYPE);

SoftwareSerial gsm(7, 8); // RX, TX for GSM module

const char* APN = "your_apn"; // Your network provider's APN

const char* USER = ""; // Leave blank if not required

const char* PASS = ""; // Leave blank if not required

const char* URL = "http://yourserver.com/data"; // Your server URL

void setup() {

Serial.begin(9600);

gsm.begin(9600);

dht.begin();

delay(1000);

Serial.println("Initializing GSM module...");

gsm.println("AT");

delay(1000);

gsm.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");

delay(1000);

gsm.println("AT+SAPBR=3,1,\"APN\",\"" + String(APN) + "\"");


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

Serial.println("Failed to read from DHT sensor!");

return;

String data = "temperature=" + String(t) + "&humidity=" + String(h);

Serial.println("Sending data to server...");

gsm.println("AT+HTTPINIT");

delay(1000);

gsm.println("AT+HTTPPARA=\"CID\",1");

delay(1000);

gsm.println("AT+HTTPPARA=\"URL\",\"" + String(URL) + "\"");

delay(1000);
gsm.println("AT+HTTPPARA=\"CONTENT\",\"application/x-www-form-
urlencoded\"");

delay(1000);

gsm.println("AT+HTTPDATA=" + String(data.length()) + ",10000");

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

delay(60000); // Send data every 60 seconds

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.

You might also like