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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s