Thursday, September 29, 2011

LM335 + Arduino temperature sensor

Few weeks ago I’ve bought a LCD 16x2 display. I wanted to create a room temperature sensor. 


I’ve been using pocket arduino and there’s been some issues with resetting. I had to burn bootloader once again, so it took me longer to make this post. Also I’ve picked LM35 for this project (cool but expensive), but I’ve burned it. So I was forced to go with LM335 (not that cool but cheap). You can download code and watch video below. 

Code : 

#include <LiquidCrystal.h>
float raw;
float temperature;
LiquidCrystal lcd(3, 4, 5, 6, 7, 8);
byte degree[8] = 
{
B01100,
B10010,
B10010,
B01100,
B00000,
B00000,
B00000,
B00000
};

void setup()
{
  lcd.begin(16, 2);
  lcd.print("Temperature :");
  lcd.createChar(0, degree); 
  lcd.setCursor(7,1);
  lcd.write(0);
  lcd.setCursor(8,1);
  lcd.print("C"); 
}

void loop()
{
 raw = analogRead(0);
 temperature = ((raw*480.0/1024.0)-273); 
 lcd.setCursor(1,1);
 lcd.print(temperature);
 delay(500);
}



12 comments:

  1. Great job, ever heard of anyone using a k-type probe for water or beer wart?

    ReplyDelete
    Replies
    1. Thanks :) I don't know if its drink-safe solution, but these sensors have plastic packages so if you won't put it in a boiling liquid it should be safe.

      Delete
  2. this is what I'm talking about, they have a 3 wire hook up to pid controllers but should work with just a positive and negative

    http://www.auberins.com/index.php?main_page=product_info&cPath=20_3&products_id=101

    ReplyDelete
    Replies
    1. Oh, I see, I believe you could use that with arduino.

      Delete
  3. Awesome, do you have a schematic? I made something similar but I could never get the readings to be very accurate.

    ReplyDelete
    Replies
    1. Hi there, thanks :). I'm sorry but I don't have schematics available, what sensor have you used ? LM335 is not going to be totally precise and also take a look at conversion between mV and degrees.

      Delete
    2. I've used the LM335 and the LM35. Any recommendations on a different chip?

      Delete
    3. In the datasheets it says that both of them should have difference of 1 degree over 100, what do you mean readings were not accurate ?

      Delete
  4. I calibrated them at 32 degrees with ice, then transferred to boiling water and couldn't get within 15 degrees of 220. That's why I was asking for help.

    ReplyDelete
    Replies
    1. hmmm, I guess I would recommend calibrating it at room temperature, for highets accuracy, what equation are you using for transfering mV to degrees ? and how have you hooked up LM335 ?

      Delete
    2. Figured it out. The voltage on the USB was fluctuating +/- .5V. An external power supply fixed it.

      Delete
    3. Glad it works :), I would never pick USB as a problem.

      Delete