Hello everyone,
I'm somewhat new to arduino, been playing with it for a couple weeks now and working on building my first project that will be put to pratical use. What I'm building is a temperature sensor for my truck since I don't have an outside temperature display in it
I ordered a couple of temp sensors from here:
https://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&productId=1468828&catalogId=10001&storeId=10001&krypto=9x3mj8umRTom0c3DLMNz0qFt1vE4yb2XEiH8QmS%2Fj5zJj6SsYWEyagtE9oUB5UUxmXu6IHyY9J5u
ryZd5zywy837CnQXRI3X&ddkey=http:StoreCatalogDrillDownView
At first I couldn't figure out how the temperature was being reported from this thing. It says in the data sheet (https://www.jameco.com/Jameco/Products/ProdDS/1468828.pdf) that it's calibrated directly in celsius. Well I thought that meant I didn't have to do the conversions to the reading like I do with the LM35 sensor that came with the arduino kit that I bought to begin with. That didn't seem to work out correctly though, so I went with the same method that I used with the LM35 that came with the kit and thought it was working, however it was returning the numbers in negatives. I thought maybe it was just a polarity issue but wiring the sensor the other way around results in it getting very hot very fast. So I just converted the negative to a positive and then went to test it. But when I went into another room in the house that was noticeably colder, the reading increased by ~3 degrees on the sensor.
Leading me to believe that perhaps the sensor is really really far off and the negative numbers were it saying the temperature was below 0... With the temperatures it's reading and judging from another thermometer nearby, it would mean this sensor is off by a little more than 90 degrees. Reading ~-18.5f in a room that is ~76f.
I dunno, I would consider it being a bad sensor but I bought two of them and they both exhibit the same behavior. With approximately the same temperature difference. I find it hard to believe that two sensors would both off by about the same amount especially when this far off. So I'm assuming I'm simply not calculating something correctly somewhere. Anyone have any ideas?
Here is the code I'm using atm for testing:
int tempPin=0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
float thisTemp=getVoltage(tempPin);
thisTemp=(thisTemp - .5) * 100;
thisTemp=(thisTemp * 1.8) + 32; //Convert to farenheit
Serial.println(thisTemp);
}
float getVoltage(int pin)
{
return (analogRead(pin) * .004882814);
}