mirror of
https://github.com/cmur2/python-bme680.git
synced 2024-12-22 22:54:29 +01:00
Actually write rungas register
This commit is contained in:
parent
306fc84cb5
commit
9619dfce3e
@ -66,6 +66,7 @@ class BME680(BME680Data):
|
|||||||
temp &= ~RUN_GAS_MSK
|
temp &= ~RUN_GAS_MSK
|
||||||
temp |= (value << RUN_GAS_POS)
|
temp |= (value << RUN_GAS_POS)
|
||||||
self.gas_settings.run_gas = value
|
self.gas_settings.run_gas = value
|
||||||
|
self._set_regs(CONF_ODR_RUN_GAS_NBC_ADDR, temp)
|
||||||
|
|
||||||
def set_gas_heater_temperature(self, value):
|
def set_gas_heater_temperature(self, value):
|
||||||
self.gas_settings.heatr_temp = value
|
self.gas_settings.heatr_temp = value
|
||||||
@ -124,10 +125,12 @@ class BME680(BME680Data):
|
|||||||
self.data.heat_stable = (self.data.status & HEAT_STAB_MSK) > 0
|
self.data.heat_stable = (self.data.status & HEAT_STAB_MSK) > 0
|
||||||
|
|
||||||
if self.data.status & NEW_DATA_MSK:
|
if self.data.status & NEW_DATA_MSK:
|
||||||
self.data.temperature = self._calc_temperature(adc_temp)
|
temperature = self._calc_temperature(adc_temp)
|
||||||
self.ambient_temperature = self.data.temperature
|
self.data.temperature = temperature / 100.0
|
||||||
self.data.pressure = self._calc_pressure(adc_pres)
|
self.ambient_temperature = temperature # Saved for heater calc
|
||||||
self.data.humidity = self._calc_humidity(adc_hum)
|
|
||||||
|
self.data.pressure = self._calc_pressure(adc_pres) / 1000.0
|
||||||
|
self.data.humidity = self._calc_humidity(adc_hum) / 1000.0
|
||||||
self.data.gas_resistance = self._calc_gas_resistance(adc_gas_res, gas_range)
|
self.data.gas_resistance = self._calc_gas_resistance(adc_gas_res, gas_range)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import bme680
|
import bme680
|
||||||
|
import time
|
||||||
|
|
||||||
sensor = bme680.BME680()
|
sensor = bme680.BME680()
|
||||||
|
|
||||||
@ -20,7 +21,8 @@ sensor.get_sensor_data()
|
|||||||
|
|
||||||
for name in dir(sensor.data):
|
for name in dir(sensor.data):
|
||||||
value = getattr(sensor.data, name)
|
value = getattr(sensor.data, name)
|
||||||
print("{}: {}".format(name, value))
|
if not name.startswith('_'):
|
||||||
|
print("{}: {}".format(name, value))
|
||||||
|
|
||||||
sensor.set_gas_heater_temperature(320)
|
sensor.set_gas_heater_temperature(320)
|
||||||
sensor.set_gas_heater_duration(150)
|
sensor.set_gas_heater_duration(150)
|
||||||
@ -33,11 +35,12 @@ try:
|
|||||||
if sensor.data.heat_stable:
|
if sensor.data.heat_stable:
|
||||||
print("{}".format(sensor.data.gas_resistance))
|
print("{}".format(sensor.data.gas_resistance))
|
||||||
|
|
||||||
print("{}".format(sensor.data.temperature))
|
print("{} {} {}".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity))
|
||||||
#for name in dir(sensor.data):
|
#for name in dir(sensor.data):
|
||||||
# value = getattr(sensor.data, name)
|
# value = getattr(sensor.data, name)
|
||||||
# if not name.startswith('_'):
|
# if not name.startswith('_'):
|
||||||
# print("{}: {}".format(name, value))
|
# print("{}: {}".format(name, value))
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user