Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
36 views

Request Temperature Data Using GSM and Arduino

This project allows users to request temperature and humidity data from a sensor using a cell phone. An Arduino board is connected to a DHT11 temperature and humidity sensor and GSM module. When the user texts a request to the GSM module, it takes a temperature and humidity reading from the sensor and sends the values back in an SMS message. The Arduino code defines how the sensor readings are taken and formatted into text messages. If the temperature exceeds 40°C, an alert message is automatically sent without a request.

Uploaded by

El Haj Benazzouz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Request Temperature Data Using GSM and Arduino

This project allows users to request temperature and humidity data from a sensor using a cell phone. An Arduino board is connected to a DHT11 temperature and humidity sensor and GSM module. When the user texts a request to the GSM module, it takes a temperature and humidity reading from the sensor and sends the values back in an SMS message. The Arduino code defines how the sensor readings are taken and formatted into text messages. If the temperature exceeds 40°C, an alert message is automatically sent without a request.

Uploaded by

El Haj Benazzouz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

www.electroniclinic.

com
/request-temperature-data-using-gsm-and-arduino/

Request Temperature Data Using GSM and Arduino


⋮ 5/5/2019

Request Temperature, Project Description:

Request Temperature using GSM– This project is based on the Temperature and Humidity
monitoring using a Cell phone, Arduino, and the famous DHT11 Temperature and Humidity Sensor. In
this tutorial, you will learn how to request temperature and humidity values from anywhere around the
world using your cell phone. There are projects in which the Sensors data is sent after regular intervals,
which I believe is not good. This project is different from the rest of the GSM-based projects, as in this
project the Temperature and Humidity values are sent only when the owner sends a request message.

Watch the complete video tutorial.

Amazon Links:

12v Adaptor:

Arduino Uno

Arduino Nano

Mega 2560:

Sim900A GSM Module:

1/8
DC 5V 2A Adaptor

DHT11 Temperature and Humidity Module:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through
these links. I would appreciate your support in this way!

DHT11 Temperature and Humidity Sensor:

The DHT11 Temperature and Humidity module have a total of 4 pins, out of which only three pins are
used. Pin number 3 is not used. The interfacing of the DHT11 temperature sensor with the Arduino can
be seen in the circuit diagram. For the complete explanation, watch the video given at the end.

2/8
GSM SIM900A Module:

This is the GSM module that I will be using in this tutorial, in the market we have different types of GSM
modules, the one I will be using today is SIM900A, the same code is also tested on sim900D, so if you
want you can also use sim900D.

If you are from Pakistan, Bangladesh or India make sure you purchase the unlocked version of the
SIM900A. This GSM SIM900A module the one we will be using in this tutorial, as you can see on the
screen has no Onboard voltage regulator, so be careful while applying the voltage. The ideal voltage for
this GSM module is 4.7v but you can also connect it with the 5v adaptor.

As the ideal voltage for this GSM module is 4.7v to 5volts, so any voltage above this can damage the
GSM module. If you don’t have the regulated 5v adaptor then you can also use an lm317t adjustable
voltage regulator. I have a very detailed tutorial on this. Watch the video.

3/8
As you can see SIM900A module has so many pins that are clearly labeled but we will be using only 5 of
these pins, the power supply pins, GND, RXD 5v, and TXD 5v. The GND of the GSM SIM900A module
will be connected with the Arduino GND, TXD of the GSM SIM900A will be connected with the Arduino
pin7 and finally, the RXD of the GSM SIM900A module will be connected with the  Arduino pin8.

GSM Sim900A and DT11 connections with Arduino:

For the complete circuit Diagram explanation watch Video tutorial given at the end of this article.

Request temperature data Arduino Programming:


1 /*
2   commands
3   v = feedback request
4 */
5  
6 #include <SoftwareSerial.h>
7 #include "DHT.h"
8  
9 #define DHTPIN 12     // what pin we're connected to
10  
11 //Uncomment whatever the type of sensor we are using.
12 #define DHTTYPE DHT11   // DHT 11
13 //#define DHTTYPE DHT22   // DHT 22  (AM2302)
14 //#define DHTTYPE DHT21   // DHT 21 (AM2301)
15  
16 // Connect pin 1 (on the left) of the sensor to +5V
17 // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
18 // to 3.3V instead of 5V!
19 // Connect pin 2 of the sensor to whatever your DHTPIN is
20 // pin3 of the sensor is not connected

4/8
21 // Connect pin 4 (on the right) of the sensor to GROUND
22 // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
23  
24 // Initialize DHT sensor for normal 16mhz Arduino
25 DHT dht(DHTPIN, DHTTYPE);
26  
27 char inchar; // Will hold the incoming character from the GSM shield
28  
29 SoftwareSerial SIM900(8, 7); // gsm module connected here.
30  
31 String TextForSms ;
32 String humidity = " Humidity: %";
33 String temperature = "   Temperature";
34 String sign = " *C";
35  
36  
37 void setup() {
38  
39    Serial.begin(9600);
40   SIM900.begin(9600); // original 19200
41    dht.begin();
42 pinMode(6, OUTPUT);  
43 digitalWrite(6, HIGH);
44   
45 //  delay(10000);  // give time to log on to network.
46 randomSeed(analogRead(0));
47  
48   SIM900.print("AT+CMGF=1\r");  // set SMS mode to text
49   delay(1000);
50   SIM900.print("AT+CNMI=2,2,0,0,0\r");
51   // blurt out contents of new SMS upon receipt to the GSM shield's serial out
52   delay(1000);
53      SIM900.println("AT+CMGD=1,4"); // delete all SMS
54    delay(5000);
55   Serial.println("Ready...");
56   
57 }
58  
59  
60  
61  
62 void sendSMS(String message)
63 {
64   SIM900.println("AT+CMGF=1\r");                     // AT command to send SMS message
65   delay(1000);
66 SIM900.println("AT+CMGS = \"+923339218213\"");  // recipient's mobile number, in
67 international format
68   delay(1000);
69   SIM900.println(message);                         // message to send
70   delay(1000);
71   SIM900.println((char)26);                        // End AT command with a ^Z, ASCII code 26
72   delay(1000);
73   SIM900.println();
74   delay(1000);                                     // give module time to send SMS
75                                    // turn off module
76 }

5/8
77 void loop() {
78  
79 if(SIM900.available() == 0)
80 {
81  
82    // Wait a few seconds between measurements.
83   delay(2000);
84  
85   // Reading temperature or humidity takes about 250 milliseconds!
86   // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
87   int h = dht.readHumidity();
88   // Read temperature as Celsius
89   int t = dht.readTemperature();
90   // Read temperature as Fahrenheit
91   int f = dht.readTemperature(true);
92   
93   // Check if any reads failed and exit early (to try again).
94   if (isnan(h) || isnan(t) || isnan(f)) {
95     Serial.println("Failed to read from DHT sensor!");
96     return;
97   }
98  
99   // Compute heat index
100   // Must send in temp in Fahrenheit!
101   int hi = dht.computeHeatIndex(f, h);
102  
103 //  Serial.print("Humidity: ");
104 //  Serial.print(h);
105 //  Serial.print(" %\t");
106 //  Serial.print("Temperature: ");
107 //  Serial.print(t);
108 //  Serial.print(" *C ");
109   
110   TextForSms = TextForSms + "Humidity: ";
111   TextForSms.concat(h);
112   TextForSms = TextForSms + "%    Temperature: ";
113   TextForSms.concat(t);
114   TextForSms = TextForSms + "*C";
115   Serial.println(TextForSms);
116   delay(2000);
117   TextForSms = " ";
118   
119    if ( t > 40 )
120    {
121    Serial.println("Temperature Exceeded");
122 TextForSms = " Temperature Exceeded";
123 sendSMS(TextForSms);
124 delay(5000);
125 TextForSms = "";
126    }
127   
128 }
129   if(SIM900.available() >0)
130   {
131  
132     inchar=SIM900.read();

6/8
133   Serial.println(inchar);
134     delay(20);
135     if (inchar=='v')
136     {
137       delay(10);
138    Serial.println(inchar);
139     
140   // Wait a few seconds between measurements.
141   delay(2000);
142  
143   // Reading temperature or humidity takes about 250 milliseconds!
144   // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
145   int h = dht.readHumidity();
146   // Read temperature as Celsius
147   int t = dht.readTemperature();
148   // Read temperature as Fahrenheit
149   int f = dht.readTemperature(true);
150   
151   // Check if any reads failed and exit early (to try again).
152   if (isnan(h) || isnan(t) || isnan(f)) {
153     Serial.println("Failed to read from DHT sensor!");
154     return;
155   }
156  
157   // Compute heat index
158   // Must send in temp in Fahrenheit!
159   int hi = dht.computeHeatIndex(f, h);
160  
161 //  Serial.print("Humidity: ");
162 //  Serial.print(h);
163 //  Serial.print(" %\t");
164 //  Serial.print("Temperature: ");
165 //  Serial.print(t);
166 //  Serial.print(" *C ");
167   
168   TextForSms = TextForSms + "HUMIDITY: ";
169   TextForSms.concat(h);
170   TextForSms = TextForSms + "%    TEMPERATURE: ";
171   TextForSms.concat(t);
172   TextForSms = TextForSms + "*C";
173    sendSMS(TextForSms);
174   Serial.println(TextForSms);
175   delay(2000);
176   TextForSms = " ";
177     }
178 }
179  
180  
181 }
182
183

Watch Video Tutorial:

7/8
Other GSM Related Projects:
How to use GSM and Bluetooth Together To monitor Any Sensors wirelessly using Arduino

RFID & GSM based student Attendance Alert message to parents

Arduino GSM Project: Security Alert message to multiple numbers

Arduino and Gsm based laser security system

Car accident location tracking using GSM, GPS, and Arduino

GSM Alarm System Using Arduino and a PIR Sensor

Arduino Gas leakage detection and SMS alert MQ-2 sensor

RFID based students attendance system with message Alert

Tags
Arduino arduino and GSM based temperature arduino and GSM to monitor temperature arduino GSM
and dht11 sensor arduino GSM temperature arduino GSM temperature monitoring arduino temperautre
GSM cell dht11 dht11 with arduino GSM gsm GSM temperature monitoring monitoring read temperature
through GSM arduino request temperature using GSM request temperature using GSM and arduino
sim900A temperature temperature monitoring through GSM arduino temperature monitoring using GSM

8/8

You might also like