LED Room Thermometer Circuit using Arduino

In this article, we are going to construct a LED room thermometer circuit using Arduino, which displays the readings in doted/bar LEDs. This project can be implemented for applications where ambient temperature plays a crucial role or it could be built just as another fun project for your home.

 

By: Girish Radhakrishnan

The heart and brain of the project is DTH11 sensor and Arduino respectively. We are going to extract only the temperature data from the sensor.

The arduino will infer the data and refresh the displayed temperature every few seconds.

We are going to take 12 resolutions of temperature sensor, in other words, we are going to take the temperature range where the ambient temperature usually vary.

If you wish to add more resolution/LEDs, you will need arduino mega to take advantage of whole temperature spectrum of the sensor with modified program.

The above illustrated layout may be adopted for best looking for your setup.

The user just needs to enter the minimum temperature range of the room. It can be a rough value, which can be later changed once full hardware setup is completed.

If the temperature range goes below the threshold value that user entered, no LED will glow and if the temperature goes beyond the maximum range (minimum + 11) all LED would glow.

If there are any sensor connectivity issues, all the LED will blink every second simultaneously.

 

The circuit:

The Arduino LED room thermometer circuit wiring is very simple, a series of LED connected to GPIO pins ranging from 2 to 13 with current limiting resistors, and DHT11 sensor is plugged to analog I/O pins, which is programmed to give power supply to sensor as well as read data.

Thus, your LED room thermometer circuit setup is complete and ready to upload the code. It is always recommended to test the circuit on bread board before making it permanent.

Tip: Use different color LED for indicating different temperature ranges. You may use blue LEDs for lower temperature range, green or yellow for mid temperature range and red LEDs for higher temperature. This will make more attractive.

 

Author’s prototype:

NOTE: The following program is only compatible with DHT11 sensor.

 

Program Code:

//-------Program developed by R.Girish------//
#include<dht.h>
int a=2;
int b=3;
int c=4;
int d=5;
int e=6;
int f=7;
int g=8;
int h=9;
int i=10;
int j=11;
int k=12;
int l=13;
int p=A0;
int data=A1;
int n=A2;
int ack;
dht DHT;
int temp=25;   // set temperature range.
void setup()
{
Serial.begin(9600); // may be removed after testing.
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(e,OUTPUT);
pinMode(f,OUTPUT);
pinMode(g,OUTPUT);
pinMode(h,OUTPUT);
pinMode(i,OUTPUT);
pinMode(j,OUTPUT);
pinMode(k,OUTPUT);
pinMode(l,OUTPUT);
pinMode(p,OUTPUT);
pinMode(n,OUTPUT);
digitalWrite(p,HIGH);
digitalWrite(n,LOW);
}
void loop()
{
// may be removed after testing.
Serial.print("Temperature(°C) = ");
Serial.println(DHT.temperature);
Serial.print("Humidity(%) = ");
Serial.println(DHT.humidity);
Serial.print("n");
//till here
ack=0;
int chk = DHT.read11(data);
switch (chk)
{
case DHTLIB_ERROR_CONNECT:
ack=1;
break;
}
if (ack==0)
{
if(DHT.temperature>=temp)digitalWrite(a,HIGH);
if(DHT.temperature>=temp+1)digitalWrite(b,HIGH);
if(DHT.temperature>=temp+2)digitalWrite(c,HIGH);
if(DHT.temperature>=temp+3)digitalWrite(d,HIGH);
if(DHT.temperature>=temp+4)digitalWrite(e,HIGH);
if(DHT.temperature>=temp+5)digitalWrite(f,HIGH);
if(DHT.temperature>=temp+6)digitalWrite(g,HIGH);
if(DHT.temperature>=temp+7)digitalWrite(h,HIGH);
if(DHT.temperature>=temp+8)digitalWrite(i,HIGH);
if(DHT.temperature>=temp+9)digitalWrite(j,HIGH);
if(DHT.temperature>=temp+10)digitalWrite(k,HIGH);
if(DHT.temperature>=temp+11)digitalWrite(l,HIGH);
delay(2000);
goto refresh;
}
if (ack==1)
{
// This may be removed after testing.
Serial.print("NO DATA");
Serial.print("nn");
// till here
delay(500);
digitalWrite(a,1);
digitalWrite(b,1);
digitalWrite(c,1);
digitalWrite(d,1);
digitalWrite(e,1);
digitalWrite(f,1);
digitalWrite(g,1);
digitalWrite(h,1);
digitalWrite(i,1);
digitalWrite(j,1);
digitalWrite(k,1);
digitalWrite(l,1);
refresh:
delay(500);
digitalWrite(a,0);
digitalWrite(b,0);
digitalWrite(c,0);
digitalWrite(d,0);
digitalWrite(e,0);
digitalWrite(f,0);
digitalWrite(g,0);
digitalWrite(h,0);
digitalWrite(i,0);
digitalWrite(j,0);
digitalWrite(k,0);
digitalWrite(l,0);
}
}
//-------Program developed by R.Girish------//

NOTE 1:

In the program:

int temp=25;   // set temperature range.
Replace “25” with your minimum ambient temperature that you have encountered in past with other thermometers or predict a rough value.
NOTE 2: Please verify the temperature readings from the serial monitor and the LED setup.



5 thoughts on “LED Room Thermometer Circuit using Arduino

  1. Have questions? Please feel free to post them through comments! Comments will be moderated and solved ASAP.
  2. Hai ,
    i am padmanaban , i have seen lots of interesting projects on the web and giving solutions to the problems also. great and excelent.
    can you help me to my circuit problem, here i have attached the diagram , the problem is serial communication ,
    i am using atmega 16, AVR Studio, through usbapp programmer , avrdude.exe, this is the code: when i connect to the computer hyperterminal to see serial communication from microcontroller to PC terminal i am getting 95 , 47 instead 65 for A 66 for B on the terminal, BUT for U ie 85 in Decimal;, 0x55in Hex, it is showing correctly on hypertermial as 85 – ie U,

    I tried with 8 Mhz, 4 Mhz ,16Mhz, 14.7456 Mhz external crystals,
    Can you please Help me where I am doing Wrong,

    Thanks ,
    below is my Avr code and circuit diagram,

    #include
    #include
    #include
    #include

    void send_char (char ch);
    void mes2usart1 (char *ptr);

    int main (void)
    {
    // initialize serial port
    sei();
    UCSRB = 0x98;
    UCSRC = 0x06;
    UBRRL = 103; // 9600 16mhz
    UBRRH = 0;
    //UBRRL = 95; //9600 14.7456 // 9600 BAU //UBRRL = 51; // 9600 8mhz //UBRRL = 103; // 4800 8mhz
    //UBRRL = 51; // 9600 4mhz //UBRRL = 103; // 4800 4mhz

    while (1)
    {
    mes2usart1 ("AB");
    // UDR=0x55;
    _delay_ms(3000);
    }
    }

    void mes2usart1 (char *ptr)
    {
    while (*ptr)
    send_char (*ptr++);
    }

    ISR (USART_RXC_vect)
    {
    unsigned char tmp;
    tmp = UDR; // get data received through serial port
    UDR = tmp; // send back data to serial port
    mes2usart1 ( tmp);
    }

    void send_char (char ch)
    {
    UDR = ch;
    while (!(UCSRA & 0x40));
    UCSRA |= 0x40;
    }



Leave a Comment