Low-Cost Temperature Measurement with a Microcontroller Schematic Circuit Diagram
It frequently happens that you have an application in which you want to measure the temperature of a circuit or the outside world. This can be easily achieved using additional components in the form of ICs, or by using an RC network and a software routine. However, if all the I/O port pins are already in use, it’s hard to know what to do. A circuit trick can provide a solution to this dilemma.
As a rule, modern microcontrollers have RC oscillators with (relatively large) temperature coefficients. Since instructions are processed at the speed of the RC clock, the execution time of a software loop varies with the chip temperature. If your program includes a loop that increments a counter, you will obtain a count that is different for each different chip temperature, and a specific temperature can be assigned to each counter value.
Of course, it is necessary to have a highly stable time reference, which may be provided by the 50-Hz mains frequency (for example) or a second (crystal) oscillator network connected to the microcontroller. Such a second oscillator circuit is used with low-power microcontrollers to operate them at very low clock rates, such as 32 kHz, in order to save power. The RC oscillator is then only put into play as needed to meet the demands placed on the software.