Temperature module

The PyMetaWear implementation of the libmetawear temperature module.

It is initialized at the creation of the MetaWearClient client and can then be accessed in the temperature attribute of the client.

Example usage:

from pymetawear.client import MetaWearClient

c = MetaWearClient('DD:3A:7D:4D:56:F0')

def temperature_callback(data):
    """Handle a temperature notification data."""
    epoch = data[0]
    temp = data[1]
    print("[{0}] Temperature {1} C".format(epoch, temp))

# Enable notifications and register a callback for them.
c.temperature.notifications(temperature_callback)
# Trigger temperature notification.
c.temperature.read_temperature()

API

Temperature module

Created by hbldh <henrik.blidh@nedomkull.com> on 2016-04-14

class pymetawear.modules.temperature.TemperatureModule(board)[source]

MetaWear Temperature module implementation.

Parameters:
  • board (ctypes.c_long) – The MetaWear board pointer value.
  • debug (bool) – If True, module prints out debug information.
configure_external_thermistor(channel_id, data_pin, pulldown_pin, active_high)[source]

Configure the external thermistor.

Parameters:
  • channel_id – Channel ID of the external thermistor
  • data_pin (int) – GPIO pin reading the data
  • pulldown_pin (int) – GPIO pin the pulldown resistor is connected to
  • active_high (int) – Zero if the pulldown pin is not active high, non-zero if active high
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 or ctypes.c_int
get_current_settings()[source]

Get the current settings for this module.

Returns:Dict with the name of the currently active channel.
get_possible_settings()[source]

Get the possible settings for this module.

Returns:Dict with the names of the possible channel choices.
module_name

Get module name.

Returns:The name of this module.
Return type:str
notifications(callback=None)[source]

Subscribe or unsubscribe to temperature notifications.

Convenience method for handling temperature usage.

Example:

def temperature_callback(data):
    # Handle dictionary with [epoch, value] keys.
    epoch = data["epoch"]
    xyz = data["value"]
    print(str(data))

mwclient.temperature_func.notifications(temperature_callback)
Parameters:callback (callable) – Temperature notification callback function. If None, unsubscription to temperature_func notifications is registered.
read_temperature()[source]

Triggers a temperature notification.

N.B. that a notifications() call that registers a callback for temperature should have been done prior to calling this method.

set_settings(channel=None)[source]

Set temperature channel settings.

mwclient.temperature.set_settings(channel='On-Die')

Call get_possible_settings() to see which values that can be set for this sensor.

Parameters:channel (str) – The name of the temperature channel to make active.