Notes about Temperature Sensors

I’ve been playing with quite a few different temperature sensors over the past few months and I just thought I’d post some kind of summary about it. This is mostly for my own reference but if you have any comments or questions, please leave a comment!

Temperature Sensors
Like most sensors, you can break temperature sensors into two different categories: analog and digital.

The trade-off is that analog sensors require an Analog-to-Digital Converter (ADC) to make their information useful to a microcontroller which have some inaccuracies depending on resolution and on the reliability of the voltage regulator. The Arduino, for example, has 6 ADC pins and has a resolution of 10 bits (range of 0-1023). This resolution is important because it means that a reading of 1023 either means you are reading anywhere from 4.995 to 5V (that is, 5 minus a step size (5V/1023). domain data . Additionally, the on-board voltage regulator gives +/- 0.075V (5V +/- 1.5%) which adds more inaccuracies to your readings. These are worth keeping track of *in addition* to the sensors own inherent inaccuracies.

One trick to improving accuracy, however, is to use the Arduino’s 3.3V instead, assuming your sensor is OK with that. Just remember to give the analog-reference (AREF) pin the voltage so that the resolution can be scaled to that!

The big advantage of analog sensors is that you don’t need to learn a digital protocol to get them. Just ask your ADC for readings, convert them using floating-point arithmetic. There’s a little snag here, since that can be kind of slow, but using look-up tables (here’s an example) can speed things up.

Now why use digital sensors at all? Well first off, you don’t have to worry about the inaccuracies from the ADC. Additionally, they tend to have some nice features.

The Dallas One-Wire allows you to put TONS of them on one digital pin! Now, this is possible with analog senors too and you could either average them out in the analog world or you a MUX chip if you wanted to preserve each reading individually, but it’s really easy with these One-Wire sensors and probably faster than if you used a MUX. I think that these might also run faster than analog depending on the accuracy that you’ve configured them for.

The DHT11 and DHT22 are also pretty neat because they’ll give you temperature and humidity readings on one digital pin (you can’t stack a bunch of these on one pin though like Dallas One-Wire).

Analog Examples:

  • Resistor Based (Thermistor): logarithmic arithmetic to convert, higher current draw than diode
  • Diode Based (TMP36, LM335): linear to convert, lower current draw than resistor
  • Thermocouple (Omega Selection Guide): can take deal with extreme heat and cold, much noisier than resistor and diode based within human-bearable temperatures, requires complex circuit for readings (single, quad (currently unavailable))

Digital Examples:

  • Dallas One-Wire (DS18B20, DS18B20 waterproofed): only use one digital pin for many sensors
  • DHT11/DHT22: give both temperature and humidity on one digital pin (very cheap on ebay), one per pin

Comments are closed.