Pregunta

Estoy conectando un href="http://www.sparkfun.com/commerce/product_info.php?products_id=8777" rel="nofollow noreferrer"> Sensor de temperatura a un Arduino LilyPad 328 Main Board con el objetivo de leer las lecturas de temperatura ambiente bastante exactas. El sensor está recibiendo alimentación y dando un respuestas que soy capaz de leer una serie.

El problema que estoy enfrentado con es que la lectura del sensor me está dando muy inusual - aunque los números consistentes. Estoy leyendo la entrada del sensor analógico y conversión en voltios como este ...

loop(){
    float therm;   
    therm = analogRead(2); // Read from sensor through Analog 2
    therm *= (5.0/1024.0); // 5 volts / 1024 units of analog resolution
    delay(100);
}

Esto produce una lectura constante de aproximadamente 1,1 voltios que la documentación del sensor indica que sería una temp ambiente de aproximadamente 60 grados Celsius cuando el verdadero temp ambiente es de aproximadamente 23 grados. El sensor no está cerca de las proximidades de cualquier otra electrónica así que no puedo prever que el principal problema.

Es mi código para leer el sensor incorrecto? Podría mi sensor esté defectuoso?

¿Fue útil?

Solución

No es la lilypad un Arduino 3,3 V, lo que significa que se debe (3.3/1024.0), lo que sería 0.726V, o 22.6 C?

Otros consejos

Probar. Tenía exactamente la misma problem.read más aquí: http://www.ladyada.net /learn/sensors/tmp36.html

//TMP36 Pin Variables
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
                        //the resolution is 10 mV / degree centigrade with a
                        //500 mV offset to allow for negative temperatures

#define BANDGAPREF 14   // special indicator that we want to measure the bandgap

/*
 * setup() - this function runs once when you turn your Arduino on
 * We initialize the serial connection with the computer
 */
void setup()
{
  Serial.begin(9600);  //Start the serial connection with the computer
                       //to view the result open the serial monitor 
  delay(500);
}

void loop()                     // run over and over again
{
  // get voltage reading from the secret internal 1.05V reference
  int refReading = analogRead(BANDGAPREF);  
  Serial.println(refReading);

  // now calculate our power supply voltage from the known 1.05 volt reading
  float supplyvoltage = (1.05 * 1024) / refReading;
  Serial.print(supplyvoltage); Serial.println("V power supply");

  //getting the voltage reading from the temperature sensor
  int reading = analogRead(sensorPin);  

  // converting that reading to voltage
  float voltage = reading * supplyvoltage / 1024; 

  // print out the voltage
  Serial.print(voltage); Serial.println(" volts");

  // now print out the temperature
  float temperatureC = (voltage - 0.5) * 100 ;   //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((volatge - 500mV) times 100)
  Serial.print(temperatureC); Serial.println(" degress C");

  // now convert to Fahrenheight
  float temperatureF = (temperatureC * 9 / 5) + 32;
  Serial.print(temperatureF); Serial.println(" degress F");

  delay(1000);                                     //waiting a second
}

De acuerdo con esta , analogRead devuelve un entero. ¿Ha intentado arrojarlo a un flotador de este modo:

therm = (float)analogRead(2);

Lo que hace el voltaje del sensor de lectura de un voltímetro? ¿Cambia la lectura cuando cambia la temperatura del sensor? (La celebración de su mano en la que debería ser suficiente para cambiar la lectura.)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top