아두이노
아두이노(arduino)와 연동하는 tmp36 (온도센서)
'김용환'
2012. 1. 10. 10:48
아트로봇에서 tmp36을 구매해서 아래 링크를 참조로 해서 회로도를 구성했다.
http://artrobot.co.kr/front/php/product.php?product_no=529&main_cate_no=&display_group=
http://www.ladyada.net/learn/sensors/tmp36.html
http://printk.tistory.com/42
http://www.ladyada.net/learn/sensors/tmp36.html
(이미지 참조 : http://www.ladyada.net/learn/sensors/tmp36.html)
내가 원하는 정보는 섭씨 온도인데, 잘 나온다.
int sensorPin = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
int reading = analogRead(sensorPin);
float voltage = reading * 5.0 / 1024.0;
float temperatureC = (voltage - 0.5) * 100 ;
Serial.println(temperatureC);
delay(1000);
}
float getVoltage(int pin){
return (analogRead(pin) * .004882814);
}
다만, 이 수식이 전류의 흐름이 불확실해지면 정보는 정확하지 않게 나오는 단점이 있다.