What the LM335 outputs
The LM335 is a two-terminal temperature sensor that behaves like a Zener diode whose breakdown voltage is proportional to absolute temperature at 10 mV/K. TI’s SNIS160E datasheet describes operation from 400 µA to 5 mA with less than 1 Ω dynamic impedance and a linear output, which is what makes a simple resistor-biased sensor practical at a microcontroller input. Because a kelvin and a degree Celsius are the same size, the same 10 mV corresponds to 1 °C of change, so the slope can be used directly as 10 mV/°C.
The arithmetic starts there. An output of 2.95 V means 295 K, and 295 − 273.15 = 21.85 °C. That is correct; the common shorthand of 22 °C is rounded and should not be carried into a calibration table.
The ADJ pin exists because the output is proportional to absolute temperature with an extrapolated zero at 0 K, so trimming leaves a slope error, not an offset error. A single-point adjustment therefore corrects the scale factor across the operating range.
Ideal 10-bit conversion on the ATmega8
The ATmega8 provides an 8-channel, 10-bit successive-approximation ADC. A 10-bit converter has 1024 possible codes, numbered 0 to 1023; 1024 is the count of codes, not a reachable result, and firmware that scales or clamps to 1024 introduces a one-code error at full scale.
With a 5 V reference, one code is 5 V ÷ 1024 = 4.8828125 mV. Dividing by the sensor slope gives 4.8828125 mV ÷ 10 mV/°C = 0.48828125 °C per code. The frequently quoted figures of 0.0049 V and 0.49 °C are this same result rounded to two significant figures.
| Quantity | Ideal value |
|---|---|
| ADC codes | 0 to 1023 |
| One LSB at a 5.000 V reference | 4.8828125 mV |
| Temperature per LSB, 10 mV/K sensor | 0.48828125 °C |
| Ideal code for 2.95 V | 604 |
| Ideal code for 2.98 V | 610 |
None of this is an accuracy specification. It is the arithmetic of an ideal converter with an ideal reference; a real channel adds reference error, offset, gain error, noise and the sensor’s own tolerance.
What gain does and does not fix
A difference amplifier maps a narrow temperature window onto the ADC input range. With a stage gain of G, one code represents 0.48828125/G °C, so G = 10 gives about 0.0488 °C per code. The input window shrinks in proportion: at G = 10, the converter’s 5 V span covers 0.5 V of sensor output, roughly 50 °C.
Gain multiplies every error ahead of the converter along with the signal. An input offset of 2 mV is equivalent to 0.2 °C at a 10 mV/°C sensor, and once amplified is indistinguishable from a real change unless measured and trimmed. A 1% gain error across a 50 °C window is 0.5 °C.
The LM324 on a 5 V rail
The LM324 is a quad op-amp whose input common-mode range includes the negative rail, so a ground-referenced input is possible. That is an input property, not a rail-to-rail output guarantee. TI’s SLOS066AE datasheet presents the LM324B and LM2902B as next-generation parts with improved specifications, including 600 µV typical offset, ±2 mV (BA) or 3 mV (B) maximum offset and 50 nA maximum input bias current over −40 °C to +125 °C. Those figures belong to the B versions; the older LM324’s offset, bias current and output swing have to be read from the non-B columns of the same datasheet.
In practice a 5 V single-supply LM324 output cannot be assumed to reach 5 V. The top of any mapped window must sit below the specified output swing for the actual load, so a design that assigns 5 V to body temperature is not reachable as drawn. The bottom needs margin too, since both the amplifier output and the converter’s linear range have limits near ground.
Errors that dominate the reading
- Reference error. If firmware assumes a 5.000 V reference but the actual reference is 1% low, every code is scaled by 1%, and a 295 K reading moves by about 2.95 K, nearly 3 °C. The sensor output is absolute, not ratiometric with the converter reference, so supply-based referencing does not cancel the error.
- Sensor excitation. The datasheet lists an operating output voltage change with current of 3 mV typical and 14 mV maximum over 400 µA to 5 mA at constant temperature for the LM335/LM335A, plus 0.3 °C typical and 1.5 °C maximum non-linearity. Bias current that moves with supply or temperature therefore appears as a temperature error.
- Self-heating. Accuracy is specified in a well-stirred oil bath; in still air self-heating must be considered, so excitation current and thermal mounting belong in the budget.
- Amplifier and network errors. Input offset, bias current through source resistance, resistor tolerance and the offset network’s own reference all translate into degrees. As a rule of thumb, bias current times source resistance divided by 10 mV/°C gives the error in °C; 100 nA through 10 kΩ is 1 mV, or 0.1 °C, before gain.
- Converter noise. The ATmega8 ADC has a dedicated clock domain and a Noise Reduction sleep mode that stops the CPU and I/O to reduce switching noise, worth using when the last codes matter.
Reviewing the 2013 circuit
The 2013 write-up at swharden.com describes an LM335 feeding an LM324 difference amplifier on a single 5 V USB supply, with room temperature mapped to 0 V and body temperature mapped to 5 V, and a 3.5 V Zener referencing the offset potentiometer instead of the 5 V rail. The author reports over 1,000 readings a second and notes that the parts were chosen cheaply from what was on hand.
Read as a resolution strategy, the gain-and-offset mapping is sound: it places a narrow window across the converter’s range. The assumptions around it need checking: the top of the window depends on LM324 output swing at 5 V, the bottom on offset trim, the scale on the actual reference voltage, and the sensor’s bias current and self-heating set a floor under the budget. The hand-on-sensor test shows the direction of change, not an absolute temperature.
Stated plainly: a Zener sensor touched by hand, an uncalibrated single-supply amplifier and a supply-referenced ADC do not make a clinical thermometer, and nothing here supports body-temperature measurement for any medical purpose.
Alternatives and a defensible next step
Where the analog chain is not the point, a digital sensor removes most of it: an ATTINY2313 thermometer built around a DS18S20 reports temperature over a one-wire bus and needs no reference or gain calculation. On-chip sensing, as in the site’s ATmega core temperature sensor article, is convenient but measures the die rather than the surroundings. A threshold application such as a temperature alarm for boiling milk is a reminder that 0.5 °C per code is often enough, and that resolution should follow the requirement, not be maximised by default.
For the LM335 channel, the defensible next step is a measurement plan, not a circuit change: log raw codes against the actual reference and an independent calibrated thermometer, fit offset and slope over the intended window, and claim no accuracy figure until the residuals are known. That evidence separates a demonstrator from an instrument.





