An Elixir library to interface with the BME680 environmental sensor.
The package can be installed
by adding elixir_bme680 to your list of dependencies in mix.exs:
def deps do
[
{:elixir_bme680, "~> 0.1.4"}
]
endThe Linux I2C driver needs to be installed for this library to work (e.g.
libi2c-dev on Debian). If using Nerves, the
driver should already be installed by default.
{:ok, pid} = Bme680.start_link()
measurement = Bme680.measure(pid)
# Measurement is like:
#
# %Bme680.Measurement{
# temperature: 21.74,
# pressure: 1090.52,
# humidity: 45.32,
# gas_resistance: 10235
# }
#
# Where temperature is in degrees Celsius, pressure in hPa, humidity in %
# relative humidity, and gas_resistance in OhmFor more information, read the API documentation.
Note that, due to the nature of the sensor, the gas resistance measurement needs a warm-up in order to give stable measurements. One possible strategy is to perform continuous meaurements in a loop until the value stabilizes (e.g. changing by less than 1% between consecutive measurements). That might take from a few seconds to several minutes (or more when the sensor is brand new), so it's adviseable to perform the measurement asynchronously to avoid blocking.
This project contains low-level code from the BME680 driver by Bosch