Barometer module¶
The PyMetaWear implementation of the libmetawear
barometer module.
It is initialized at the creation of the MetaWearClient
client and can then be accessed in the barometer
attribute of the client.
Example usage:
from pymetawear.client import MetaWearClient
c = MetaWearClient('DD:3A:7D:4D:56:F0')
# Set a large oversampling value.
c.barometer.set_settings(oversampling='ultra_high')
def barometer_callback(data):
"""Handle a (epoch, altitude) barometer tuple."""
print("[{0}]: Altitude: {1} m".format(*data))
# Enable notifications and register a callback for them.
c.barometer.notifications(barometer_callback)
API¶
Barometer module¶
Created by hbldh <henrik.blidh@nedomkull.com> on 2016-08-16 Modified by lkasso <hello@mbientlab.com>
-
class
pymetawear.modules.barometer.
BarometerModule
(board, module_id)[source]¶ MetaWear barometer module implementation.
Parameters: - board (ctypes.c_long) – The MetaWear board pointer value.
- module_id (int) – The module id of this barometer
component, obtained from
libmetawear
. - debug (bool) – If
True
, module prints out debug information.
-
data_signal
¶ Returns the data signal pointer value for the switch module.
Returns: The pointer value. (Long if on x64 architecture.) Return type: ctypes.c_long
orctypes.c_int
-
module_name
¶ Get module name.
Returns: The name of this module. Return type: str
-
notifications
(callback=None)[source]¶ Subscribe to or unsubscribe from barometer notifications.
Convenience method for handling barometer usage.
Example:
def handle_barometer_notification(data) # Handle dictionary with [epoch, value] keys. epoch = data["epoch"] value = data["value"] print(data) mwclient.barometer.notifications(handle_barometer_notification)
Parameters: callback (callable) – Barometer notification callback function. If None, unsubscription to barometer notifications is registered.
-
sensor_name
¶ Get sensor name, if applicable.
Returns: The name of this module. Return type: str or None
-
set_altitude_data
(status=True)[source]¶ Change between altitude and pressure output.
Parameters: status (bool) –
-
set_settings
(oversampling=None, iir_filter=None, standby_time=None)[source]¶ Set barometer settings.
Can be called with 1-3 setting:
mwclient.set_settings(oversampling='low_power', iir_filter='avg_2', standby_time=125.0)
will give the same result as
mwclient.set_settings(oversampling='low_power') mwclient.set_settings(iir_filter='avg_2') mwclient.set_settings(standby_time=125.0)
albeit that the latter example makes two writes to the board.
Call
get_possible_settings()
to see which values that can be set for this sensor.Parameters: - oversampling (str) –
- iir_filter (str) –
- standby_time (float) –