Personal Blog – Dushyant

Thermometer and Humidity Control

by on Oct.14, 2013, under Electronics

The first thing that came to my mind when I started microcontroller programming was to set an automatic room heating cum humidifier system.

First off – bought a DHT11 sensor module. Then went about setting up the circuit. Added the LCD to boot – to show the temperature and humidity.

Set up the circuit as follows:


Code as follows:

#define DHT11PIN 13
#define RELAY1 2 // Connect humidifier to Relay1
#define RELAY2 3 // Connect heater to Relay2
#define TEMP_SET 20.0
#define HUM_SET 35.0

dht11 DHT11;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  lcd.begin(16, 2);
  pinMode(DHT11PIN, INPUT);
  pinMode(RELAY1, OUTPUT);
  pinMode(RELAY2, OUTPUT);

void loop() {
  // put your main code here, to run repeatedly: 
  int chk =;
  // Serial.print("Read sensor: ");
  switch (chk)
    case DHTLIB_OK: 
               // Serial.println("OK"); 
               // Serial.println("Checksum error"); 
               // Serial.println("Time out error"); 
                lcd.println("Unknown error"); 
  lcd.setCursor(0, 0);
  lcd.print("Humidity: ");
  lcd.print((float)DHT11.humidity, 2);
  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  lcd.print((float)DHT11.temperature, 2);
  if(DHT11.humidity < 50){ 
    digitalWrite(RELAY1, HIGH);
  else {
    // lcd.print("H0");
  if(DHT11.temperature < 25){ 
    digitalWrite(RELAY2, HIGH);
    // lcd.print("T1");
  else {

Worked like a charm – next steps:

  1. Add two buttons to change the temperature presets – save preset in EEPROM
  2. Create a standalone arduino so that I don’t have to give up my Induino for this small project



2 Comments for this entry

  • Tri Duc

    Dear Dushyant,

    I’m a newbies in arduino from Viet Nam, I knew about your project via hackaday. I have plan to build a project like your project. When I watch your circuit, I don’t know what is second small component, which is second from left, what’s it doing? Can you explain for me!
    Sr for bad in English! 😀

  • Dushyant

    That’s a variable resistor, and adjusts the contrast on the LCD screen.

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!


A few highly recommended websites...