Arduino LM335 temperature sensor interface
Intro
Here we describe a class for reading out the LM335 temperature sensor. This class is based on Chiptemp. See here for a detailed description of the software: http://www.avdweb.nl/arduino/temperature-measurement.html
Differential amplifier
The LM335 output voltage is 2.73V ... 3.73V for 0/°C to 100/°C. This differential amplifier converts the output voltage to 0 ... 5V for the Arduino ADC:
Electronic circuit calculation with wolframalpha
Although the circuit is simple, the calculation isn't. We have to solve a system of multiple variable equations. Manually solving cost a lot of work, but wolframalpha can solve it automatically. For Rc we take a value of 100kΩ, the resistors Ra and Rb have to be determined.
Gain calculation:
The gain is (Rc + Ry) / Ry, where Ry is the equivalent resistance Ry = Ra*Rb / (Ra+Rb)
Kirchhoff's circuit law:
iRa = iRb + iRc
(5V - 2.98V) / Ra = 2.98V / Rb + (2.98V - 1.25V) / Rc
So there are 4 equations which have to be filled in into wolframalpha:
c = 100e3, y = a*b / (a+b), (c + y) / y = 5, (5 - 2.98) / a = 2.98 / b + (2.98 - 1.25) / c
After a short time wolframalpha comes with the solution:
Ra=36630Ω, Rb=78740Ω
Link
LM335 class
For troubleshooting see HERE.
LM335.pde
#include "LM335.h" LM335::LM335(int _ADCpin) inline void LM335::initialize() inline int LM335::readAdc() int LM335::deciCelsius() int LM335::celsius() int LM335::deciFahrenheit() int LM335::fahrenheit() |
LM335.h
#ifndef LM335_H // LM335 temperature sensor interface // Calibration values, set in decimals static const int lm335_samples = 1000; // must be >= 1000, else the gain setting has no effect // Compile time calculations class LM335 #endif |