Two digital temp sensors- what sensor to believe?

Hi There,
I am using a DS18B20 and a BME280 sensor on I2c. The are showing significantly different temperatures
|DS18B20 Temperature|30.4 °C|
|BME280 Temperature|27.9 °C|

What sensor to believer? Both sensors are brandnew...

How short are the wires leading from your microcontroller to your sensors? Wires can conduct heat from a warm microcontroller to a sensor.

DON'T believe either one until you have run calibration tests for each against a sensor you do believe in.

7 Likes

Is it possible that your DS18B20 is a fake, counterfeit or clone? Unless you bought it from an authorized distributor your odds of getting one are unfortunately high.

they both have a typical accuracy is ±0.5°C over their respective range (-10°C to +85°C for the DS18B20 and -40°C to +85°C for the BME280).

of course with clones / knock offs, all bets are off

the BME280 offers a resolution of 16 bits whilst the DS18B20 has a user-configurable resolution ranging from 9 to 12 bits. This allows you to trade off resolution and accuracy for speed.

are you using the 12 bit mode ?

The BME280 is a pressure sensor - not a temperature sensor.

It has an internal temperature sensor for calibration purposes, and they let you read it as a "free gift", but it's more about temperature changes than absolute measurements.

Therefore, the dedicated temperature sensor would be the one to trust for temperature readings.

And, as @TechHiker says, your placement of it can have a big effect.

2 Likes

Take an average of both readings and that's it.

1 Like

Neither one, without a professionally calibrated thermometer for comparison. Without that, the best you can do is average.


//Libraries
#include <DFRobot_SHT20.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <DS3231.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_BME280.h>
#include <DHT.h>;

//Constants
#define ONE_WIRE_BUS 2
LiquidCrystal_I2C lcd(0x27, 20, 4); //Defines LCD at address 0X27 as a 16X2 LCD
DS3231  rtc(SDA, SCL); // SDA connects to pin A4, SCL connects tp pin A5 on arduino uno
#define DHTPIN 7     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
Adafruit_BME280 bme;
DFRobot_SHT20 sht20(&Wire, SHT20_I2C_ADDR);

//Variables
float humdht;  //Stores humidity value
float tempdht; //Stores temperature value
float temprtc;
float temp18b20;
float tempbme;
float humbme;
float presbme;
float humsht;
float tempsht;
byte deg[8] = {B00110,B01001,B01001,B00110,B00000,B00000,B00000,B00000};

void setup()
{
  Serial.begin(115200);  
  rtc.begin();
  lcd.init();
  dht.begin();
  sensors.begin();
  bme.begin();
  sht20.initSHT20();
}

void loop()
{
    sensors.setResolution(12);
    sensors.requestTemperatures();
    humsht = sht20.readHumidity();
    tempsht = sht20.readTemperature();
    lcd.createChar(0, deg); //Create "degree" symbol from byte variable
    humdht = dht.readHumidity(); //Read data and store it to variable hum
    tempdht= dht.readTemperature(); //Read data and store it to variable temp
    temprtc= rtc.getTemp();
    temp18b20 = sensors.getTempCByIndex(0);
    tempbme = bme.readTemperature();
    humbme = bme.readHumidity();
    presbme = bme.readPressure();
    float avgtemp = ((tempdht + temprtc + temp18b20 + tempbme + tempsht) / 5);
    float avghum = ((humdht + humbme + humsht) / 3);
    {
      Serial.print(F("Humidity Sensors RH%: DHT22 = "));
      Serial.print(humdht);
      Serial.print(F(" BME280 = "));
      Serial.print(humbme);
      Serial.print(F(" SHT20 = "));
      Serial.println(humsht);
      Serial.print(F(" Average Humidity = "));
      Serial.println(avghum);
      Serial.print(F("Temperature Sensors Celsius: DHT22 = "));
      Serial.print(tempdht);
      Serial.print(F( " BME280 = "));
      Serial.print(tempbme);
      Serial.print(F(" DS3231 =  "));
      Serial.print(temprtc);
      Serial.print(F(" DS18b20 "));
      Serial.print(temp18b20);
      Serial.print(F(" SHT20 = "));
      Serial.println(tempsht);
      Serial.print(F(" Average Temperature = "));
      Serial.print(avgtemp);
      Serial.println(F(" "));

      lcd.backlight();
      lcd.setCursor(0,0);
      lcd.print(rtc.getDateStr(2,1,'/'));
      lcd.print(F(" "));
      lcd.print(rtc.getTimeStr());
      lcd.setCursor(0, 1);
      lcd.print(avghum);
      lcd.print(F(" %RH"));
      lcd.setCursor(0, 2);
      lcd.print((presbme) / 1000);
      lcd.print(F(" kPa"));
      lcd.setCursor(0,3);
      // lcd.print(rtc.getUnixTime(rtc.getTime()));
      // lcd.print(" ");
      // lcd.print("Unix");

      lcd.print(avgtemp);
      lcd.print(F(" "));
      lcd.write(0);
      lcd.print(F("C"));
  
} if (avgtemp < 14) {
        tone(11, 10000);
      }
      else {
        noTone(11);
      }
  
    }

Data sheet says:

Does that accuracy +/-0.50C mean that displayed reading could be +/-0.50C off - I mean if I observe 27.93750C (for DS18B20, 12-bit resolution) on the monitor, in reality the reading could be 28.4375 or 27.4375?

What is the precision of DS18B20 in 12-bit resolution? Is it 0.06250C?

Is the resolution 16-bit or 20-bit?

So far I know that DS18B20 is factory calibrated (supported by the example of Fig-1); it does not need to be calibrated against a secondary (field) calibrator.


Figure-1:

Well, they would say that - wouldn't they ...
:stuck_out_tongue_winking_eye:

Datasheet first page says
BME280
Combined humidity and pressure sensor
but page two says
BME280
Digital humidity, pressure and temperature sensor
but no information about temperature accuracy.
Page 3 says
The integrated temperature sensor has been optimized for lowest noise and highest resolution. Its output is used for temperature compensation of the pressure and humidity sensors and can also be used for estimation of the ambient temperature.
Page 12 note 7 says
7 Temperature measured by the internal temperature sensor. This temperature value depends on the PCB temperature, sensor element self-heating and ambient temperature and is typically above ambient temperature.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.