Vous êtes sur la page 1sur 4

void loop()

{
tempC = analogRead(tempPin);
tempC = (5.0 * tempC * 100.0)/1024.0;
ure
Serial.print((byte)tempC);
delay(1000);
ew data
}

//read the value from the sensor


//convert the analog data to temperat
//send the data to the computer
//wait one second before sending n

int reading = analogRead(sensorPin);


float voltage = reading * 5.0 / 1024;
int temp = voltage * 100 ;

Ce capteur est trs facile utiliser puisqu il suffit de l alimenter avec les pattes VC
C et GND et la patte centrale une entre analogique d Arduino.
La conversion elle aussi est simple puisqu un volt correspond 100 degrs Celsius.
La lecture analogique d u signal de 0 5V tant code de 0 1023, on a la formule
Temp = Volt * 5./1023*100 ;

void loop()
{
int rawvoltage= analogRead(outputpin);
float millivolts= (rawvoltage/1024.0) * 5000;
float celsius= millivolts/10;
Serial.print(celsius);
Serial.print(" degrees Celsius, ");
Serial.print((celsius * 9)/5 + 32);
Serial.println(" degrees Fahrenheit");
delay(1000);
}
void loop()
{ delay(2000); // calls a 2 second delay
t=t+2;
// increments the time by 2 every two seconds
temp=analogRead(sensor); // reads the LM35 output
tempc=(temp*5)/10;
// converts the digital value into temperature degree
C
tempf=(tempc*1.8)+32;
// converts degree C to degree F
Serial.println("...............");
Serial.println("Temperature logger");
Serial.print("Time in sec = "); // prints the time on serial monitor window
Serial.println(t);
Serial.print("Temperature in deg C = "); // prints the temperature in degreeC
Serial.println(tempc);
Serial.print("Temperature in deg F = "); // prints the temperature in degreeF
Serial.println(tempf);
}

void setup()
{

analogReference(INTERNAL); //Permet de fixer la temperature de refernce 1,1


volt
Serial.begin(9600);
//initialisation de la liaison srie 9 600 bauds
}
void loop()
{
mesure = analogRead(portana0); //Lecture de la valeur fournie par le capteu
r de temprature
tension = mesure * 1.1 / 1024; //Conversion en tension (en volt)
temperature = tension * 100;
//Conversion en temprature (en degr Celsius)
}
Par dfaut la tension de rfrence utilise par les convertisseurs analogique-numrique de
l'Arduino est de 5 volts. Comme la tension maximale dlivre par le LM35 DZ n'est q
ue de 1 volt nous utilisons l'instruction analogReference(INTERNAL) permettant d
'optimiser les mesures grce une tension de rfrence de 1.1 volt au lieu de la tensio
n de rfrence par dfaut de 5 volts.
Ainsi pour la tension maximale en entre de 1 volt, le convertisseur fournira une
valeur en sortie de 1 V * 1024 / 1.1 v soit 931 alors que si nous avions gard la
tension de rfrence par dfaut de 5 volt, nous n'aurions eu en sortie que 1 v * 1024
/ 5 v soit 205. Un incrment de 1 fourni par le convertisseur correspond 1.1 V / 1
024 volt soit environ 1 mV au lieu de 5 V / 1024 soit environ 41 mV. La rsolution
est donc ainsi bien meilleure (multiplie par environ 40).
Les paramtres utilisables avec l'instruction analogReference(INTERNAL) sont les s
uivants :
- DEFAULT : La tension de rfrence est de 5 volts
- INTERNAL : La tension de rfrence est de 1.1 volts
- EXTERNAL : La tension de rfrence est celle applique sur la patte AREF de l'Arduin
o

// the pin where the analog data is read


const int analogPin = 0;
// the variable for the data
float sensorValue = 0;
void setup()
{
// setting the reference voltage
// to internal 1.1V
analogReference(INTERNAL);
// starting serial
Serial.begin(9600);
}
void loop()
{
// read the data and
// scale it from 10 bit to 0.01 / degree C
sensorValue = float(analogRead(analogPin)) * 110 / 1024;
// output data to serial monitor
Serial.print("temp
// print only one decimal place
Serial.print(sensorValue, 1);
Serial.println("degrees C");
// wait one second then start again
delay(1000);

void loop()
{
temp = analogRead(tempPin);
temp = temp * 0.48828125;
Serial.print("TEMPRATURE = ");
Serial.print(temp);
Serial.print("*C");
Serial.println();
delay(1000);
}

void loop()
{
for(i = 0;i< =7;i++){ // gets 8 samples of temperature
samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
tempc = tempc + samples[i];
delay(1000);
}

The LM35 is a common TO-92 temperature sensor. It is often used with the equatio
n
temp = (5.0 * analogRead(tempPin) * 100.0) / 1024;
[Get Code]
However, this does not yield high resolution. This can easily be avoided, howeve
r. The LM35 only produces voltages from 0 to +1V. The ADC uses 5V as the highest
possible value. This is wasting 80% of the possible range. If you change aRef t
o 1.1V, you will get almost the highest resolution possible.
The original equation came from taking the reading, finding what percentage of t
he range (1024) it is, multiplying that by the range itself(aRef, or 5000 mV), a
nd dividing by ten (10 mV per degree Celcius, according to the datasheet: http:/
/www.ti.com/lit/ds/symlink/lm35.pdf
However, if you use 1.1V as aRef, the equation changes entirely. If you divide 1
.1V over 1024, each step up in the analog reading is equal to approximately 0.00
1074V = 1.0742 mV. If 10mV is equal to 1 degree Celcius, 10 / 1.0742 = ~9.31. So
, for every change of 9.31 in the analog reading, there is one degree of tempera
ture change.
To change aRef to 1.1V, you use the command "analogReference(INTERNAL);"
Here's an example sketch using 1.1 as aRef:
void setup()
{
analogReference(INTERNAL);
Serial.begin(9600);
}
void loop()
{

reading = analogRead(tempPin);
tempC = reading / 9.31;
Serial.println(tempC);
delay(1000);
}