Skip to content

Commit ded08dd

Browse files
committed
Added temperature offset
1 parent f709a6f commit ded08dd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

adafruit_bme680.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ class Adafruit_BME680:
142142
:param int refresh_rate: Maximum number of readings per second. Faster property reads
143143
will be from the previous reading."""
144144

145-
def __init__(self, *, refresh_rate=10):
145+
def __init__(self, *, refresh_rate=10, temp_offset=5):
146146
"""Check the BME680 was found, read the coefficients and enable the sensor for continuous
147147
reads."""
148+
149+
148150
self._write(_BME680_REG_SOFTRESET, [0xB6])
149151
time.sleep(0.005)
150152

@@ -178,6 +180,9 @@ def __init__(self, *, refresh_rate=10):
178180
self._last_reading = 0
179181
self._min_refresh_time = 1 / refresh_rate
180182

183+
# Set up temperature offset
184+
self.temp_offset = temp_offset
185+
181186
@property
182187
def pressure_oversample(self):
183188
"""The oversampling for pressure sensor"""
@@ -231,7 +236,7 @@ def temperature(self):
231236
"""The compensated temperature in degrees celsius."""
232237
self._perform_reading()
233238
calc_temp = ((self._t_fine * 5) + 128) / 256
234-
return calc_temp / 100
239+
return (calc_temp / 100) - self.temp_offset
235240

236241
@property
237242
def pressure(self):

0 commit comments

Comments
 (0)