user2780027
Published © GPL3+

Temp and Humidity Sensor

This project uses a DHT11 humidity and temperature sensor for detection, then displays it on a 16 X 2 LCD display.

BeginnerShowcase (no instructions)15 minutes5,162
Temp and Humidity Sensor

Things used in this project

Hardware components

RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
it actually needs to be on a board with three pins coming out.
×1
Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

lcd wiring

do this and wire dht11 to pin 2

Code

arduino code

C/C++
the entire code, ready to run
#include <SimpleDHT.h>
#include <LiquidCrystal.h> // include the libraries
LiquidCrystal lcd(7,8,9,10,11,12); //start the lcd code
byte customChar[8] = { // make a degrees symbol
  0b00110,
  0b01001,
  0b01001,
  0b00110,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

// for DHT11, 
//      VCC: 5V or 3V
//      GND: GND
//      DATA: 2
//for lcd follow picture because wiring is more complex
int pinDHT11 = 2;
SimpleDHT11 dht11;

void setup() {
  Serial.begin(9600);
    lcd.createChar(0, customChar);
    lcd.begin(16, 2);
     
}

void loop() {
  // start working...
  // read without samples.
  byte temperature = 0;
  byte humidity = 0;
  if (dht11.read(pinDHT11, &temperature, &humidity, NULL)) {
    lcd.print("Read DHT11 failed.");
    return;
  }
  

  lcd.print((int)temperature * 1.8 + 32); lcd.write((uint8_t)0);
  lcd.print("Fahrenheit"); // write the temperature note: just delete * 1.8 + 32 //to display
  // in celcius
    lcd.setCursor(0, 1); // now write on the bottom line
  lcd.print((int)humidity); lcd.println("%Humidity");
  
  // DHT11 sampling rate is 1HZ.
  delay(1000);
  lcd.clear();
}

Credits

user2780027

user2780027

1 project • 1 follower

Comments