How accurate is this? Thermometer with arduino uno

So I built this a couple of years ago, believe it or not, and haven’t really used it. Well, it’s getting hot again and my room is getting groggy. So I want to see what my temperature in my room is using this, since I already got it :stuck_out_tongue:

I’m using a RGB-LED, and assigning the values of red/green/blue based on the temperature. I didn’t make the “formula” for the color that accurate, it was mostly based on try/fail.

However, I’m not worried about what color it shows in color as much as I am it showing the correct temperature.

Here’s the code I’ve got currently.

const int TEMP_PIN = 6;
const int RED_LED_PIN = 9;
const int GREEN_LED_PIN = 10;
const int BLUE_LED_PIN = 11;

int redIntensity = 0;
int greenIntensity = 0;
int blueIntensity = 0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
 float temperature = getVoltage(TEMP_PIN);
 temperature = ((temperature - .5) * 100)*1.2;
 
 Serial.println(temperature);
 if(temperature >= 10.00 && temperature <= 255){
   blueIntensity = temperature + 120;
   analogWrite(BLUE_LED_PIN, blueIntensity);
 }
 if(temperature >= 70.00 && temperature <= 255){
   blueIntensity -= 40;
   greenIntensity = temperature + 100;
   analogWrite(BLUE_LED_PIN, blueIntensity);
   analogWrite(GREEN_LED_PIN, greenIntensity);
 }
 if(temperature >= 80.00 && temperature <= 255){
   blueIntensity = 0;
   greenIntensity = 0;
   redIntensity = temperature + 90;
   analogWrite(BLUE_LED_PIN, blueIntensity);
   analogWrite(GREEN_LED_PIN, greenIntensity);
   analogWrite(RED_LED_PIN, redIntensity);
 }
 delay(1000);
}
float getVoltage(int pin){
 return (analogRead(pin) * .004882814);
}

Here’s what the current output is in my room (It feels hotter than 75 degrees, hence why I’m asking if my data is accurate):

116.99
96.97
86.23
80.86
78.42
76.95
76.46
75.98
75.98
75.98
75.98
75.98
75.98
75.98
75.98
75.49
75.49
75.49

It starts high and then it eventually drops down to what it’s reading. So it didn’t suddenly drop 40 degrees.

Thanks all for your time.

try putting a thermometer next to the sensor and checking

BulldogLowell: try putting a thermometer next to the sensor and checking

I actually don't have one :astonished:

SimpleMindedMan:

BulldogLowell: try putting a thermometer next to the sensor and checking

I actually don't have one :astonished:

0 and 100 are easy enough to check, even if you live at high altitude. If you can't come at that, try investing $3 in a sensor that you can have more faith in, like a DS18B20.

As it happens, a simple thermistor can be pretty good over a narrow range like room temperatures. If that is what you are using, I would be more inclined to trust it than your feelings. The strange initial readings are probably some aberration, easily fixed or easily ignored.

We need a datasheet for your sensor.

Sorry for the late reply, got busy.

Nick_Pyner:

SimpleMindedMan: 0 and 100 are easy enough to check, even if you live at high altitude. If you can't come at that, try investing $3 in a sensor that you can have more faith in, like a DS18B20.

As it happens, a simple thermistor can be pretty good over a narrow range like room temperatures. If that is what you are using, I would be more inclined to trust it than your feelings. The strange initial readings are probably some aberration, easily fixed or easily ignored.

I'm using a TMP36. It came in a kit I bought some time ago. I haven't been to an electronics store (like, one that carries parts and not tvs etc) in a while. I need to rewire my current project because looking at it again, it looks like mass chaos.

Jiggy-Ninja: We need a datasheet for your sensor.

http://www.analog.com/static/imported-files/data_sheets/TMP35_36_37.pdf

SimpleMindedMan: I'm using a TMP36. It came in a kit I bought some time ago.

OK, the same applies and you can still check it if you need to. Maybe the code is a little bit rough, but the TMP36 itself is popular and reputable.

Nick_Pyner:

SimpleMindedMan: I'm using a TMP36. It came in a kit I bought some time ago.

OK, the same applies and you can still check it if you need to. Maybe the code is a little bit rough, but the TMP36 itself is popular and reputable.

Yeah the code is actually what I was wondering about. I wanted to know if it's accurate (just not the color showing part, I'll work the kinks out on that on my own :) )

I'm a DS18B20 user, so I can't comment. If it is reading something close to what you expect it is probably OK. When I said rough I just meant some minor procedural issue giving false readings at the start.

if(temperature >= 70.00 && temperature <= 255){
blueIntensity -= 40;

so as long as the temperature is between these values you keep on subtracting 40 from blueIntensity.
Think that should read

if(temperature >= 70.00 && temperature <= 255){
blueIntensity = Temperature - 40;

robtillaart:
if(temperature >= 70.00 && temperature <= 255){
blueIntensity -= 40;

so as long as the temperature is between these values you keep on subtracting 40 from blueIntensity.
Think that should read

if(temperature >= 70.00 && temperature <= 255){
blueIntensity = Temperature - 40;

Yeah I wrote this when I was new to programming. It honestly was one of my first projects. That’s actually why I’m trying to figure out the accuracy of the temperature.
I haven’t gotten the time to rewrite the color codes. I’m going to rework all the colors because reading it now, it looks bad. I want to dictate each color in it’s own method and give a more reasonable scale, because I don’t see me going anywhere near 255 degrees in temperature. I believe I did that just because the values the light can be are 0-255.
Thanks for the heads up though ^.^