Using a 1N4148 diode as temperature sensor…
I had an application where I wanted to detect temperature. No big deal, lots of good temperature sensors exist. But of course, I don’t have any of those. Rather than order something from sparkfun, I thought I’d just try to see what I could do with the stuff I had on hand. What I had on hand was about 100 1N4148 diodes that I got for about a penny a piece.
The idea is that the forward voltage of diodes is temperature dependent. For every degree Celcius the diode increases, the forward voltage should drop by 2mV. So, I decided to test this idea. I configured the analog input pin 0 on my Arduino to be an input, and then activated its internal pullup resistor. I then wrote a program which averaged a bunch (1000) of readings in an attempt to get a stable, relatively noise free signal.
I logged the values beginning at room temperature, then held the diode between my fingers, and then released it a couple of times. Here’s a graph of the resulting data values:
You can see that when I grab the diode, the forward voltage drops rather quickly, but when I release, the signal returns to the original value, somewhat more slowly. Room temperature in my house is around 70 degrees (21 degrees C) and body temperature is 98.6 is about 37 degrees C. The difference would then be about 16 degrees C, and we might expect a difference of 32 mV, but I experienced a difference of only about 16mV. At least part of this can be attributed to the fact that your finger temperature isn’t actually that close to 98.6.
This simple experiment demonstrates a couple of problems: the values returned by analogRead() are noisy, and quantization error is significant. The analogRead call returns a 10 bit number, which means that each bit is about 4 mV, or about 2 degrees C. We could use an operational amplifier to multiply the voltage to make it easier to read, which might help. Consider that an experiment for the future.