pyupm_htu21d module

class pyupm_htu21d.HTU21D(bus, devAddr=64)[source]

Bases: 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

getCompRH(bSampleData=False)[source]

float getCompRH(int bSampleData=false)

Using the current humidity and temperature, the function calculates the compensated RH using the equation from the datasheet.

bSampleData: Flag to sample sensor (default false)

Compensated relative humidity in RH

getDewPoint(bSampleData=False)[source]

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.

bSampleData: Flag to sample sensor (default false)

Dew point in degC

getHumidity(bSampleData=False)[source]

float getHumidity(int bSampleData=false)

Gets the current measured humidity [RH]

bSampleData: Flag to sample sensor (default false)

Relative humidity in RH

getHumidityData(fHum, fHumTemp, fDewPt)[source]

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

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

getTemperature(bSampleData=False)[source]

float getTemperature(int bSampleData=false)

Gets the humidity cell temperature [degC]

bSampleData: Flag to sample sensor (default false)

Temperature in degC

i2cReadReg_16(reg)[source]

uint16_t i2cReadReg_16(int reg)

Reads a two-byte register. Note: byte ordering is hardware specific.

reg: Address of the register

Value returned from register

i2cReadReg_8(reg)[source]

uint8_t i2cReadReg_8(int reg)

Reads a one-byte register

reg: Address of the register

Value returned from register

i2cWriteReg(reg, value)[source]

mraa::Result i2cWriteReg(uint8_t reg, uint8_t value)

Writes to a one-byte register

reg: Address of the register

value: Byte to be written

resetSensor()[source]

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.

sampleData()[source]

int sampleData(void)

Initiates a temperature/pressure mesasurement and waits to complete. The humidity and temperature registers can be read after this call.

setHeater(bEnable=False)[source]

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.

bEnable: Sets to non-zero to turn the heater on

0 on success

testSensor()[source]

int testSensor(void)

Tests the device and verifies it is operating correctly.

0 on success or error code