14 Oct 2013 Thermometer and Humidity Control
 |  Category: Electronics  | Tags:

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:

Thermometer_bb

Code as follows:

#include 
#include 
#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 = DHT11.read(DHT11PIN);
  // Serial.print("Read sensor: ");
  switch (chk)
  {
    case DHTLIB_OK: 
               // Serial.println("OK"); 
                break;
    case DHTLIB_ERROR_CHECKSUM: 
               // Serial.println("Checksum error"); 
                break;
    case DHTLIB_ERROR_TIMEOUT: 
               // Serial.println("Time out error"); 
                break;
    default: 
                lcd.println("Unknown error"); 
                break;
  }
  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);
    lcd.print("H1");
  }
  else {
    digitalWrite(RELAY1,LOW);
    // lcd.print("H0");
  }
  if(DHT11.temperature < 25){ 
    digitalWrite(RELAY2, HIGH);
    // lcd.print("T1");
  }
  else {
  digitalWrite(RELAY2,LOW);
  lcd.print("T0");
  }
  delay(900000);
}

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

 

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Responses

  1. 1
    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! 😀

  2. 2
    Dushyant 

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

Leave a Reply