0

ADT7410 Temperature Inaccuracies
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: ADT7410 Temperature Inaccuracies

by lunch_box on Tue Aug 13, 2019 5:24 pm

adafruit_support_carter wrote:Let's check you hardware setup. Can you post a photo of one of the setups.

It's a very simple setup. I have 5v running in to the ESP8266. The 3VO pin on the ESP is used to power the ADT7410, which keeps all the GPIO lines at 3.3V.
IMG_20190813_171134.jpg
IMG_20190813_171134.jpg (198.37 KiB) Viewed 361 times

IMG_20190813_171119.jpg
IMG_20190813_171119.jpg (193.18 KiB) Viewed 361 times

lunch_box
 
Posts: 20
Joined: Thu Aug 08, 2019 4:11 pm

Re: ADT7410 Temperature Inaccuracies

by adafruit_support_carter on Wed Aug 14, 2019 12:43 pm

Soldering is marginal on a few pins. Could image that possibly leading to noise and bits maybe getting misread in the I2C traffic. But I don't think that is what is going on. That would be more random, and the values could go all over the place.

At this point, each ESP8266 setup is running the simple version of the code? The code below is what I was running for my test. (secret stuff removed)

Code: Select all | TOGGLE FULL SIZE
/***************************************************
  Adafruit ESP8266 Sensor Module
  Must use ESP8266 Arduino from:
    https://github.com/esp8266/Arduino
  Works great with Adafruit's Huzzah ESP board:
  ----> https://www.adafruit.com/product/2471
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!
  Written by Tony DiCola for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/

// Libraries
#include <ESP8266WiFi.h>
#include <Wire.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "Adafruit_ADT7410.h"

// Sensor Node
#define NODE_ID         "TEMP-04"
#define NODE_SENS_TYPE  "ADT7410"
#define NODE_CONTROLLER "Adafruit Feather ESP8266"
#define UPDATE_INTERVAL 30000  //millis

// WiFi parameters
#define WLAN_SSID       "XXXX"
#define WLAN_PASS       "XXXX"

// Adafruit IO
#define AIO_SERVER      "io.adafruit.com"
#define AIO_SERVERPORT  1883
#define AIO_USERNAME    "XXXX"
#define AIO_KEY         "XXXX"
#define AIO_FEED        AIO_USERNAME "/feeds/" NODE_ID


// Create the ADT7410 temperature sensor object
Adafruit_ADT7410 temp_sensor = Adafruit_ADT7410();

// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;

// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);

// Setup feeds for temperature & humidity
Adafruit_MQTT_Publish temp_feed = Adafruit_MQTT_Publish(&mqtt, AIO_FEED);
/*************************** Sketch Code ************************************/

void setup() {
  Serial.begin(115200);
  Serial.print(F("NODE_ID: ")); Serial.println(NODE_ID);
  Serial.print(F("NODE_SENS_TYPE: ")); Serial.println(NODE_SENS_TYPE);
  Serial.print(F("NODE_CONTROLLER: ")); Serial.println(NODE_CONTROLLER);

  // Make sure the sensor is found, you can also pass in a different i2c
  // address with tempsensor.begin(0x49) for example
  if (!temp_sensor.begin()) {
    Serial.println("Couldn't find ADT7410!");
    while (1);
  }


  // Connect to WiFi access point.
  Serial.println(); Serial.println();
  delay(10);
  Serial.print(F("Connecting to "));
  Serial.println(WLAN_SSID);

  WiFi.hostname("sensor01");
  WiFi.begin(WLAN_SSID, WLAN_PASS);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println();

  Serial.println(F("WiFi connected"));
  Serial.println(F("IP address: "));
  Serial.println(WiFi.localIP());

  // connect to adafruit io
  connect();
}

void loop() {
  // ping adafruit io a few times to make sure we remain connected
  if(! mqtt.ping(3)) {
    // reconnect to adafruit io
    if(! mqtt.connected())
      connect();
  }

  // Publish data
  if (! temp_feed.publish(temp_sensor.readTempC()))
    Serial.println(F("Failed to publish temperature"));
  else
    Serial.println(F("Temperature published!"));

  delay(UPDATE_INTERVAL);
}

// connect to adafruit io via MQTT
void connect() {

  Serial.print(F("Connecting to Adafruit IO... "));
  int8_t ret;
  while ((ret = mqtt.connect()) != 0) {
    switch (ret) {
      case 1: Serial.println(F("Wrong protocol")); break;
      case 2: Serial.println(F("ID rejected")); break;
      case 3: Serial.println(F("Server unavail")); break;
      case 4: Serial.println(F("Bad user/pass")); break;
      case 5: Serial.println(F("Not authed")); break;
      case 6: Serial.println(F("Failed to subscribe")); break;
      default: Serial.println(F("Connection failed")); break;
    }
    if(ret >= 0)
      mqtt.disconnect();
    Serial.println(F("Retrying connection..."));
    delay(5000);
  }
  Serial.println(F("Adafruit IO Connected!"));

}

adafruit_support_carter
 
Posts: 13195
Joined: Tue Nov 29, 2016 2:45 pm

Re: ADT7410 Temperature Inaccuracies

by millercommamatt on Wed Aug 14, 2019 5:15 pm

lunch_box wrote:
millercommamatt wrote:The spikes in your data are often in phase across sensors and not random. It is likely an environmental issue.

If that's the case, why do the DHT22 and BMP388 not exhibit similar behavior? Though there does appear to be some correlation in the ADT7410 data streams.


The different sensors likely behave differently because they have different thermal mass and hysteresis characteristics. Is there anything in the local environment that would change the temperature? Are your sensors near a fan or AC vent? Are you sensors near a window or a bright light source? Are you sensors near anything that produces heat? Are you handling them? Are they well ventilated?

You other sensors are responding to something at the same times as your ADT7410 sensors. They're just not having as large an amplitude response.

millercommamatt
 
Posts: 480
Joined: Tue Jul 31, 2018 4:57 pm

Re: ADT7410 Temperature Inaccuracies

by lunch_box on Wed Aug 14, 2019 5:44 pm

millercommamatt wrote:The different sensors likely behave differently because they have different thermal mass and hysteresis characteristics. Is there anything in the local environment that would change the temperature? Are your sensors near a fan or AC vent? Are you sensors near a window or a bright light source? Are you sensors near anything that produces heat? Are you handling them? Are they well ventilated?


The sensors are not near a vent or fan. There is a window nearby, but it is shaded. I ran an earlier test with the sensors in a drawer, so airflow and radiant heat were near zero. The same temperature spikes were observed.
I just don't see how minor fluctuations in room temperature could lead to 5+ degree temperature spikes. I expect to see jitter within one or two degrees, but this is far beyond that. And while the spikes do sometimes roughly match up, there are plenty of other instances where they do not. So the correlation is not at all convincing.

lunch_box
 
Posts: 20
Joined: Thu Aug 08, 2019 4:11 pm

Re: ADT7410 Temperature Inaccuracies

by adafruit_support_carter on Wed Aug 14, 2019 5:54 pm

I just don't see how minor fluctuations in room temperature could lead to 5+ degree temperature spikes.

Agree. And the correlation isn't 100%.

Really weird issue. At this point I feel like we are running the same hardware/software. Not being able to recreate the issue, I'm not sure how to troubleshoot.

For the sake of troubleshooting, try powering down everything but one board. Run the above sketch with the board sitting on your desk in front of you. See if the problem repeats.

adafruit_support_carter
 
Posts: 13195
Joined: Tue Nov 29, 2016 2:45 pm

Re: ADT7410 Temperature Inaccuracies

by lunch_box on Wed Aug 14, 2019 6:04 pm

adafruit_support_carter wrote:Soldering is marginal on a few pins. Could image that possibly leading to noise and bits maybe getting misread in the I2C traffic. But I don't think that is what is going on. That would be more random, and the values could go all over the place.
At this point, each ESP8266 setup is running the simple version of the code? The code below is what I was running for my test. (secret stuff removed)


Yes, the code you posted is line-for-line what my sensors are running.
And yes, on the photos I posted, the solder could be cleaned up a bit. But that wouldn't account for why all three are behaving the same way.

I bought an infrared thermometer and measured all the sensors. Sure enough, the ADT7410s were all reading the temperature they reported to IO. The BMP and DHT, however, showed a few degrees cooler- also in line with what they published to IO.
Interestingly, the ESP8266s all measured roughly the same temperature- the very same temperature reported by the ADT7410s.
I have to conclude, therefore, that the ADT7410s are responding very rapidly to changes in the ESP8266. This is exacerbated by the fact that they're hard-soldered right next to the ESP, whereas the BMP and the DHT are currently just breadboarded with a few centimeters of spacing between the sensor and the ESP.

Thank you both for your thoughtful input on this. If I make any new discoveries, I'll be sure to post them here.

lunch_box
 
Posts: 20
Joined: Thu Aug 08, 2019 4:11 pm

Re: ADT7410 Temperature Inaccuracies

by adafruit_support_carter on Wed Aug 14, 2019 6:57 pm

I have to conclude, therefore, that the ADT7410s are responding very rapidly to changes in the ESP8266

Interesting theory. Just eye balling it, I wouldn't expect that amount of proximity to induce several degrees C of change. But guess it is possible. And all the anomalies are in the positive (heated) direction.

Can you somehow physically separate the ADT on one of your setups to see if the helps?

adafruit_support_carter
 
Posts: 13195
Joined: Tue Nov 29, 2016 2:45 pm

Re: ADT7410 Temperature Inaccuracies

by lunch_box on Wed Aug 14, 2019 9:11 pm

adafruit_support_carter wrote:Can you somehow physically separate the ADT on one of your setups to see if the helps?

Yes. I'm going to re-work one of the boards and move the sensor farther over to the edge.

lunch_box
 
Posts: 20
Joined: Thu Aug 08, 2019 4:11 pm

Re: ADT7410 Temperature Inaccuracies

by lunch_box on Sun Aug 25, 2019 1:55 pm

I re-worked one of the boards (white plot line) to include about 2cm of separation between the ADT and the ESP. You can clearly see on the plot that this configuration reports about 1 degC cooler than the original configuration (blue/green plots). It's still 0.5-1.0 degC warmer than the breadboarded DHT22 and BMP388 sensors (red/orange plots), but thermal "cross-talk" seems to be markedly reduced.
Note that this graph is a 48-hour run, so individual spikes are less apparent than on some of my previous posts.
I think the big takeaway from this experiment for me is that, in order to achieve the most accurate possible temperature measurements, a remote probe or thermocouple is much more desirable than these on-chip solutions. That would also permit a proper calibration in an ice and/or a boiling water bath.
For my purposes, however, I think I can get away with fudging it with a -1-ish deg calibration factor.
Screen Shot 2019-08-25 at 10.36.26 AM.png
Screen Shot 2019-08-25 at 10.36.26 AM.png (172.48 KiB) Viewed 253 times

lunch_box
 
Posts: 20
Joined: Thu Aug 08, 2019 4:11 pm

Re: ADT7410 Temperature Inaccuracies

by millercommamatt on Mon Aug 26, 2019 12:38 pm

I think your data looks pretty good.

Temperature is an intensely local measurement. There are so many subtle things that can affect it.

Also, I don't care what manufacturers put in their data sheets, the out-of-the-box accuracy is never what they claim. For accuracy, they all need calibration to a calibrated reference. The good news in that the precision is usually good.

millercommamatt
 
Posts: 480
Joined: Tue Jul 31, 2018 4:57 pm

Re: ADT7410 Temperature Inaccuracies

by lunch_box on Mon Aug 26, 2019 8:41 pm

millercommamatt wrote:For accuracy, they all need calibration to a calibrated reference.

Do you have any tips for how to calibrate on-chip sensors like these? Without access to some expensive temperature chamber.

lunch_box
 
Posts: 20
Joined: Thu Aug 08, 2019 4:11 pm

Re: ADT7410 Temperature Inaccuracies

by adafruit_support_bill on Tue Aug 27, 2019 6:15 am

What you need is a stable uniform temperature environment. The boiling water/ice bath work well due to the combination of the phase change and the thermal conductivity of the water. But water and circuit boards don't play well together - unless the boards are protected with something like a conformal coating.

Environmental chambers typically rely on a combination of good insulation, air circulation temperature control and time for equilibration. You might be able to rig something up in foam cooler.

https://learn.adafruit.com/calibrating-sensors

adafruit_support_bill
 
Posts: 74639
Joined: Sat Feb 07, 2009 10:11 am

Re: ADT7410 Temperature Inaccuracies

by adafruit_support_carter on Tue Aug 27, 2019 1:06 pm

What about the original issue with the odd sudden changes? Is that still there? It looks gone in your plot above.

adafruit_support_carter
 
Posts: 13195
Joined: Tue Nov 29, 2016 2:45 pm

Re: ADT7410 Temperature Inaccuracies

by lunch_box on Tue Aug 27, 2019 7:45 pm

adafruit_support_carter wrote:What about the original issue with the odd sudden changes? Is that still there? It looks gone in your plot above.

They are still there. They're just not as obvious on a 48-hour x-axis.

lunch_box
 
Posts: 20
Joined: Thu Aug 08, 2019 4:11 pm

Re: ADT7410 Temperature Inaccuracies

by millercommamatt on Wed Aug 28, 2019 5:51 pm

I don't really see any high-frequency deviations in the temperature time series with a magnitude > 0.5 C. That's decent performance. You earlier plots had jumps with almost 10 times that magnitude. The reworking of the boards seems to have helped.

millercommamatt
 
Posts: 480
Joined: Tue Jul 31, 2018 4:57 pm

Please be positive and constructive with your questions and comments.