From 2c60241a7a3d2710973215e576e087fa6e0bde6d Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Thu, 22 Aug 2019 12:52:58 +0200 Subject: [PATCH] docs: Fix bme680 docs Signed-off-by: Rahix <rahix@rahix.de> --- Documentation/index.rst | 1 + Documentation/pycardium/bme680.rst | 43 +++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Documentation/index.rst b/Documentation/index.rst index 0eec748c6..9cf3dac8f 100644 --- a/Documentation/index.rst +++ b/Documentation/index.rst @@ -22,6 +22,7 @@ Last but not least, if you want to start hacking the lower-level firmware, the pycardium/overview pycardium/stdlib + pycardium/bme680 pycardium/buttons pycardium/color pycardium/display diff --git a/Documentation/pycardium/bme680.rst b/Documentation/pycardium/bme680.rst index aa937fdfb..8eb02f23b 100644 --- a/Documentation/pycardium/bme680.rst +++ b/Documentation/pycardium/bme680.rst @@ -1,17 +1,40 @@ -``bme680`` - 4-in-1 Sensor -========================== +.. py:module:: bme680 -.. py:function:: bme680.init() +``bme680`` - Environmental Sensor +================================= - Before being able to read data from the sensor, you have to call init(). +**Example**: -.. py:function:: bme680.get_data() +.. code-block:: python - Does a single measurement to get environmental data. + import bme680, utime - :return: Tuple containing ``temperature`` (°C), ``humidity`` (% r.h.), - ``pressure`` (hPa) and ``gas resistance`` (Ohm). + bme680.init() -.. py:function:: bme680.deinit() + while True: + temperature, humidity, pressure, resistance = bme680.get_data() - De-Initializes the sensor. \ No newline at end of file + 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. -- GitLab