bme680
- Environmental Sensor¶
Allows access to environmental data of card10’s surroundings.
Example:
import bme680, time
with bme680.Bme680() as environment:
while True:
d = environment.get_data()
print("Temperature: {:10.2f} °C".format(d.temperature))
print("Humidity: {:10.2f} % r.h.".format(d.humidity))
print("Pressure: {:10.2f} hPa".format(d.pressure))
print("Gas Resistance: {:10.2f} Ω".format(d.resistance))
time.sleep(1)
Sensor Class¶
-
class
bme680.
Bme680
[source]¶ BME680 4-in-1 environmental sensor.
Example:
import bme680 environment = bme680.Bme680() print("Current temperature: {:4.1f} °C".format(environment.temperature()))
This class can also be used as a context-manager which will automatically deactivate the sensor on exit:
import bme680 with bme680.Bme680() as environment: print("H: {:4.1f}%".format(environment.humidity())) # Sensor is off again, saving power
New in version 1.10.
-
get_data
()[source]¶ Get all sensor data at once.
get_data()
returns a namedtuple with the following fields:temperature
: Temperature in °Chumidity
: Relative humiditypressure
: Barometric pressure in hPagas_resistance
: Gas resistance in Ω
Example:
import bme680 with bme680.Bme680() as environment: data = environment.get_data() print("T: {}".format(data.temperature)) print("H: {}".format(data.humidity))
-
close
()[source]¶ Stop/deinit the BME680.
If you no longer need measurements, you should call this function to save power.
-
temperature
()[source]¶ Measure current temperature in °C.
Example:
environment = bme680.Bme680() print(str(environment.temperature()))
-
humidity
()[source]¶ Measure current relative humidity.
Example:
environment = bme680.Bme680() print(str(environment.humidity()))
-
Deprecated Interface¶
The following functions should no longer be used directly. The only exist for compatibility as they were the old BME680 interface in previous firmware versions.
-
bme680.
init
()¶ Initialize the sensor.
Before being able to read data from the sensor, you have to call
bme680.init()
.New in version 1.4.
Deprecated since version 1.10: Use the
bme680.Bme680
class instead.
-
bme680.
get_data
()¶ Perform a single measurement of environmental data.
- Returns
Tuple containing
temperature
(°C),humidity
(% r.h.),pressure
(hPa) andgas resistance
(Ohm).
New in version 1.4.
Deprecated since version 1.10: Use the
bme680.Bme680
class instead.
-
bme680.
deinit
()¶ Deinitialize the sensor.
New in version 1.4.
Deprecated since version 1.10: Use the
bme680.Bme680
class instead.