Tag Archives: Arduino Indoor thermometer

Arduino Remote Control Indoor Thermometer

Happy Holidays everyone, its been a while since my last post but i have been a bit busy over the past few months. I have been working on a Infrared remote control version of my indoor thermometer. It has a menu and displays the current temperature in Celsius, Fahrenheit, and Kelvin.

Before i go any further i need to credit   and more specifically his instructable  on IR remotes and Arduino. Also credit is due to Ken Shirriff for the original IR remote libraries located on Git Hub.

For this project i used the same set up as with my previously posted indoor thermometer with the added TSOP4838 IR receiver and IR remote. The first task was decoding the IR signals from the remote i had which was very easy thanks to the previously mentioned instructable. Each button sends out a different signal and once you have the signals its a matter of just coding what you want done when said signal is recognized.

Here is the code.

#include <IRremote.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,7,6,5,4);

float temp;
int tempPin = 0;
int IRpin = 11;
IRrecv irrecv(IRpin);
decode_results results;
boolean menu = true;
boolean submenu = true;

byte degree[8] = {
  0b01111,
  0b01001,
  0b01001,
  0b01111,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
};

byte downArrow[8] = {
  0b00000,
  0b00000,
  0b00000,
  0b00100,
  0b00100,
  0b10101,
  0b01110,
  0b00100,
};

byte upArrow[8] = {
  0b00100,
  0b01110,
  0b10101,
  0b00100,
  0b00100,
  0b00000,
  0b00000,
  0b00000,
};



void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn(); //Start the receiver
  
  lcd.createChar(0, degree);
  lcd.createChar(1, downArrow);
  lcd.createChar(2, upArrow);
  lcd.begin(16, 2);
  
 
 
  
}

void loop()
{
  
  temp = analogRead(tempPin);
  float tempK = (((temp/1023) * 5)*100); //calculate Kelvin
  float tempF = (((tempK - 273.15)*1.8) + 32); //calculate Farenheit
  float tempC = (tempK - 273.15); //calculate Celsius

  if(irrecv.decode(&results))
    {
      irrecv.resume();
    }
    
  if (menu == true || results.value == 16738455) //menu page 1
    {
        menu = true;
        submenu = true;
        lcd.clear();
        lcd.print("1:Farenheit"); //menu
        lcd.setCursor(0,1);
        lcd.print("2:Kelvin");
        lcd.setCursor(15,1);
        lcd.write(byte(1));
        delay(1000);               
    }
    
  if (submenu == true && results.value == 16769055) //display menu page 2 by pressing the minus button while on menu page 1
    {
        menu = false;
        lcd.clear();
        lcd.print("3:Celsius");
        lcd.setCursor(15,0);
        lcd.write(byte(2));
        delay(1000);
    }
    
  if (submenu == true && menu == false && results.value == 16754775) //display menu page 1 by pressing the plus button while on menu page 2
    {
        lcd.clear();
        lcd.print("1:Farenheit"); //menu
        lcd.setCursor(0,1);
        lcd.print("2:Kelvin");
        lcd.setCursor(15,1);
        lcd.write(byte(1));
        delay(1000);      
    }
    
  if (results.value == 16724175)
    {
        submenu = false;
        menu = false;
        results.value = 0;
        Serial.println(tempF); //display Farenheit
        lcd.clear();
        lcd.print(tempF);
        lcd.write(byte(0));
        lcd.print("F");
        delay(1000);           
    }
    
  if (results.value == 16718055)
    {
        submenu = false;
        menu = false;
        results.value = 0;
        Serial.println(tempK); //display Kelvin
        lcd.clear();
        lcd.print(tempK);
        lcd.write(byte(0));
        lcd.print("K");
        delay(1000);
     }
     
  if (results.value == 16743045)
    {
        submenu = false;
        menu = false;
        results.value = 0;
        Serial.println(tempC); //display Ceslsius
        lcd.clear();
        lcd.print(tempC);
        lcd.write(byte(0));
        lcd.print("C");
        delay(1000);
    }
              

}

The remote i used which you can see in the pictures below is small with few options so i used the + & – button as up and down for the menu, and 1 2 & 3 to select which unit of measurement to display also i used the 0 button to go back to the menu.  Here are the pictures and schematic.

IR Indoor Thermometer
IR Indoor Thermometer

Just as a side note as to not confuse anyone in my pictures the potentiometer to adjust the temperature sensor has been removed. I had previously adjusted it to the correct setting and there was no need to leave it on.

If theres any questions about this or any of my other projects feel free to post them here. Hopefully ill post again before the new year but if not then Merry Christmas and Happy New Year to you all.

Arduino Indoor Thermometer Revised

I actually did this right after the amp but have been too busy to post it, or lazy. This is just a revised thermometer with the extra pot to zero in on the correct voltage to get an accurate temp reading.  If that is confusing then ill explain.

Here is the sketch i use to get the temp in Fahrenheit.

/* Indoor temperature with LM335Z temp sensor and being displayed
on a 16x2 LCD
by Travis Compton
2/6/15
*/

#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,7,6,5,4);

float temp;
int tempPin = 0;

byte degree[8] = {
  0b01111,
  0b01001,
  0b01001,
  0b01111,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
};



void setup() {
  Serial.begin(9600);
  
  lcd.createChar(0, degree);
  
  lcd.begin(16, 2);
  
}

void loop()
{
  
  temp = analogRead(tempPin);
  //calculate Kelvin
  float tempK = (((temp/1023) * 5)*100);
  //calculate Farenheit
  float tempF = (((tempK - 273.15)*1.8) + 32);
  
  Serial.println(tempF);
  lcd.clear();
  lcd.print(tempF);
  lcd.write(byte(0));
  lcd.print("F");
  delay(10000);
}

As you can see its quite simple. I first take the raw output from the temp sensor, convert it to Kelvin, then convert it to Fahrenheit. The reason we need that 3 pot is because of this formula in the sketch
tempK = (((temp/1023) * 5)*100)

We take the Analog read from the sensor and store it in temp, then divide that by 1023, then multiply that by 5, and lastly multiply that by 100 to get the temp in Kelvin. Whats important here is the multiply by 5 which is the voltage being fed to the sensor, which is not going to be a constant when using usb to power this project. If we where using a 9volt battery we would substitute the 5 for 9. So lets say we are only getting 4.6 volts from usb to power this project are temp will be off, here in lies the need for the 3 pot. Although with this method we would need another thermometer to verify are adjustments.

I hope i made this clear enough, if anyone has any questions just ask. Now for some pics.

Indoor thermometer w/ pot

And of course as always the fritzing schematic.

Indoor Temp with potentiometer_bb

Well thats it for this post. I have a lighted 3d cube im working on with some pictures from secret of mana on it, i would like to show this next, hopefully sometime this week.

Arduino Indoor Thermometer

I wanted to do a simple project for my newly acquired 16×2 LCD display, and thought I should do an indoor thermometer. I searched around a bit online but couldn’t find exactly what i wanted to do, most projects where indoor/outdoor. I did however find this great tutorial here on hooking up the 16×2 LCD with 2 pots.

I added my LM335z temperature sensor, hooked up my arduino, made a little sketch to output the temp to the serial monitor. It was 3 degrees off and that could have easily been fixed with a another pot however i only have 2 and used them for the LCD display. Here is a diagram i made with fritzing.

Indoor Temp_bb

And here is a very poor photo of the finished project.

Arduino Indoor Temp