arduinocreator123
Published

Temperature and humidity sensor

This is an easy project to measure temperature and humidity using an DHT11 sensor and an LCD display.

BeginnerShowcase (no instructions)1,853
Temperature and humidity sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Grove - 16 x 2 LCD (Black on Red)
Seeed Studio Grove - 16 x 2 LCD (Black on Red)
×1
Resistor 221 ohm
Resistor 221 ohm
×1
Rotary Potentiometer, 10 kohm
Rotary Potentiometer, 10 kohm
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
The 4 pins DHT11 will be an option as well
×1

Story

Read more

Schematics

imagen_para_arduino_yWAYbOWqPU.jpeg

Code

Code

Arduino
This is the code i used
// include the library code:
#include <LiquidCrystal.h>
#include "DHT.h"

// set the DHT Pin
#define DHTPIN 8

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  dht.begin();
  
  // Print a message to the LCD.
  lcd.print("Temp:  Humidity:");
}

void loop() {
  delay(500);
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // read humidity
  float h = dht.readHumidity();
  //read temperature in Fahrenheit
  float f = dht.readTemperature(true);

  if (isnan(h) || isnan(f)) {
    lcd.print("ERROR");
    return;
  }

  lcd.print(f);
  lcd.setCursor(7,1);
  lcd.print(h);  
}

Credits

arduinocreator123

arduinocreator123

1 project • 0 followers

Comments