ADC thermometers (for the poor man)

Discussion in 'Automation, Motors & Robotics' started by I Hate Google!, Jul 2, 2016.

  1. I Hate Google!

    I Hate Google! New Member

    Jun 20, 2016
    Likes Received:
    A long time ago I designed an incubation system for my chickens after the traditional "air" variety failed to work as well as they might have. Part of that - and also figuring out why the still/blown air ones weren't working as predicted - was using multiple (and cheap) digital thermometers.

    There's a lot of science here that I won't bother you with (TL;DR) because there's a neat - and very practical application of the UDO Neo's ADC here that allows anyone to mount up to six remotely mounted and reasonably accurate (albeit when calibrated) temperature sensors.

    For the uninitiated, this involves using either diodes (just about any general purpose silicone diode will do - you can even use a transistor or even an LED at a pinch).

    Without looking at the finer points, the forward voltage across a typical diode's PN junction drops fairly linearly about 2 mV per degree C increase in temperature. It doesn't come much simpler than this and you can access the readings from Ardunio or Linux via the "sys" filing system as described in the docs.

    It's so simple (cough) a child could do it and there's little danger of frying your Udoo provided you don't connect it up wrong AND wire it to the 5v rail at the same time: this is because we're measuring the voltage across the diode and, even if you're using an LED (except a blue one because they do use a lot of votage) that's not going to go much

    That said, here's what you do: I strongly recommend sticking to a diode or the base-collector junction of any small-signal, general purpose transistor like a BC107/8/9.

    The circuit needs a little bit of current to get the diode moving (and to drop the remaining voltage) so this is where your calculator is going to come in.

    Most guides put Vf (the voltage developed across the diode) at about 600 - 700 mV but that varies with temperature (!) and the type of diode we're using. The idea then is to get the diode to conduct a small amount of current - a few mA - but the exact value is not crucial. If you're one of those "cut and run" fellows, I'll oblige you by looking the other way and suggest you start with something around 1K0 to 2K2.

    The spec sheet should give you Vf but we'll assume 0.7v for this example.

    Powering the circuit from the 3.3v supply means we have:

    3.3v - 0.7v = 2.6v

    to drop across the resistor. From Ohm's law we can calculate (for 1mA):

    2.6v / 0.001A = 2,600 (2K7)

    Using the 5v supply is similar:

    (5 - 0.7) / 0.001 = 4,300 (4K3)

    The important thing here is to wire the circuit diode so it's ANODE goes to the ADC input and the CATHODE (often marked with a bar) does to the 0V. Power is drawn from the 3.3v (or 5v!) lines through the resistor which limits the current.

    3.3v o---[/\/\/\/\]----o-----|>|-------o 0V
    | | |
    VCC (R1) ADC (D1) GND

    Although the "bricks" are pre-calibrated this is a great way to demonstrate ADC function to the kids.

    The gotchas? There are several but here are a couple.

    * The components are all reactive to heat to some degree. R1 should be a good quality metal film 1% for decent results.

    * If you're running this any distance, electrical noise might be a factor and there's also the impedance of the wire to get in the way (which also changes with heat!).

    Calibration is best done with a known instrument. The *actual* Vf (voltage drop) across the diode isn't crucial - what we're interested in is how much it changes.

    The ADC is calibrated for 4095 (12 bit) at 3.3 V which is about 0.8 mV per increment giving us (about) 0.5C accuracy which isn't too bad. (If you need a more granular reading, it's possible to use an op-amp to improve matters but that's beyond the scope of this and really outside of what a diode sensor is useful for and it's cheaper to resort to proprietary silicone.)

    If you want to use this device to measure temperature it's important to remember that the Vf goes DOWN as the temp goes UP. Think of having walk on a cold day. It's easier as you warm up!

    Getting an absolute temperature from the sensor is simply a matter of recording your reference Vf and working from there.

    My test rig reads about 792 mV at 18 C.

    Let's say I read an unknown temperature reading of 780mV? How hot (or cold is it)?

    The formula is quite simple:
    Temp C = (Vf1 - Vf2)/2 + Tc

    Vf1 = the known Vf at a calibration temperature.
    Vf2 = the measured Vf at the unknown temperature.

    (792 - 780)/2 + 18 = 24C

    Conversely, let's say we get a reading if 800 mV:

    (792 - 800)/2 + 18 = 15C

    These "place mat" calculations imply the ADC is more accurate than it really is but in reality there is a bit of jitter in the readings, sufficient to slip +/- 2C of error so any software should average out at least 5-10 readings as in rapid succession rather than rely on an instantaneous one.

    Have fun!
    Andrea Rovai likes this.

Share This Page