Skip to content

Commit

Permalink
Tidied up temp-offset.py example
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Jun 1, 2018
1 parent 4ae50e2 commit 0f0be7f
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions examples/temp-offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,25 @@
sensor.set_temperature_oversample(bme680.OS_8X)
sensor.set_filter(bme680.FILTER_SIZE_3)

def display_data(offset=0):
sensor.set_temp_offset(offset)
sensor.get_sensor_data()
output = "{0:.2f} C, {1:.2f} hPa, {2:.3f} %RH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
print(output)
print("")

print("Initial readings")
sensor.get_sensor_data()
output = "{0:.2f} C,{1:.2f} hPa,{2:.3f} %RH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
print(output)
display_data()

print("SET offset 4 degrees celsius")
sensor.set_temp_offset(4)
sensor.get_sensor_data()
output = "{0:.2f} C,{1:.2f} hPa,{2:.3f} %RH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
print(output)
display_data(4)

print("SET offset -1.87 degrees celsius")
sensor.set_temp_offset(-1.87)
sensor.get_sensor_data()
output = "{0:.2f} C,{1:.2f} hPa,{2:.3f} %RH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
print(output)
display_data(-1.87)

print("SET offset -100 degrees celsius")
sensor.set_temp_offset(-100)
sensor.get_sensor_data()
output = "{0:.2f} C,{1:.2f} hPa,{2:.3f} %RH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
print(output)
display_data(-100)

print("SET offset 0 degrees celsius")
sensor.set_temp_offset(0)
sensor.get_sensor_data()
output = "{0:.2f} C,{1:.2f} hPa,{2:.3f} %RH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)
print(output)
display_data(0)

0 comments on commit 0f0be7f

Please sign in to comment.