Sunteți pe pagina 1din 7

SENSOR TEMPERATURA

No he visto nada para Arduino con este sensor que tiene un factor de 10mv/K
en vez de C que tiene el LM35. Este est sin calibrar segn el datasheet.
int degC = 0;
// fija los tipos de variables
float tmpVal = 0;
const int ledPin = 13;
// numero del PIN 13
void setup( ) {
Serial.begin( 9600 );
}
void loop( ) {
degC = analogRead( 0 );
tmpVal = (degC*5 / 1024.0 *1000/10)-273.15;
de 5V a formato

// lee el pin analogico 0


// pasa el valor de voltaje
// de Arduino -1024 valores-

y lo convierte
// a C de K a razn de 10
mV/K
Serial.print( "Lectura PIN 0: " );
Serial.print( degC );
Serial.print( ", Temperatura: " );
equivalente C
Serial.print( tmpVal);
Serial.println( " C " );
if (tmpVal >23.0) {
no lo apaga
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
delay( 3000 );
}

// escribe en pantalla la lectura y el

// si es mayor de 23C enciende el pin 13 si

// espera 3 segundos para la siguiente lectura

LM335 Therometer using the Arduino

October 6, 2011
About: The LM335 is a simple thermometer with only 3 pins. It can be easily interfaced to the arduino or any other
microcontroller. The LM335 is pretty much just a diode in a TO-92 case. The voltage rises 10mv for every degree in
Kelvins. You will pretty much need to convert the kelvin temperature to Celsius or Fahrenheit using simple
calculations.
Objective: To build a simple digital thermometer using a LM335 and an Arduino.
Material: You will need the following:

Arduino Uno

LM335

2x 1Kohm resistors

Instructions: The connections are very simple you will only need to use 2 of the 3 pins on the LM335. Pins 2 and 3
will only be used. Refer to the breadboard diagram below for connections. The resistors connect to the middle pin of
the LM335. The middle pin then connects to the arduino analog0. Pin 3 of the LM335 is connected to ground.

Calculations: The calculations are based off the Wikipedia for Kelvin. To calculate the Kelvin we read the analog0
pin on our arduino. We multiply that value by .004882812. Why .004882812? We get that by dividing our 5v (Power
Supply) by 1024 (10bits based off arduino analog). After we get our Kelvin we 273.15 to get our Celsius. To get our
Fahrenheit we multiply our Kelvin value by 9/5 and then subtract 459.67.
Arduino Code:

1
2

/*************************************************
* Temperature Sensor LM335 and Arduino

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

* ----------------* Objective: To build a simple digital thermometer


*
using a LM335 and an Arduino.
*
* http://dayzlab.wordpress.com
*************************************************/
float tempK=0, tempC=0, tempF=0;
void setup(){
Serial.begin(9600);
}

//Setup serial to 9600 bps

void loop(){
tempK = analogRead(0) * 0.004882812 * 100;
Kelvins first
tempC = tempK - 273.15;

//Read temperature in

//Convert from Kelvin to Celsius

tempF = ((tempK) * 9 / 5) - 459.67;


Fahrenheit

//Convert from Kelvin to

//Print all the values to Serial


Serial.print("Kelvin: "); Serial.println(tempK);
Serial.print("Celsius: "); Serial.println(tempC);
Serial.print("Fahrenheit: "); Serial.println(tempF);
Serial.println();
//Print Blank Line
delay(1000);

//Delay 1 second

lectura de temperatura con sensor TMP36 o LM335


En lnea con el tutorial anterior sobre sensores LDR, en este tutorial repasaremos otro elemento muy
interesante que nos permite captar variables del mundo fsico: El sensor de temperatura. En el tutorial
usaremos un TMP36, veamos el datasheet.
Del datasheet podris observar que el TMP36 es un circuito integrado que acta como un
sensor de temperatura calibrado directamente en grados Celsius, que se alimenta entre
2.7V y 5.5V y que por lo tanto es ideal para usarlo con nuestra placa Arduino.
Proporciona una salida de voltaje directamente proporcional a la temperatura en grados Celsius y
es muy parecido al clsico LM335A. Algunas caractersticas son:
:

Rango de temperatura: -40C to 150C / -40F to 302F


_Factor de escala 10 mV/C
_Precisin de 2C
_Linealidad de 0.5
Alimentacin: Entre 2.7 y 5.5V.

Remarquemos del datasheet sobretodo la curva Vout vs Temp:

Del grfico anterior, lo que tenemos que observar es la recta b, que hace referencia al sensor TMP36.
Veamos pues el tutorial...
Tendremos que montar el siguiente circuito sobre nuestra placa protoboard:

Ya sobre la protoboard real, nos tendra que quedar algo as:

Ms que otra cosa, hay que tener cuidado de poner correctamente cada cable donde toca, el azul - el
de seal-, entre la pata del centro del sensor y el pin A0de Arduino, el cable rojo entre la pata que
queda ms a la izquirda y el pin 5Vde Arduinoy finalmente el cable negro entre la pata que queda ms
a la derecha y el pin GND de Arduino.

Una vez hecho el montaje, vamos a programar el cdigo sobre la placa Arduino Uno. El cdigo que
usaremos es el siguiente:
/*Opiron Electronics
Medicin de temperatura con sensor TMP36 o LM35
by A.Girod
*/
float temp;

int tempPin=0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
temp=analogRead(tempPin);
temp=(5.0*temp*100)/1024.0;
Serial.print(temp);
Serial.print(temp); Serial.println(" grados C");
//
delay(1000);
}

S-ar putea să vă placă și