Arduino LilyPad 온도 센서에서 주변 온도를 얻는 방법
-
12-09-2019 - |
문제
나는 연결하고있다 백합 온도 센서 a Lilypad Arduino 328 메인 보드 상당히 정확한 주변 온도 판독 값을 읽는 것을 목표로합니다. 센서는 전원을 수신하고 연속에 대해 읽을 수있는 응답을 제공합니다.
제가 직면 한 문제는 센서에서 읽는 것이 일관된 숫자라는 비록 매우 드문 일을한다는 것입니다. 아날로그 센서 입력을 읽고 이와 같은 볼트로 변환하고 있습니다 ...
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);
}
이는 센서 문서가 진정한 주변 온도가 약 23 도일 때 섭씨 약 60 도의 앰비언트 온도가 될 것으로 예상되는 약 1.1 볼트의 일관된 판독 값을 산출합니다. 센서는 다른 전자 제품에 근접하지 않으므로 문제가되는 것을 예견 할 수 없습니다.
센서를 읽는 코드가 잘못 되었습니까? 내 센서가 결함이있을 수 있습니까?
해결책
릴리 패드는 3.3V arduino가 아니므로 (3.3/1024.0)
, 어느 쪽은 0.726V 또는 22.6 C입니까?
다른 팁
이 시도. 나는 정확히 같은 문제가있었습니다. 여기에서 더 읽으십시오. 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
}
이것에 따르면 선적 서류 비치, Analogread는 정수를 반환합니다. 그렇게 부유물에 캐스팅 해보 셨나요?
therm = (float)analogRead(2);
센서 전압은 전압계에서 무엇을 읽습니까? 센서의 온도를 변경할 때 읽기가 변경됩니까? (손을 잡고 독서를 바꾸기에 충분해야합니다.)
제휴하지 않습니다 StackOverflow