शुक्रवार, १७ फेब्रुवारी, २०१७

Temp & Humidity Sensor with LCD Disp & LED Indicator

 Temp & Humidity Sensor with LCD Disp & LED Indicator



In this instructable, I have used the DHT11 Temperature & Humidity sensor & Arduino UNO to display the current temperature & humidity readings into a 16 x 2 LCD Display. Alongside, I have also created a 3-LED setup which indicates 3 sets of temperature readings (cold, hot, extreme).
The DHT11 is a digital sensor that lets you easily get relative humidity and temperature readings in your projects. Because of their low cost and small size, DHT11 sensors are perfect for lots of different DIY electronics projects. Some projects where the DHT11 would be useful include remote weather stations, home environment control systems, and agricultural/garden monitoring systems.
DHT11 Technical Specifications :
  • Humidity Range: 20-90% RH
  • Humidity Accuracy: ±5% RH
  • Temperature Range: 0-50 °C
  • Temperature Accuracy: ±2% °C
  • Operating Voltage: 3V to 5.5V
Next, I will be describing step-wise with relevant images, how to hook up the 16 x 2 LCD Display to the Arduino, the relative connections of the DHT11 sensor & the 3-LED setup.

Stuffs you will need for this project

  1. Breadboard
  2. 16 X 2 LCD Display
  3. Jumper wires
  4. Arduino UNO Board & Arduino IDE installed on your computer
  5. 3-LEDs (of 3 different colors)
  6. Mini Breadboard (not necessary)
  7. DHT11 Temp & Humidity Sensor
Setting up the connections with the Arduino


The connection part is the most important part of the whole project. Make sure you follow the directions properly or else you might end up destroying the sensor directly. The image above (and in Step 3 below) shows the connections of the setup in the breadboard in a clean way. Deep-Blue wires correspond to the 5V connection & Black wires correspond to the Ground connection
1. The 16 x 2 LCD Display consists of 16 pins which are labelled with different names, written on the back of the display module. Make sure you follow the pin numbers correctly.
2. To know the pins of the DHT11 sensor, refer to the wiring diagram above.
In case, the wiring diagram feels a bit too complex, here is the connection setup list pin wise :
  • Arduino GND to breadboard Negative power rail (All black wires goes to this rail)
  • Arduino 5V to breadboard Positive power rail (All deep-blue wires goes to this rail)
  • DHT11 Positive pin to breadboard positive power rail
  • DHT11 Negative pin to breadboard negative power rail
  • DHT11 Signal pin to Arduino Analog A0 (this feeds data from DHT11 to Arduino)
  • LCD 1 to breadboard Negative power rail
  • LCD 2 to breadboard Positive power rail
  • LCD 3 to breadboard Negative power rail (if you connect this to a potentiometer, this helps to change the LCD brightness)
  • LCD 4 to Arduino Digital Pin 12 (LCD character coordinates)
  • LCD 5 to breadboard Negative power rail
  • LCD 6 to Arduino Digital Pin 11 (LCD initiate command)
  • LCD 11 to Arduino Digital Pin 5
  • LCD 12 to Arduino Digital Pin 4
  • LCD 13 to Arduino Digital Pin 3
  • LCD 14 to Arduino Digital Pin 2
  • LCD 15 to breadboard Positive power rail
  • LCD 16 to breadboard Negative power rail
  • Cold/Green LED Positive Pin to Arduino Digital Pin 7 (negative pin to breadboard negative rail)
  • Hot/Yellow LED Positive Pin to Arduino Digital Pin 8 (negative pin to breadboard negative rail)
  • Extreme/Red LED Positive Pin to Arduino Digital Pin 9 (negative pin to breadboard negative rail)
If you have made the connections properly, you are almost half-way through the project since the rest steps are easy to follow with.

What your setup will probably look like

I have uploaded few images above to see how each connections look like. Since this is a complex circuit, I have tried my best to keep wiring connections as simple as possible. Hope this might help you at some stage.
Next before moving on the coding part, what we need are two Arduino Libraries for our LCD Display & DHT11 sensors to work properly. I have had a tough time finding the correct library for the DHT11 sensor because most of them were outdated. However, the LCD Display library is inbuilt within the Arduino IDE.

Nevertheless, I have attached the two library files. If you don't know how to install an Arduino Library inside the IDE, it's quite easy : Open Arduino IDE --> Sketch --> Include Library --> Add Library and select the .zip files.

This is the code, you will have to compile & upload to your Arduino UNO board. If you have made all the connections & library installation exactly as described, the code compilation should probably produce no errors.
#include <LiquidCrystal.h> #include <DHT.h>
#include "DHT.h"
#define DHTPIN A0 // what pin we're connected to
#define DHTTYPE DHT11 // we are using the DHT11 sensor
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DHT dht(DHTPIN, DHTTYPE);
void setup() { Serial.begin(9600); for (int DigitalPin = 7; DigitalPin <= 9; DigitalPin++) { pinMode(DigitalPin, OUTPUT); } lcd.begin(16,2); //16 by 2 character display dht.begin(); } void loop() { delay(1000); // Reading temperature or humidity takes about 250 milliseconds! float h = dht.readHumidity(); float t = dht.readTemperature(); // Read temperature as Celsius (the default)
lcd.clear(); lcd.setCursor(0,0); lcd.print("Temp: "); lcd.print(t); //printing temperarture to the LCD display
lcd.print("'C"); lcd.setCursor(0,1); lcd.print("Humid: "); lcd.print(h); //printing humidity to the LCD display lcd.print("%");
//the 3-led setup process if (t<=22) { digitalWrite(7, HIGH); digitalWrite(8, LOW); digitalWrite(9, LOW); } else if (t>22) { digitalWrite(8, HIGH); digitalWrite(7, LOW); digitalWrite(9, LOW); } else if (t>=35) { digitalWrite(9, HIGH); digitalWrite(7, LOW); digitalWrite(8, LOW); } }

1 टिप्पणी:

  1. Companies that produce industrial chemicals require products that are safe, rugged and resist chemical attack and wear. They produce magnetic and mechanical float level sensors, chemical compatibility, temperature and viscosity.
    Chemical Level Sensor

    उत्तर द्याहटवा