úterý 3. března 2015

Temperature sensors precision

I was always curious how much can I trust various types of temperature sensors. I loved the TI's TMP100, tiny I2C based sensors, and used them a lot before. In one project, I got a feeling that the sensors are actually lying to me, and I became a bit cautios. I later abandoned them in favor of DS1820 style sensors, and the few remaining TMP100's were resting in the box. As I recently got the DHT22 that also has temperature sensor, I felt like I should really take a look at various sensors and compare their readings. The results are interesting.
First thing first - the contestants are:
  • TMP100 - I2C based sensor from TI in SOT23-6 package
  • DS1820 (and similar ones) - 1-Wire based sensor from Dallas / Maxim
  • DHT22 - sort of one-wire protocol, temperature and humidity, based on AM2302
I already played with all the DS1820 (DS18B20, DS1822 etc.) sensors I have, comparing all of them, and I found out that at least at room temperature, they all report more or less the same temperature, with maximal difference between the lowest and highest value around 0.5°C.

As always, I took Arduino, attached LCD display to it and all three sensors, using sample code from Arduino libraries. I did not see any example for TMP100, but Google suggested the Fork Robotics page, and the example described on that page worked just fine. I do not offer the code for download, it's a big mess, and throwing it together took me about ten minutes anyway.

The results are interesting, and reassuring me I can use any kind of sensor without risking the temperatures being too different compared to any other sensor. In other words, I can use the DHT22 for the meteo node, and trust the temperature. There is no need for an additional DS18xx sensor on that node.

I tweaked the code for the central node a little, nothing important. I am considering a change of the packet definition, making just a single structure that will use anonymous structures and unions to describe any kind of sensor packet. I am still not sure if there are any drawback other than the obvious one (prone to mistake). Just to explain what do I mean:

typedef union {
  SensorPayloadTemperature_t Temp;
  SensorPayloadMeteo_t Meteo;
  struct {
    uint8_t PacketType;
    uint8_t BattLevel;
    uint8_t ___pad[2];
    uint16_t SensorId;
} SensorPayload_t;
This allows me to directly refer to PacketType, BattLevel etc. without 'going into' the Temp structure. Arduino supports this, at least the 1.5.8 version.

Žádné komentáře: