Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
275c99cc
Verified
Commit
275c99cc
authored
5 years ago
by
rahix
Browse files
Options
Downloads
Patches
Plain Diff
docs(bme680): Document new sensor interface
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
e7144129
No related branches found
No related tags found
1 merge request
!286
BME680 Refactor
Pipeline
#3768
passed
5 years ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Documentation/conf.py
+1
-0
1 addition, 0 deletions
Documentation/conf.py
Documentation/pycardium/bme680.rst
+26
-8
26 additions, 8 deletions
Documentation/pycardium/bme680.rst
pycardium/modules/py/bme680.py
+96
-0
96 additions, 0 deletions
pycardium/modules/py/bme680.py
with
123 additions
and
8 deletions
Documentation/conf.py
+
1
−
0
View file @
275c99cc
...
...
@@ -90,6 +90,7 @@ html_context = {
autodoc_mock_imports
=
[
"
buttons
"
,
"
interrupt
"
,
"
sys_bme680
"
,
"
sys_display
"
,
"
sys_leds
"
,
"
sys_max30001
"
,
...
...
This diff is collapsed.
Click to expand it.
Documentation/pycardium/bme680.rst
+
26
−
8
View file @
275c99cc
...
...
@@ -2,6 +2,7 @@
``bme680`` - Environmental Sensor
=================================
Allows access to environmental data of card10's surroundings.
**Example**:
...
...
@@ -9,17 +10,28 @@
import bme680, utime
bme680.init()
with bme680.Bme680() as environment:
while True:
d = environment.get_data()
while True:
temperature, humidity, pressure, resistance = bme680.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))
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)
utime.sleep(1)
Sensor Class
------------
.. autoclass:: bme680.Bme680
:members:
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.
.. py:function:: init()
...
...
@@ -29,6 +41,8 @@
:py:func:`bme680.init`.
.. versionadded:: 1.4
.. deprecated:: 1.10
Use the :py:class:`bme680.Bme680` class instead.
.. py:function:: get_data()
...
...
@@ -38,9 +52,13 @@
``pressure`` (hPa) and ``gas resistance`` (Ohm).
.. versionadded:: 1.4
.. deprecated:: 1.10
Use the :py:class:`bme680.Bme680` class instead.
.. py:function:: deinit()
Deinitialize the sensor.
.. versionadded:: 1.4
.. deprecated:: 1.10
Use the :py:class:`bme680.Bme680` class instead.
This diff is collapsed.
Click to expand it.
pycardium/modules/py/bme680.py
+
96
−
0
View file @
275c99cc
...
...
@@ -10,6 +10,33 @@ Bme680Data = ucollections.namedtuple(
class
Bme680
:
"""
BME680 4-in-1 environmental sensor.
**Example**:
.. code-block:: python
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:
.. code-block:: python
import bme680
with bme680.Bme680() as environment:
print(
"
H: {:4.1f}%
"
.format(environment.humidity()))
# Sensor is off again, saving power
.. versionadded:: 1.10
"""
def
__init__
(
self
):
sys_bme680
.
init
()
...
...
@@ -20,19 +47,88 @@ class Bme680:
self
.
close
()
def
get_data
(
self
):
"""
Get all sensor data at once.
:py:meth:`~bme680.Bme680.get_data` returns a namedtuple with the
following fields:
- ``temperature``: Temperature in *°C*
- ``humidity``: Relative humidity
- ``pressure``: Barometric pressure in *hPa*
- ``gas_resistance``: Gas resistance in *Ω*
**Example**:
.. code-block:: python
import bme680
with bme680.Bme680() as environment:
data = environment.get_data()
print(
"
T: {}
"
.format(data.temperature))
print(
"
H: {}
"
.format(data.humidity))
"""
return
Bme680Data
(
*
sys_bme680
.
get_data
())
def
close
(
self
):
"""
Stop/deinit the BME680.
If you no longer need measurements, you should call this function to
save power.
"""
sys_bme680
.
deinit
()
def
temperature
(
self
):
"""
Measure current temperature in *°C*.
**Example**:
.. code-block:: python
environment = bme680.Bme680()
print(str(environment.temperature()))
"""
return
self
.
get_data
().
temperature
def
humidity
(
self
):
"""
Measure current relative humidity.
**Example**:
.. code-block:: python
environment = bme680.Bme680()
print(str(environment.humidity()))
"""
return
self
.
get_data
().
humidity
def
pressure
(
self
):
"""
Measure current barometric pressure in *hPa*.
**Example**:
.. code-block:: python
environment = bme680.Bme680()
print(str(environment.pressure()))
"""
return
self
.
get_data
().
pressure
def
gas_resistance
(
self
):
"""
Measure current gas resistance in *Ω*.
**Example**:
.. code-block:: python
environment = bme680.Bme680()
print(str(environment.gas_resistance()))
"""
return
self
.
get_data
().
gas_resistance
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment