Posts Tagged ‘ LM335A

Arduino LCD HD44780 + LM335 Temperature Sensor

This was the next logical step in my home monitoring project.  I’ve simply added an LM335A temperature sensor to the breadboard and have the output being posted to the LCD every second.

 

First the drawing:

The next step was to write the code that reads the temperature on Analog Pin 0, then writes it the LCD.  This could not have been easier.

 

Code:

#include <LM335A.h>
#include <LiquidCrystal.h>
float raw;
 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
 
LM335A InsideTemp(0); //pass the analog input pin number
void setup() {
  lcd.begin(16, 2);
}
 
void loop() {
  lcd.clear();
  //user must call ReadTemp before any valid temp data is available
  raw = analogRead(0);
  InsideTemp.ReadTemp();
  lcd.print(InsideTemp.Fahrenheit());
  lcd.print((char)223);
  lcd.print("F");
  lcd.setCursor(0, 1); // bottom left
  delay(1000);
}

Working project:

 

 

Things are coming along on the home monitor.  I’ll soon be using some multiplexers and 8bit shift registers to help reduce the number of pins used on the arduino.  Keep checking back for more updates!

Arduino LM335 Temperature Sensor Tutorial

Getting started with the LM335 Temperature sensor can be a bit tricky.  I ran into some problems when I started getting incorrect data.  I googled around for the problem, and all of the schematics and drawings at the top of google were incorrect.  They either had a static resistor on the data pin, or they show the data pin on the arduino directly connected to the LM335 Temperature sensor’s data pin.

The trick to correctly calibrating the temperature sensor is to connect a 10k potentiometer to the data pin.  Once the potentiometer is wired in place, you can calibrate the LM335 to read the correct temperature.  The correct wiring of the LM335 can be seen below:

 

 

 

 

 

Once everything is wired up, I simply used the lm335a.h library written by greenrobotics.net.  This is a nice library, a quick test sketch can be seen below here:

// Example using the LM335A library for reading temperatures
// Created by Jonathan Merrill, February 20, 2010.
// http://www.greenrobotics.net
//  Released into the public domain.
 
#include 
 
LM335A InsideTemp(0); //pass the analog input pin number
void setup() {
Serial.begin(57600);
Serial.println("starting");
 
}
 
void loop() {
  delay(3000);
  //user must call ReadTemp before any valid temp data is available
  InsideTemp.ReadTemp();
  Serial.print("Fahrenheit: ");
  //functions to get the temperature in various unitsfs
  Serial.println(InsideTemp.Fahrenheit());
  Serial.print("Celsius: ");
  Serial.println(InsideTemp.Celsius());
  Serial.print("Kelvin: ");
  Serial.println(InsideTemp.Kelvin());
 
}

Once I get motived, I’ll be sending this temperature data from my home to my blog, here.  I’ll be sure to post more updates as they come.