bme680.rst 959 Bytes
Newer Older
Rahix's avatar
Rahix committed
1
.. py:module:: bme680
chris007's avatar
chris007 committed
2

Rahix's avatar
Rahix committed
3
4
``bme680`` - Environmental Sensor
=================================
chris007's avatar
chris007 committed
5

Rahix's avatar
Rahix committed
6
**Example**:
chris007's avatar
chris007 committed
7

Rahix's avatar
Rahix committed
8
.. code-block:: python
chris007's avatar
chris007 committed
9

Rahix's avatar
Rahix committed
10
   import bme680, utime
chris007's avatar
chris007 committed
11

Rahix's avatar
Rahix committed
12
   bme680.init()
chris007's avatar
chris007 committed
13

Rahix's avatar
Rahix committed
14
15
   while True:
       temperature, humidity, pressure, resistance = bme680.get_data()
chris007's avatar
chris007 committed
16

Rahix's avatar
Rahix committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
       print("Temperature:    {:10.2f} °C".format(temperature))
       print("Humidity:       {:10.2f} % r.h.".format(humidity))
       print("Pressure:       {:10.2f} hPa".format(pressure))
       print("Gas Resistance: {:10.2f} Ω".format(resistance))

       utime.sleep(1)

.. py:function:: init()

   Initialize the sensor.

   Before being able to read data from the sensor, you have to call
   :py:func:`bme680.init`.

.. py:function:: get_data()

   Perform a single measurement of environmental data.

   :return: Tuple containing ``temperature`` (°C), ``humidity`` (% r.h.),
      ``pressure`` (hPa) and ``gas resistance`` (Ohm).

.. py:function:: deinit()

   Deinitialize the sensor.