Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

TE Connectivity HTU31D temperature and humidity sensor. More...

Files

file  htu31d.h
 Header file for extended sensor API of HTU31D sensor.

Functions

int htu31d_heater_set (const struct device *dev, bool enable)
 Enable or disable the on-chip heater.
int htu31d_read_diagnostics (const struct device *dev, uint8_t *diag)
 Read the sensor diagnostics register.
int htu31d_read_serial (const struct device *dev, uint32_t *serial)
 Read the factory-programmed 24-bit serial number.

Diagnostics register bit flags

Bit positions of the diagnostics byte returned by htu31d_read_diagnostics().

#define HTU31D_DIAG_HEATER_ON   BIT(0)
 Heater is currently enabled.
#define HTU31D_DIAG_TEMP_LOW_ERR   BIT(1)
 Temperature below minimum.
#define HTU31D_DIAG_TEMP_HIGH_ERR   BIT(2)
 Temperature above maximum.
#define HTU31D_DIAG_TEMP_OVER_ERR   BIT(3)
 Temperature under/over-run.
#define HTU31D_DIAG_HUMI_LOW_ERR   BIT(4)
 Humidity below minimum.
#define HTU31D_DIAG_HUMI_HIGH_ERR   BIT(5)
 Humidity above maximum.
#define HTU31D_DIAG_HUMI_OVER_ERR   BIT(6)
 Humidity under/over-run.
#define HTU31D_DIAG_NVM_ERR   BIT(7)
 NVM checksum error.

Detailed Description

TE Connectivity HTU31D temperature and humidity sensor.

Macro Definition Documentation

◆ HTU31D_DIAG_HEATER_ON

#define HTU31D_DIAG_HEATER_ON   BIT(0)

#include <zephyr/drivers/sensor/htu31d.h>

Heater is currently enabled.

◆ HTU31D_DIAG_HUMI_HIGH_ERR

#define HTU31D_DIAG_HUMI_HIGH_ERR   BIT(5)

#include <zephyr/drivers/sensor/htu31d.h>

Humidity above maximum.

◆ HTU31D_DIAG_HUMI_LOW_ERR

#define HTU31D_DIAG_HUMI_LOW_ERR   BIT(4)

#include <zephyr/drivers/sensor/htu31d.h>

Humidity below minimum.

◆ HTU31D_DIAG_HUMI_OVER_ERR

#define HTU31D_DIAG_HUMI_OVER_ERR   BIT(6)

#include <zephyr/drivers/sensor/htu31d.h>

Humidity under/over-run.

◆ HTU31D_DIAG_NVM_ERR

#define HTU31D_DIAG_NVM_ERR   BIT(7)

#include <zephyr/drivers/sensor/htu31d.h>

NVM checksum error.

◆ HTU31D_DIAG_TEMP_HIGH_ERR

#define HTU31D_DIAG_TEMP_HIGH_ERR   BIT(2)

#include <zephyr/drivers/sensor/htu31d.h>

Temperature above maximum.

◆ HTU31D_DIAG_TEMP_LOW_ERR

#define HTU31D_DIAG_TEMP_LOW_ERR   BIT(1)

#include <zephyr/drivers/sensor/htu31d.h>

Temperature below minimum.

◆ HTU31D_DIAG_TEMP_OVER_ERR

#define HTU31D_DIAG_TEMP_OVER_ERR   BIT(3)

#include <zephyr/drivers/sensor/htu31d.h>

Temperature under/over-run.

Function Documentation

◆ htu31d_heater_set()

int htu31d_heater_set ( const struct device * dev,
bool enable )

#include <zephyr/drivers/sensor/htu31d.h>

Enable or disable the on-chip heater.

The heater can be used to burn off condensation or perform sensor self-diagnostics. It increases the measured temperature by several degrees while enabled and should not be left on continuously.

Parameters
devPointer to the sensor device.
enableTrue to enable the heater, false to disable it.
Returns
0 on success, negative errno on I2C error.

◆ htu31d_read_diagnostics()

int htu31d_read_diagnostics ( const struct device * dev,
uint8_t * diag )

#include <zephyr/drivers/sensor/htu31d.h>

Read the sensor diagnostics register.

The diagnostics byte reports persistent fault flags; decode the returned value using the HTU31D_DIAG_* bit macros.

Parameters
devPointer to the sensor device.
diagOutput, populated with the 8-bit diagnostics word.
Returns
0 on success, -EIO on CRC failure, or another negative errno.

◆ htu31d_read_serial()

int htu31d_read_serial ( const struct device * dev,
uint32_t * serial )

#include <zephyr/drivers/sensor/htu31d.h>

Read the factory-programmed 24-bit serial number.

Parameters
devPointer to the sensor device.
serialOutput, populated with the 24-bit serial number in the low three bytes (upper byte is zero).
Returns
0 on success, -EIO on CRC failure, or another negative errno.