# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyupm_htu21d', [dirname(__file__)])
except ImportError:
import _pyupm_htu21d
return _pyupm_htu21d
if fp is not None:
try:
_mod = imp.load_module('_pyupm_htu21d', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_htu21d = swig_import_helper()
del swig_import_helper
else:
import _pyupm_htu21d
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr_nondynamic(self, class_type, name, static=1):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
if (not static):
return object.__getattr__(self, name)
else:
raise AttributeError(name)
def _swig_getattr(self, class_type, name):
return _swig_getattr_nondynamic(self, class_type, name, 0)
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object:
pass
_newclass = 0
def getVersion():
return _pyupm_htu21d.getVersion()
getVersion = _pyupm_htu21d.getVersion
_pyupm_htu21d.HTU21D_NAME_swigconstant(_pyupm_htu21d)
HTU21D_NAME = _pyupm_htu21d.HTU21D_NAME
_pyupm_htu21d.HTU21D_I2C_ADDRESS_swigconstant(_pyupm_htu21d)
HTU21D_I2C_ADDRESS = _pyupm_htu21d.HTU21D_I2C_ADDRESS
_pyupm_htu21d.HTU21D_READ_TEMP_HOLD_swigconstant(_pyupm_htu21d)
HTU21D_READ_TEMP_HOLD = _pyupm_htu21d.HTU21D_READ_TEMP_HOLD
_pyupm_htu21d.HTU21D_READ_HUMIDITY_HOLD_swigconstant(_pyupm_htu21d)
HTU21D_READ_HUMIDITY_HOLD = _pyupm_htu21d.HTU21D_READ_HUMIDITY_HOLD
_pyupm_htu21d.HTU21D_WRITE_USER_REG_swigconstant(_pyupm_htu21d)
HTU21D_WRITE_USER_REG = _pyupm_htu21d.HTU21D_WRITE_USER_REG
_pyupm_htu21d.HTU21D_READ_USER_REG_swigconstant(_pyupm_htu21d)
HTU21D_READ_USER_REG = _pyupm_htu21d.HTU21D_READ_USER_REG
_pyupm_htu21d.HTU21D_SOFT_RESET_swigconstant(_pyupm_htu21d)
HTU21D_SOFT_RESET = _pyupm_htu21d.HTU21D_SOFT_RESET
_pyupm_htu21d.HTU21D_DISABLE_OTP_swigconstant(_pyupm_htu21d)
HTU21D_DISABLE_OTP = _pyupm_htu21d.HTU21D_DISABLE_OTP
_pyupm_htu21d.HTU21D_HEATER_ENABLE_swigconstant(_pyupm_htu21d)
HTU21D_HEATER_ENABLE = _pyupm_htu21d.HTU21D_HEATER_ENABLE
_pyupm_htu21d.HTU21D_END_OF_BATTERY_swigconstant(_pyupm_htu21d)
HTU21D_END_OF_BATTERY = _pyupm_htu21d.HTU21D_END_OF_BATTERY
_pyupm_htu21d.HTU21D_RESO_RH12_T14_swigconstant(_pyupm_htu21d)
HTU21D_RESO_RH12_T14 = _pyupm_htu21d.HTU21D_RESO_RH12_T14
_pyupm_htu21d.HTU21D_RESO_RH8_T12_swigconstant(_pyupm_htu21d)
HTU21D_RESO_RH8_T12 = _pyupm_htu21d.HTU21D_RESO_RH8_T12
_pyupm_htu21d.HTU21D_RESO_RH10_T13_swigconstant(_pyupm_htu21d)
HTU21D_RESO_RH10_T13 = _pyupm_htu21d.HTU21D_RESO_RH10_T13
_pyupm_htu21d.HTU21D_RESO_RH11_T11_swigconstant(_pyupm_htu21d)
HTU21D_RESO_RH11_T11 = _pyupm_htu21d.HTU21D_RESO_RH11_T11
[docs]class HTU21D(_object):
"""
API for the HTU21D Temperature & Humidity Sensor.
ID: htu21d
Name: Digital Relative Humidity Sensor with Temperature
Category: temp
Manufacturer: seeed adafruit sparkfun
Link:http://www.meas-spec.com/downloads/HTU21D.pdf
Connection: i2c HTU21D by Measurement Specialties is a digital
humidity sensor with temperature output. RH reports between 0 and
100%, and the temperature range is -40 to +125 degC. Note: getCompRH
is the preferred function below (passing true to cause a measurement
cycle). If actual values used for the compensated ready are necessary,
use the getHumidity(false) and getTemperature(false) functions
following the getCompRH call. Also note the sensor should not perform
more than a couple of measurements per second to limit the heating of
the sensor.
C++ includes: htu21d.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, HTU21D, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, HTU21D, name)
__repr__ = _swig_repr
def __init__(self, bus, devAddr=0x40):
"""
HTU21D(int bus, int
devAddr=HTU21D_I2C_ADDRESS)
Instantiates an HTU21D object
Parameters:
-----------
bus: Number of the used bus
devAddr: Address of the used I2C device
"""
this = _pyupm_htu21d.new_HTU21D(bus, devAddr)
try:
self.this.append(this)
except Exception:
self.this = this
[docs] def sampleData(self):
"""
int sampleData(void)
Initiates a temperature/pressure mesasurement and waits to complete.
The humidity and temperature registers can be read after this call.
"""
return _pyupm_htu21d.HTU21D_sampleData(self)
[docs] def getHumidity(self, bSampleData=False):
"""
float
getHumidity(int bSampleData=false)
Gets the current measured humidity [RH]
Parameters:
-----------
bSampleData: Flag to sample sensor (default false)
Relative humidity in RH
"""
return _pyupm_htu21d.HTU21D_getHumidity(self, bSampleData)
[docs] def getTemperature(self, bSampleData=False):
"""
float
getTemperature(int bSampleData=false)
Gets the humidity cell temperature [degC]
Parameters:
-----------
bSampleData: Flag to sample sensor (default false)
Temperature in degC
"""
return _pyupm_htu21d.HTU21D_getTemperature(self, bSampleData)
[docs] def getCompRH(self, bSampleData=False):
"""
float getCompRH(int
bSampleData=false)
Using the current humidity and temperature, the function calculates
the compensated RH using the equation from the datasheet.
Parameters:
-----------
bSampleData: Flag to sample sensor (default false)
Compensated relative humidity in RH
"""
return _pyupm_htu21d.HTU21D_getCompRH(self, bSampleData)
[docs] def getDewPoint(self, bSampleData=False):
"""
float
getDewPoint(int bSampleData=false)
Using the current humidity and temperature the function will calculate
the dew point in degreeC based on equation from the datasheet.
Parameters:
-----------
bSampleData: Flag to sample sensor (default false)
Dew point in degC
"""
return _pyupm_htu21d.HTU21D_getDewPoint(self, bSampleData)
[docs] def getHumidityData(self, fHum, fHumTemp, fDewPt):
"""
int
getHumidityData(float *fHum, float *fHumTemp, float *fDewPt)
Function will attempt to get the best measurement for humidity using
the heater in cases where humidity is high to keep the sesnsor dry.
The heater setting is returned
Parameters:
-----------
fHum: pointer to float for relative humidity RH
fHumTemp: pointer to float for temperature degC
fDewPt: pointer to float for calculated dew point degC
0 if success or 1 if sensor is not functioning
"""
return _pyupm_htu21d.HTU21D_getHumidityData(self, fHum, fHumTemp, fDewPt)
[docs] def setHeater(self, bEnable=False):
"""
int setHeater(int
bEnable=false)
Sets the heater state. The heater is used to test the sensor
functionality since the temperature should increase 0.5 to 1.5 degC,
and the humidity should decrease. The testSensor() function below uses
the heater.
Parameters:
-----------
bEnable: Sets to non-zero to turn the heater on
0 on success
"""
return _pyupm_htu21d.HTU21D_setHeater(self, bEnable)
[docs] def resetSensor(self):
"""
void
resetSensor(void)
Performs a soft reset of the MPL3115A2 device to ensure it is in a
known state. This function can be used to reset the min/max
temperature and pressure values.
"""
return _pyupm_htu21d.HTU21D_resetSensor(self)
[docs] def testSensor(self):
"""
int testSensor(void)
Tests the device and verifies it is operating correctly.
0 on success or error code
"""
return _pyupm_htu21d.HTU21D_testSensor(self)
[docs] def i2cWriteReg(self, reg, value):
"""
mraa::Result
i2cWriteReg(uint8_t reg, uint8_t value)
Writes to a one-byte register
Parameters:
-----------
reg: Address of the register
value: Byte to be written
"""
return _pyupm_htu21d.HTU21D_i2cWriteReg(self, reg, value)
[docs] def i2cReadReg_16(self, reg):
"""
uint16_t
i2cReadReg_16(int reg)
Reads a two-byte register. Note: byte ordering is hardware specific.
Parameters:
-----------
reg: Address of the register
Value returned from register
"""
return _pyupm_htu21d.HTU21D_i2cReadReg_16(self, reg)
[docs] def i2cReadReg_8(self, reg):
"""
uint8_t
i2cReadReg_8(int reg)
Reads a one-byte register
Parameters:
-----------
reg: Address of the register
Value returned from register
"""
return _pyupm_htu21d.HTU21D_i2cReadReg_8(self, reg)
__swig_destroy__ = _pyupm_htu21d.delete_HTU21D
__del__ = lambda self: None
HTU21D_swigregister = _pyupm_htu21d.HTU21D_swigregister
HTU21D_swigregister(HTU21D)
# This file is compatible with both classic and new-style classes.