Project tutorial
Temp/Humidity LCD Box

Temp/Humidity LCD Box

Arduino + LCD + DHT11 sensor + Lego = Awesome temp/humidity display

  • 3,291 views
  • 3 comments
  • 9 respects

Components and supplies

About this project

Most of us rely on weather app to check temperature and humidity. However, it's still a difference between how it really feels like indoor and outdoor. So I decided to make one that will be installed inside of the house. That way, I can have a better understanding of when to turn on/off the heater and humidifier.

Code

Temp/Humidity Sensor with LCDC/C++
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <dht11.h>

LiquidCrystal_I2C __flagI2CLCD( 0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
dht11 __flagDHT11;
unsigned long __lastDHT11Time = 0;

int __getDHT11Temp(int dataPin) {
  if((millis() - __lastDHT11Time <= 150) && __lastDHT11Time > 0)
    return __flagDHT11.temperature;
  if(__flagDHT11.read(dataPin) == DHTLIB_OK) {
    __lastDHT11Time = millis();
    return __flagDHT11.temperature;
  } else
    return -1;
}

String __rightPaddingStr(String content, int width) {
  int len = content.length();
  for(int i = 0;i < (width - len);i++)
    content += " ";
  return content;
}

int __getDHT11Humi(int dataPin) {
  if((millis() - __lastDHT11Time <= 150) && __lastDHT11Time > 0)
    return __flagDHT11.humidity;
  if(__flagDHT11.read(dataPin) == DHTLIB_OK) {
    __lastDHT11Time = millis();
    return __flagDHT11.humidity;
  } else
    return -1;
}


void setup() {
  __flagI2CLCD.begin(16,2);
}

void loop() {
  __flagI2CLCD.setCursor(0, 0);
  __flagI2CLCD.print(__rightPaddingStr(String((String(__getDHT11Temp(2)) + String(char(223)) + String(u8"C"))), 16));
  __flagI2CLCD.setCursor(0, 1);
  __flagI2CLCD.print(__rightPaddingStr(String((String(__getDHT11Humi(2)) + String(u8"%"))), 16));
  delay(2000);

}

Schematics

Arduino + LCD + DHT11 Sensor
0901 bb laimt8m59v

Comments

Similar projects you might like

Portable Arduino Temp/Humidity Sensor with LCD

Project tutorial by ThothLoki

  • 207,707 views
  • 132 comments
  • 283 respects

Soil Moisture Sensor With LCD Display

Project tutorial by Patel Darshil

  • 35,971 views
  • 10 comments
  • 55 respects

DHT11 Humidity + Temperature Sensor with 16x2 LCD display

Project showcase by onatto22

  • 25,288 views
  • 6 comments
  • 42 respects

Making LCD Thermometer With Arduino And LM35/36

Project tutorial by Konstantin Dimitrov

  • 88,880 views
  • 19 comments
  • 73 respects

Arduino LCD Thermostat

Project tutorial by Arduino “having11” Guy

  • 21,550 views
  • 26 comments
  • 42 respects
Add projectSign up / Login