Simple microcontroller-temperature measurement uses only a diode and a capacitor
Discharging a capacitor through the reverse leakage of a PN junction allows you to measure ambient temperature.
Andreas Grün, Wedemark, Germany; Edited by Martin Rowe and Fran Granville -- EDN, December 5, 2008
Using a PN-junction diode for temperature measurement usually depends on its 2‑mV/K temperature coefficient. Conventionally, you must amplify and digitize this voltage with an ADC before you can use the value in a microcontroller. Less well-known is the fact that the reverse current of a PN-junction diode shows a good exponential dependency over temperature; increasing the temperature by approximately 12K doubles the leakage (Figure 1). An easy way to measure current over such a large range of two to three decades is to charge and discharge a capacitor and measure the time or frequency.
A general-purpose I/O pin of a microcontroller charges a capacitor either by using it temporally as an output or by enabling a pull-up resistor, which is available in some controllers (Figure 2a). After charging the pin, you configure it as a high-impedance input, and a capacitor discharges through the leakage current of the diode (Figure 2b). The discharge time then is proportional to the temperature of the diode; thus, the diode exhibits exponential behavior. Depending on the type of diode, the exponential behavior can be nearly ideal. Calibration of a base point is necessary because the absolute value of the current varies greatly at a given temperature.
|
Selecting the diode and the value of the capacitor requires some care. The smaller the PN junction, the smaller the reverse current and the longer the discharging time. Periods longer than a few seconds are usually unsuitable. Making the capacitor’s value too low leads to errors because the capacitance of any cable and the capacitance of the PN-junction diode come into effect.
Typically, a power diode, such as a 1N4001 with a capacitance of 1 nF, gives suitable results. The discharge time is approximately 0.3 to 1 sec at room temperature, falling into the millisecond range at 100°C. The PN-junction diode of a power transistor should also work.
-
Andreas,
I agree, as long as the idea just demonstrates a basic temp estimation and/or the temperature behavior i.e.(temp goes up or down) it works. My previous comment should be referred to the loosely used word "measurement".
Samuel
Samuel Kerem - 2009-21-1 13:57:00 PST -
@samuel and maybe @lonnie too:
Let me clarify some things, that I may failed to describe in this design idea: 1) the idea was not meant to be used for accurate temperature measurements, it was meant to be used to differntiate between “low” and “high” temperatures, e.g. to distinguish 20C from 50C. 2) The principle works, I tested it, otherwise I wouldn’t have published it here. My circuit used an Atmel ATTiny26 processor with a 1N4007 and a 1 nF capacitor and produced the results published.
The Atmel processors do have a well defined input threshold and I assume other processors work in the same way. We are not discussing about 10% difference!
3) The picture indeed shows an JFET reverse current diagram simply because there are no similar diagrams for standard diodes. It should only show the logarithmic behaviour, the absolute values are much higher for diodes even at lower voltages.
4) I agree with your estimations about leakage current of the diode and input leakage current of the processor pin. But as I said this idea was not intended to measure accurate values and of course there must be some kind of “calibration”. In the worst case It may even be possible that this idea won’t work if the input leakage is too high.
However this was a design idea, not a recipe for production. I understand this column of EDN exactly this way: someone has an idea that basically works, you have to examine precisely if you can use it or not in your specific environment.
Anyway thanks for your helpful comment.
Andreas Gruen
Andreas Gruen - 2009-7-1 13:19:00 PST -
Doubt it is practical and even will work.
1) The IFD implies that ADC is not required and general (digital) I/O pin is used to differentiate between charged cap (logical 1) and discharged cap (logical 0). The level of switching between 1 and 0 is EXTREMELY loose, depends on many-many factors (one of them the microprocessor’s own temperature).
2) Let’s say you charged the cap (or reversed the diode) to 5V (3.3V is much more accepted now). Reversed current for 1n4001 (or similar diodes) at reverse 5V is not defined but for sure is very small and rolls down sharply at low voltages. (Even on fig.1, I guess reversed current of JFET is shown at 20V bias). Assuming, very loosely, from 1N4001 Data Sheet reversed current as ~ 100nA,- you need to guarantee for 10% (!!) error that the microcontroller input leakage current is fixed and stable at ~10nA and does not change (or change predictably) with variation of micro own temp. Even specially designed ultra low power micro TI MSP430F543 may have input leakage up to +/- 50 nA greatly changing the cap/diode discharge behavior
Samuel - 2008-14-12 11:38:00 PST -
Wow, I thought I had a decent answer to a project idea of mine for a temp sensor for controlling a home's environment. But, I notice the diode's temperature starts at 30 deg C. I need to at least start at 0 deg C to say 65 deg C range. Any viable diodes available with that reverse bias trend?
Lonnie Burk - 2008-5-12 12:27:00 PST


















