믿을만 한건가...?
// Internal Temperature Sensor
// Example sketch for ATmega328 types.
//
// April 2012, Arduino 1.0
void setup()
{
Serial.begin(9600);
Serial.println(F("Internal Temperature Sensor"));
}
void loop()
{
// Show the temperature in degrees Celcius.
Serial.println(GetTemp(),1);
delay(1000);
}
double GetTemp(void)
{
unsigned int wADC;
double t;
// The internal temperature has to be used
// with the internal reference of 1.1V.
// Channel 8 can not be selected with
// the analogRead function yet.
// Set the internal reference and mux.
ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));
ADCSRA |= _BV(ADEN); // enable the ADC
delay(20); // wait for voltages to become stable.
ADCSRA |= _BV(ADSC); // Start the ADC
// Detect end-of-conversion
while (bit_is_set(ADCSRA,ADSC));
// Reading register "ADCW" takes care of how to read ADCL and ADCH.
wADC = ADCW;
// The offset of 324.31 could be wrong. It is just an indication.
t = (wADC - 324.31 ) / 1.22;
// The returned temperature is in degrees Celcius.
return (t);
}
|
실내온도 25도
손으로 대면 약간 따스함이 느껴지는걸 봐서는 37도~38도 정도 되지 않을까 싶은데...
19.4도는 손을 댄 시점..
20.2 20.2 20.2 21.1 20.2 20.2 20.2 21.1 20.2 21.1 20.2 20.2 19.4 19.4 18.6 19.4 19.4 20.2 19.4 20.2 21.1 20.2 20.2 20.2 20.2 20.2 20.2 21.1 20.2 21.1 20.2 21.1 20.2 |
그냥 레지스터 출력
349.0 349.0 349.0 348.0 348.0 348.0 348.0 348.0 349.0 349.0 348.0 349.0 349.0 |
[링크 : http://playground.arduino.cc/Main/InternalTemperatureSensor]
2016/03/31 - [embeded/arduino(genuino)] - 아두이노 나노 내장 온도센서
아무튼.. 아래 계산식에 의해 349를 계산해보면
349 = (Vin * 1024) / 1.1
Vin = (349 * 1.1) / 1024
Vin = 0.37490234375 = 374mV 인가?
![](https://t1.daumcdn.net/cfile/tistory/254B2438570B710724)
대충.. 10bit니까 1024.. rev가 1.1로 내장 전원을 쓰니
단순하게(?) 출력으로 나오는 값에서 10으로 나눠주면 되려나?
그런데.. k랑 Tos값은 제품 테스트의 일부로 EEPROM에 테스트 해서 저장해야 한다고?!?!
[링크 : http://www.atmel.com/images/...328p_datasheet_complete.pdf]
![](https://t1.daumcdn.net/cfile/tistory/2606AB36570B71A430)
[링크 : https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf]
AREF는 0.0V로 연결되서.. 코드에서 내부 1.1V로 설정한 듯?
ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));
Internal 1.1V Voltage Reference with external capacitor at AREF pin
회로도에서 찾아 보니.. AVcc는 5V랑 묶여 있으니..
데이터시트에서 해당내용을 찾아 변경하면..
![](https://t1.daumcdn.net/cfile/tistory/256F6E50570B76B310)
음.. 너무 빠듯하게 나오네..
ADMUX = (_BV(REFS0) | _BV(MUX3)); // (_BV(REFS1) |
79.0 79.0 79.0 79.0 79.0 79.0 79.0 |
+
offset도 .. gain도 많이 다르네?
static const float offset = 335.2; // change this by calibration result
static const float gain = 1.06154;
[링크 : http://www.avdweb.nl/arduino/hardware-interfacing/temperature-measurement.html]