Compare piicodev TMP117 and BME280 temperature sensors

There has been discussion about checking the accuracy of temperature sensors but fairly academic without a calibrated reference. We can however compare readings from two sensors. We can also check their drift and repeatability.

So I set up a piicodev TMP117 +/-0.1degC and BME280 +/-0.5degC in parallel.

Both sensors had initial drift with the TMP117 going up and the BME280 going down but after a minute they both settled down. The repeatability of both sensors was excellent reading to 2 decimal places.

But the temperature readings were a big shock viz

22.89 °C TMP117
20.85 °C 1000.8 hPa 70.0 %RH BME280

Yes, that is two degrees difference.
Would anyone care to comment on the reason please.

Here is my code just in case I have made a mistake.

#This program compares the temperature of the PiicoDev TMP117 and BME280 sensors

from PiicoDev_TMP117 import PiicoDev_TMP117
from PiicoDev_BME280 import PiicoDev_BME280
from time import sleep

TMP117Sensor = PiicoDev_TMP117()
TMP117Sensor.addr = 0x48
BME280Sensor = PiicoDev_BME280(t_mode=2, p_mode=5, h_mode=1, iir=2)

while True:
    TMP117Temp = round(TMP117Sensor.readTempC(), 2) # Celsius
    BME280Temp, presPa, humRH = BME280Sensor.values()
    pres_hPa = presPa / 100
    # Convert temperature into a string and print the data
    print(str(TMP117Temp) + " °C TMP117")
    print(str(BME280Temp) + " °C  " + str(round(pres_hPa, 1)) + " hPa  " + str(round(humRH, 1)) +" %RH BME280")
    sleep(5) # delay 5 seconds
5 Likes

BTW I am using a pi zero W running buster lite.

Following up I swapped out the piicodev BME280 for another with the following results.

21.99 °C TMP117
21.08 °C 1007.3 hPa 74.2 %RH BME280
0.91 °C difference

The difference at 0.91 degC is much smaller but still disapointing results because it means that the 2 BME280 boards rated at +/-0.5 degC are over a degree apart. The TMP117 +/- 0.1 degC is the higher spec chip so using that as a “reference” it means that the BME280’s are one to two degrees below. It had been my intention to use the BME280 in a project but I will now have to abandon that or calibrate them to a reference and insert an offset in the code.

I have updated the code to improve the formatting. Not sure if anyone is interested but here is the revised code.

# This program compares the temperature of the PiicoDev TMP117 and BME280 sensors
# Courtesy of Chris Barlow 

from PiicoDev_TMP117 import PiicoDev_TMP117
from PiicoDev_BME280 import PiicoDev_BME280
from time import sleep

TMP117Sensor = PiicoDev_TMP117()
TMP117Sensor.addr = 0x48
BME280Sensor = PiicoDev_BME280(t_mode=2, p_mode=5, h_mode=1, iir=2)

while True:
    TMP117Temp = round(TMP117Sensor.readTempC(), 2) # Celsius
    BME280Temp, presPa, humRH = BME280Sensor.values()
    pres_hPa = presPa / 100
    # Print the data
    print(str("{:.2f}".format(TMP117Temp) + " °C TMP117"))
    print(str("{:.2f}".format(BME280Temp)) + " °C  " + str("{:.1f}".format(pres_hPa, 1)) + " hPa  " + str("{:.1f}".format(humRH, 1)) +" %RH BME280")
    print(str("{:.2f}".format((TMP117Temp - BME280Temp), 2)) + " °C difference")
    print("----------")
    sleep(5) # delay 5 seconds
6 Likes

With respect to BME280, I read somewhere there is a known self heating problem with the sensor.
I certainly experienced it when using those sensors.
The TMP117 is my preferred temperature sensor.
I have also used a DS18B20, and trust its measurements.

Cheers
Jim

4 Likes

Hi All
I think any of these semiconductor type temperature sensors have a self heating problem. Before all these fancy devices came around there were little devices that looked like a small transistor which passed 1”A per ÂșK which conveniently gave you 10mV per Âș across a 10k resistor to ground.This could be offset by 2.73V with an OPamp to convert to ÂșC. To minimise self heating the input voltage to this device was made as low as practical so most of the voltage drop and thus power occurred across the resistor.

These devices worked quite well if you accounted for limitations like self heating but I think you will find any semiconductor device will have this problem, some to a lesser degree than others.
Cheers Bob

5 Likes

Indeed, here are a couple of choice quotes from the BME280 datasheet:

The BME280 achieves high performance in all applications requiring humidity and pressure
measurement. These emerging applications of home automation control, in-door navigation,
health care as well as GPS refinement require a high accuracy and a low TCO at the same
time.

The humidity sensor provides an extremely fast response time for fast context awareness
applications and high overall accuracy over a wide temperature range.

The pressure sensor is an absolute barometric pressure sensor with extremely high accuracy
and resolution and drastically lower noise than the Bosch Sensortec BMP180.

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.

And

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.

The BME280 does have a very accurate temperature sensor, but the temperature it measures is higher than ambient.

For a best chance at accuracy, you’d be best to only power on the BME280 intermittently.

4 Likes

Thanks for your replies everyone.

Reading the technical literature it seems that the BME280 was designed for humidity and pressure measurements. The temperature measurement is included to improve the accuracy of these measurements and that it can be read seems to be incidental. The tech specs boast of the humidity and pressure performance but no mention is made of the temperature. My experience is that the BME280 is reading below ambient temperature.

So from my testing the BME280 is of no use if a reasonably accurate absolute temperature reading is needed. For my application which requires temperature, humidity and pressure measurements that is a nuisance because it now requires both a TMP117 and a BME280.

From running the above code my experience is that drift and repeatability of measurements is not a major issue. The TMP117 quickly stabilised but even the BME280 was steady after about 30 seconds. The trick I have found with the BME280 is to initially rapid fire it with some throw away measurements. Also in my (and others) experience a new BME280 sensor requires 30 minutes of burn in.

6 Likes

Also, depends on the manufacturing process. There are recommendations in the datasheet for post reflow treatment to readjust the sensor humidity and temp sensors - one of the scenarios actually requires 5 days in 70% humidity I think - so this might be the ‘burn in’ you’re seeing. It probably happens pretty well while it’s sitting on the shelf in its packaging though.

4 Likes

Hi Fractal
What sort of absolute accuracy are you after or are you just comparing sensors.

If you are talking about an absolute reference I think the only one available to us mere mortals is a container of ice water (0 DegC).

The Met Bureau publish weather temperatures to 1 decimal place so it would be interesting to know what they use.
Cheers Bob

3 Likes

Hi Robert93820

I am trying to achieve one decimal place of accuracy the same as the Met Bureau. At this point I am going with the TMP117 for temperature and the BME280 for humidity and pressure. It will be nice to have a Davis weather station for a fraction of the cost but with the programability of the raspberry pi.

If there is a volunteer prepared to dunk their TMP117 in ice water would love to hear the results. :wink:

The Bureau uses the resistance temperature detector (RTD) but these cost hundreds of dollars.

3 Likes

If the inaccuracy of the BME280 is due to “self heating” why do both those tested give readings lower than the TMP117? Have you tested another TMP117 against any other sensor?

3 Likes

Hi John
Maybe it is the TMP117 that is self heating.
You will never find out while you keep comparing only the 2.
To get a definitive answer you will have to compare against a known lab instrument or try the iced water.

Reminds me of the old Marconi 1MHz frequency standard system before the current crop of super accurate standards. The idea was to have 3 (very good) oscillators. they were compared and the 2 closest were considered most likely to be correct and were used. The third was disregarded. This process was continuous.

Maybe 3 different temperature sensors could be subject to a similar comparing system to decide which is most probably correct. I think “most probably” is about as good as the home hobbyist could get.
Cheers Bob

EDIT.
My apologies to John, I realise now he was only replying. My response was really targeted to all interested parties.
Cheers Bob

3 Likes

I had a second TMP117 so I did a comparison to two decimal places

The first unit was reading in the range 27.73 to 27.74 degC

The second unit was reading in the range 27.71 to 27.72 degC

That is a remarkable difference of only 0.02 degC and easily delivers one decimal place of accuracy.

The second unit was new and again I saw this burn in characteristic. It started at 28.22 and took about a minute to fall to the stable temperature of around 27.72. The second time I powered it up this did not happen.

The BME280 was reading 27.07 degC.

3 Likes

Hi Fractal
I meant 3 or more different brands.
Cheers Bob

3 Likes

Hi Fractal
Just re read your last post.
Rounded to 1 decimal place the 2 TMP117 units read 27.7ÂșC and the BME280 27.1C. A difference of just 0.6ÂșC. There are any number of reasons for this slight discrepancy and one could be slight positional differences. To be precise the devices would have to be in precisely the same environment and the only way you could guarantee that would be to immerse the units in a fluid, like water.

Anyway, 0.6Âș!!!. What are you trying to measure. I would consider that discrepancy not too bad for a device costing only a few dollars. There is a reason the devices used by the Met cost $hundreds and they only publish to 1 decimal place. I am afraid that if you want the same accuracy, repeatability and reliability you may have to fork out the same sort of $$$.
Cheers Bob

3 Likes

Hi Fractal and All interested parties.
Just had a look at what is available on Core web site. These sensors seem to have a variety of PC board sizes which surely must have some influence when comparing. That is some will have a larger “collection” area than others.

Now the original specs would have been written about the bare device. If those specs have just been transferred to the finished product and no allowance made for different “collection” areas any comparison could be a bit in error.

I also notice that some products have cuts in the board. 3 items have a cut down 2 sides while 2 have a cut around 3 sides leaving the sensor itself sitting on a little island. I think this has been possibly done to reduce the “collection” properties of the board and form some degree of isolation.

I feel that 2 different board sizes could easily account for the 0.6ÂșC difference found above. I am only guessing here as we don’t know exactly which units are being compared. There are multiple versions of each of them. I don’t think my guess would be too far wrong.
Cheers Bob

2 Likes

Guys,
anyone have access to (say) four piicodev TMP117? Curious to know how they would read “out-of-the-box” and how will they would track.
Cheers

1 Like

Hi Allan
I would think all 4 would be very close especially if they are the same brand of board. I just had a look at Core site and they carry 3 different brands using the same sensor (TMP117) and they all look pretty much the same. Board material may be different.

So, assuming they are all the same board and all within a smidgen of one another. What does that tell us? It says the manufacturing techniques are pretty good and repeatability is good. It does NOT tell us how accurate they actually are. The only resource available to us mere mortals is the Data Sheets and that is going to tell us they are probably good. Outside a pretty good laboratory that is.

The original thread here was comparing 2 different types of sensor. The results came back as 0.6ÂșC difference after normalising to 1 decimal place. I personally think that either device would be pretty good for what they are designed for so what if we say one is 0.3ÂșC high and the other 0.3ÂșC low then the result is quite good for a device costing only a few $$ and you could use either one happily and not know the difference.

Of course if you need something super accurate with a calibration certificate one must be prepared to pay somewhat more but that is the only way you can be sure. Comparing random devices on a “kitchen table” or normal workshop environment is not really productive (unless you find 1 or 2 way off) and will not prove outright accuracy.
Cheers Bob

1 Like

I also have experienced the same issue of using the BME280 under reporting values.
The BME280 sensor expected accuracy is
temp +/- 0.5C, Pressure +/- 1.5hPa and humidity +/- 1%
Refer the attached BME280 datasheet - in particular chapters 3.3 and 3.4 - Sensor measurements and measurement flow.
I am aware that you can change these settings in your code - t_mode = temp, p_mode=pressure, h_mode= humidity, iir = noise filter.
Changing settings will depend on what you intend to use the sensor for - weather station, humidity or indoors. So can can change these settings accordingly.
BME280Sensor = PiicoDev_BME280(t_mode=2, p_mode=5, h_mode=1, iir=2)

For my purpose I do not need the accuracy.
I have compared the sensor to a weather station and have noted the following.
Temperature is out by factor of 1.08 (8%)
Pressure - 1.02 (2%)
Humidity - 1.06 (6%)
I have altered my code to change each of these values by these factors for the temperature ranges I am using and is now satisfactory for my purposes.
Refer attached examples of my comparison before and after changing my codes.
Using Pico, BME280, ENS160, OLED SSD1306 and Micropython.
Appears this is a noted issue above.

BME280_Calibrate_Example.zip (608.2 KB)
BME280_Datasheet.pdf (1.5 MB)

1 Like

Hi Steffan

Just how did you do that. I did not think things like a BOM weather stations would be accessible to the public or do you have authorised access.

To make this comparison you would need to have your sensor physically sitting alongside the weather station sensor as close as possible. If you have it anywhere else the comparison is approximate at best although it will give you a general idea. Although possibly to a lesser extent the same would apply to the other sensors as well.
Cheers Bob

Refer my attachments - I have included a photo of my pico setup alongside a commercial home weather station that measures both inside and outside measurements of weather conditions. More expensive versions of this weather station include a weather vane and rain gauge. It is this unit that I am comparing with both before and after corrections.
For pressure one can also refer to the BOM for indicative pressure values

I was trying to determine if my unit is faulty or if it is a known issue.
For the $ value and after correction of my BME280 it has been a valuable learning tool and has provided me with satisfactory results.