LM335 Therometer Using The Arduino: Sensor Temperatura
LM335 Therometer Using The Arduino: 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
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 );
}
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
void loop(){
tempK = analogRead(0) * 0.004882812 * 100;
Kelvins first
tempC = tempK - 273.15;
//Read temperature in
//Delay 1 second
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:
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);
}