I'm having some troubles reading the correct temperature from a LM335Z Temperature IC. The code I'm using is:
const int analogInPin = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
float raw = analogRead(analogInPin);
float kelvin = (raw / 1023.0) * 500.0;
float celcius = kelvin - 273.15;
Serial.print("Raw: ");
Serial.print(raw);
Serial.print(", ");
Serial.print("Kelvin: ");
Serial.print(kelvin);
Serial.print(", ");
Serial.print("Celcius: ");
Serial.print(celcius);
Serial.println("");
delay(1000);
}
The kind of results I'm getting are:
Raw: 738.00, Kelvin: 360.70, Celcius: 87.55
Raw: 739.00, Kelvin: 361.19, Celcius: 88.04
Raw: 739.00, Kelvin: 361.19, Celcius: 88.04
Raw: 740.00, Kelvin: 361.68, Celcius: 88.53
Raw: 739.00, Kelvin: 361.19, Celcius: 88.04
Raw: 739.00, Kelvin: 361.19, Celcius: 88.04
These results are a little off the maximum uncalibrated temperature error of 9°C (it's about 22°C here), and I am getting a similar result from another LM355Z (I have two).