2009-11-03 12 views
5

मैं LilyPad Temperature sensor को LilyPad Arduino 328 Main Board पर सटीक परिवेश तापमान रीडिंग पढ़ने के लक्ष्य के साथ कनेक्ट कर रहा हूं। सेंसर शक्ति प्राप्त कर रहा है और एक प्रतिक्रिया दे रहा है मैं धारावाहिक पर पढ़ने में सक्षम हूँ।Arduino Lilypad तापमान सेंसर से परिवेश Temp कैसे प्राप्त करें

जिस समस्या का सामना मैं कर रहा हूं वह यह है कि सेंसर से पढ़ना मुझे बहुत असामान्य दे रहा है - हालांकि लगातार संख्याएं। मैं अनुरूप सेंसर इनपुट पढ़ने और इस तरह वोल्ट में कनवर्ट कर रहा हूँ ...

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); 
} 

यह लगभग 1.1 वोल्ट का एक सुसंगत पढ़ने जो सेंसर प्रलेखन इंगित करता है के बारे में 60 डिग्री सेल्सियस परिवेश अस्थायी होगा पैदावार जब सही परिवेश अस्थाई लगभग 23 डिग्री है। संवेदक किसी भी अन्य इलेक्ट्रॉनिक्स के निकट निकटता में नहीं है, इसलिए मैं यह नहीं देख सकता कि समस्या है।

क्या सेंसर पढ़ने के लिए मेरा कोड गलत है? क्या मेरा सेंसर दोषपूर्ण हो सकता है?

उत्तर

7

लिलीपैड 3.3V arduino नहीं है, तो इसका मतलब है कि यह (3.3/1024.0) होना चाहिए, जो 0.726V, या 22.6 सी होगा?

0

इस documentation के अनुसार, एनालॉगरेड एक पूर्णांक देता है। क्या आपने इसे फ्लोट पर कास्ट करने का प्रयास किया है:

therm = (float)analogRead(2); 

सेंसर वोल्टेज वोल्टमीटर पर क्या पढ़ता है? जब आप सेंसर के तापमान को बदलते हैं तो क्या पठन बदल जाता है? (इस पर अपना हाथ पकड़ना पढ़ने के लिए पर्याप्त होना चाहिए।)

+1

आप सुरक्षित रूप से पूर्णांक डाली कर सकते हैं: मैं बिल्कुल वैसा ही problem.read अधिक यहाँ था। मूल जवाब उपयोगी होगा, यद्यपि। – FryGuy

3

इसे आजमाएं। -> नाव ग में (कुछ परिशुद्धता नुकसान के साथ) 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 
} 
संबंधित मुद्दे