In this workhop we will learn how to how to make a digital thermostat to measure and display temprature and Humidity.
In order to measure temprature and Humidity we using online service , but the probel is that, they are getting the data not your place where you searched so value might have difference, we don't know about that. also we can't make action like turing on A/C when temperature is High/Low like that using data from online services, for this we need absoulte data.
What if, we have a system that can be continually monitor and display temprature and Humidity, that can also be used for trigger some actions.
Build a device that can be controled continually monitor the temprature and Humidity and make actions like getting notification ike turing on A/C when temperature is High/Low, notification that can be help to refrigerate our food...etc.
Build a device that can be display temprature and Humidity also can be make action depends on the temprature and Humidity .
- Arduino Uno
- DHT11- Digital Humidty and Temperature Sensor
- Jumber Wires
- Breadboard
The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). Its fairly simple to use, but requires careful timing to grab data. The only real downside of this sensor is you can only get new data from it once every 2 seconds, so when using our library, sensor readings can be up to 2 seconds old.
An LCD is an electronic display module which uses liquid crystal to produce a visible image. The 16×2 LCD display is a very basic module commonly used in DIYs and circuits. The 16×2 translates o a display 16 characters per line in 2 such lines. In this LCD each character is displayed in a 5×7 pixel matrix.
Download the Arduino IDE and install it on your computer.
If you are new to the arduino system, you can learn the Arduino basics from here , after reading then go to the next step.
Since the DHT11 dones't comes with arduino IDE need to add the library on Arduino IDE first. Open the Library manager from Sketch -> Include Library- > Manage Libraries
from the follwing window search DHT11
Select the DHT Sensor library by Adafruit, and click Install.so we successfully added the DHT11 library.
#include "DHT.h" #define DHTPIN 2 // Digital pin connected to the DHT sensor #define DHTTYPE DHT11 // set DHT mode to dht11 DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor with pin and mode. void setup() { Serial.begin(9600); dht.begin(); // Initialize DHT sensor. } void loop() { delay(2000); // Wait a few seconds between measurements. // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float humi = dht.readHumidity(); // Read temperature as Celsius (the default) float temp = dht.readTemperature(); Serial.print("Humidity: "); Serial.print(humi); //print humudity Serial.print(" "); Serial.print("Temperature: "); Serial.print(temp); Serial.println(""); }
Connect the Data to Arduino Digital Pin 2 .
After open the Serial monitor
Here we are using LCD Module with 12C addons for I2C Communication , which will only need two wires for communication, in other way we need to use 14 pins.
Since the I2C is a addon we need to insert the library on Arduino IDE first. For that first downlaod the Arduino-LiquidCrystal-I2C-library.zip, Then click Sketch -> Include Library -> Add .ZIP Library
then select the .Zip file and click open.
now we successfully added the I2C library.
#include <Wire.h> #include <LiquidCrystal_I2C.h> // Set the LCD address to 0x27 for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x27, 16, 2); void setup() { // initialize the LCD lcd.begin(); // Turn on the blacklight and print a message. lcd.backlight(); lcd.print("Hello, world!"); } void loop() { lcd.setCursor(0, 1); lcd.print(millis() / 1000); }
Demonstrates the use a 16x2 LCD display. The I2C LiquidCrystal Module comes with 4-pins and connect them with follwing model.
- LCD SCL - Arduino SCL
- LCD SDA - Arduino SDA
- LCD GND - Arduino GND
- LCD VCC - Arduino VCC
This sketch prints "Hello World!" to the LCD and shows the time.
#include "DHT.h" #include <Wire.h> #include <LiquidCrystal_I2C.h> // Set the LCD address to 0x27 for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x27, 16, 2); #define DHTPIN 2 // Digital pin connected to the DHT sensor #define DHTTYPE DHT11 // set DHT mode to dht11 DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor with pin and mode. void setup() { Serial.begin(9600); dht.begin(); // Initialize DHT sensor. lcd.begin(); // initialize the LCD lcd.backlight(); // Turn on the blacklight and print a message. lcd.setCursor(0, 0); lcd.print("Humi Temp"); } void loop() { //delay(2000); // Wait a few seconds between measurements. // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float humi = dht.readHumidity(); // Read temperature as Celsius (the default) float temp = dht.readTemperature(); Serial.print("Humidity: "); Serial.print(humi); Serial.print(" "); Serial.print("Temperature: "); Serial.print(temp); Serial.println(""); lcd.setCursor(0, 0); lcd.print("Humi(%) Temp(C)"); lcd.setCursor(0, 1); lcd.print(humi); lcd.print(" "); lcd.print(temp); delay(2000); lcd.clear(); }
-
Add buzzer and trigger when a when temprature high.
-
Design and 3D Print an Enclosure.
Please share your feedback.