energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
794 stars 672 forks source link

Reading built-in temperature sensor on Stellaris launchpad #560

Closed RobisLV closed 9 years ago

RobisLV commented 9 years ago

Hi! 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, appart from random-like stuttering. What could be the problem here?

rei-vilo commented 9 years ago

May I recommend you a better place to post your question and receive more answers from other users?

Try the special threads

RobisLV commented 9 years ago

Ok, I will try to place a post there.