RobisLV 0 Posted January 31, 2015 Share Posted January 31, 2015 Hello, fellow launchpad enthusiasts!I am having problems reading temperature sensor values on my stellaris launchpad (LM4F120H5QR). The values returned by analogRead(TEMPSENSOR) are erratic and do not correlate with actual temperature. I use ubuntu 14.04 and energia 0101E0014. I tried following code: uint32_t TempRead = 0; float TempC = 0; void setup() { Serial.begin(9600); analogRead(TEMPSENSOR); } void loop() { TempRead = analogRead(TEMPSENSOR); TempC = (float)(1475 - ((2475*TempRead)/4096))/10; Serial.print("ADC value: "); Serial.println(TempRead); Serial.print("Temperature in C: "); Serial.println(TempC); Serial.println("------------------------"); delay(1000); } While runnning this code and putting my finger on MCU this code gives: ADC value: 1939 Temperature in C: 32.40 ------------------------ ADC value: 1871 Temperature in C: 34.50 ------------------------ ADC value: 1899 Temperature in C: 32.80 ------------------------ ADC value: 1895 Temperature in C: 33.00 ------------------------ ADC value: 1895 Temperature in C: 33.00 ------------------------ ADC value: 1899 Temperature in C: 32.80 ------------------------ ADC value: 1899 Temperature in C: 32.80 ------------------------ ADC value: 1895 Temperature in C: 33.00 ------------------------ ADC value: 1899 Temperature in C: 32.80 ------------------------ ADC value: 1899 Temperature in C: 32.80 ------------------------ ADC value: 1895 Temperature in C: 33.00 ------------------------ ADC value: 1899 Temperature in C: 32.80 Basicaly no changes in reading, apart from random-like stuttering. Anyone have an idea what could be the problem here? Quote Link to post Share on other sites
L.R.A 78 Posted February 1, 2015 Share Posted February 1, 2015 The temperature seems correct, did you try to heat up the chip in some way?Note that the temperature should be above the ambient temperature. It's the temperature inside the chip and like any processor it heats up a bit. Quote Link to post Share on other sites
RobisLV 0 Posted February 1, 2015 Author Share Posted February 1, 2015 Thank you for answer! This was very silly of me, indeed the processor heats up and my finger was about the same temperature, therefore that did not make any change. I tried heating it up using hair dryer and cooling it by putting it near opened windows and it seams it works. Sorry for "false alarm" Quote Link to post Share on other sites
L.R.A 78 Posted February 1, 2015 Share Posted February 1, 2015 That sensor isn't the best to get real temperatures, it's usually used to detect changes in temperature, it even needs a different calibration value from chip to chip if I am not mistaken.If you want both real ambient temperature and good absolute values it's best to use a external sensor. Quote Link to post Share on other sites
RobisLV 0 Posted February 1, 2015 Author Share Posted February 1, 2015 Thank you for advice, I will try using an LM35 instead Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.