Bom, eu to tentando medir a temperatura de um comodo com um sensor Dallas 18B20. Bom, eu li sobre o assunto, procurei bastante e achei um cara fazendo o msm coisa, com 1 só sensor e tal... "roubei" o código dele e apliquei aqui. Bom, não funciou muito bem na verdade.... Aqui a leitura é a msm pra sempre :
Alguem pode me dar uma luz ?
Eu conectei assim :
Pino 1 - gnd
pino 2 - analog 0
pino 3 - 5v
codigo :
An open-source LM35DZ Temperature Sensor for Arduino. This project will be enhanced on a regular basis
(cc) by Daniel Spillere Andrade , http://www.danielandrade.net
http://creativecommons.org/license/cc-gpl
*/
int pin = 0; // analog pin
int tempc = 0,tempf=0; // temperature variables
int samples[8]; // variables to make a better precision
int maxi = -100,mini = 100; // to start max/min temperature
int i;
void setup()
{
Serial.begin(9600); // start serial communication
}
void loop()
{
for(i = 0;i< =7;i++){ // gets 8 samples of temperature
samples = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
_ tempc = tempc + samples*;_
_ delay(1000);_
_}*_
tempc = tempc/8.0; // better precision
tempf = (tempc * 9)/ 5 + 32; // converts to fahrenheit
if(tempc > maxi) {maxi = tempc;} // set max temperature
if(tempc < mini) {mini = tempc;} // set min temperature
Serial.print(tempc,DEC);
Serial.print(" Celsius, ");
Serial.print(tempf,DEC);
Serial.print(" fahrenheit -> ");
Serial.print(maxi,DEC);
Serial.print(" Max, ");
Serial.print(mini,DEC);
Serial.println(" Min");
tempc = 0;
delay(1000); // delay before loop[/color]
Bom, eu fiz as ligações certas, e obviamente não está 0°C aqui... então alguém sabe dizer por que não está lendo, apesar dele tentar ?