Project tutorial
Temp/Humidity LCD Box

Temp/Humidity LCD Box

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

  • 1,871 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

Arduino Bluetooth Basic Tutorial

by Mayoogh Girish

  • 455,007 views
  • 42 comments
  • 239 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 286,084 views
  • 95 comments
  • 672 respects

Security Access Using RFID Reader

by Aritro Mukherjee

  • 229,740 views
  • 38 comments
  • 239 respects

OpenCat

Project in progress by Team Petoi

  • 196,322 views
  • 154 comments
  • 1,364 respects
Add projectSign up / Login