Go Down

Topic: Ardunio DUE & LM35 (Read 1 time) previous topic - next topic

tv_freak

Hi can't get Ardunio DUE & LM35 to work for me. Works great on MEGA-ADK board.
I get 91 Analog read & 41 degree C for first reading
then ZERO for all other readings

int potPin = 0;                             //input read pin for LM35 is Analog Pin 0
void setup()
{
  Serial.begin(9600);
}

void loop ()                             
{
  int aRead = 0;
  aRead = analogRead(potPin);

  Serial.print("Analog = ");
  Serial.print(aRead);
 
  float tempC = (((aRead * 5000) / 1024.0) ) / 10.0 ;
 
  Serial.print("     Temp = ");
  Serial.println(tempC);
  delay(3000);
}

Graynomad

float tempC = (((aRead * 5000) / 1024.0) ) / 10.0 ;

I haven't used the Due yet but it's a 3v3 system, so wouldn't that value be 3300?

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

shteii01

From Adafruit TMP36 tutorial:
Voltage at pin in milliVolts = (reading from ADC) * (3300/1024)
This formula converts the number 0-1023 from the ADC into 0-3300mV (= 3.3V)

Go Up