LCD Thermomter Problem

Hi, guys it's Dylon J. again with a thermometer for my room. I want to make a thermometer with arduino. I've begun the process and tested the project (not in an enclosure yet) and the results are weird. I see that the temperature is very inaccurate. It's jump from 60 -80 on both sensors. What's going on? Also, I need the proper conversion code or equation. I just threw together a quick little equation. Any advice? Here's my code:

#include<LiquidCrystal.h>
int therm1 = A0;
int therm2 = A1;
float tempout; 
float tempin; 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
 Serial.begin(9600);
 lcd.begin(16,2); 
 pinMode(therm1,0);
 pinMode(therm2,0);
}

void loop()
{
  therm1 = analogRead (A0);
  therm2 = analogRead (A1);
  Serial.println(therm1);
  Serial.println(therm2);
  tempin = therm1 / 6.290322581 ;
  tempout = therm2 / 6.319648094 ;
  lcd.setCursor(0,0);
  lcd.print(tempin);
  lcd.print(" F Inside");
  lcd.setCursor(0,1);
  lcd.print(tempout);
  lcd.print(" F Outside");
  delay(250);
 
}

Are you planning to give any hints about what you think you are using to measure the temperature, and how you have wired it up?

Looking at the code, I would take a guess they're analogue temp sensors.
You are right thinking that you need proper conversion code as analogRead A0/A1 just returns a value from 0-1023, not quite a temperature range you are looking for.

Adafruit has a tutorial for a TMP36/LM35/TMP35

Which shows the conversion code needed to get a good temperature for those sensors.Also you will get better results if you power the sensor from 3.3v and produce an average of your readings.

Some other types of analogue sensors use kelvin as the base for conversion and B value which is detailed in the datasheet.
I'm sure if you post the type and part number of your sensor this forum should be able to help you get a good reading from it.

I've wired it up via voltage divider circuit on ao and a1. Two different sensors. Make to make outside temperature and indoor temperature.

An "it" is?

You need help / we need help. What sensors are you using. If they are not working as expected, then just start with one to simplify things, till you get it working. What is it, and why use a voltage divider? I prefer the LM34 for affordable, and pretty good accuracy.

 pinMode(therm1,0);
 pinMode(therm2,0);

This is setting the mode of digital pins 14 and 15, on the 328-based machines. It does nothing for the analog pins 0 and 1. They are input only, so there is no need to set the mode for analog pins.

  tempin = therm1 / 6.290322581 ;
  tempout = therm2 / 6.319648094 ;

Floats have 6 to 7 digits of accuracy, not 9 or 10.

I was using a cheap 10k ntc thermistor so I need to wire it up using a voltage divider, and I'm broke so I can't afford the lm35 temp sensor.

If you have a
Volt Ohm meter, read the resistance of the thermistor. Use the fixed resistor of approximately the same value. What are the two values?

I thinks I'll use an LM35 temp sensor, because it's accurate. I think the problem could be some emf noise or something to make my reading a skew. Thanks for your help but I'll keep you updated on my progress.

The LM34 and LM35 are pretty much the same. The LM34 is accurate to one degree Fahrenheit , while the LM35 is accurate to one degree Celsius. Which makes the LM34 more accurate. You can always convert between Fahrenheit and Celsius in the scripts code. Either one you get, I am sure you will be happy with.

there is something wrong in the code you are using therm1 and therm2 twice and it is an integer so it will never float.

HI, I'm having deja vu here, I think there are a couple of threads on this forum dealing PT100s and PTC and NTC thermistors.
All recommending amplification and voltage shifting before analog reading.
In the end the cheapest and easiest is the suggestion by Jack, LM35 or LM34.

Tom... :slight_smile:

Depending on the application, there may be another reason to prefer the LM34 to the LM35. Unless you have a negative voltage supply available, the LM35 can only measure down to +2degC. The LM34 can measure down to +5degF without a negative supply, which is about -15degC.