pht 2.0.0.0
PHT Click Driver

API for configuring and manipulating PHT Click driver. More...

Topics

 PHT Registers Settings
 Settings for registers of PHT Click driver.
 
 PHT MikroBUS Map
 MikroBUS pin mapping of PHT Click driver.
 

Functions

void pht_cfg_setup (pht_cfg_t *cfg)
 PHT configuration object setup function.
 
err_t pht_init (pht_t *ctx, pht_cfg_t *cfg)
 PHT initialization function.
 
err_t pht_generic_write (pht_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 PHT I2C writing function.
 
err_t pht_generic_read (pht_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 PHT I2C reading function.
 
void pht_set_command (pht_t *ctx, uint8_t sensor_type, uint8_t cmd)
 Set Command function.
 
void pht_soft_reset (pht_t *ctx, uint8_t sensor_type)
 Soft Reset function.
 
uint8_t pht_get_prom (pht_t *ctx, uint8_t sel_data, uint32_t *tx_data)
 Calibration Data Read function.
 
uint8_t pht_set_ratio (pht_t *ctx, uint8_t temp_ratio, uint8_t press_ratio)
 Set Ratio function.
 
void pht_reset (pht_t *ctx)
 Reset function.
 
void pht_write_user_register (pht_t *ctx, uint8_t tx_data)
 Write User Register function.
 
uint8_t pht_read_user_register (pht_t *ctx)
 Raed User Register function.
 
uint8_t pht_measure_rh (pht_t *ctx, uint16_t *rh_data)
 Measure RH function.
 
void pht_get_temperature_pressure (pht_t *ctx, float *temperature, float *pressure)
 Get temperature and pressure function.
 
void pht_get_relative_humidity (pht_t *ctx, float *humidity)
 Get humidity function.
 

Detailed Description

API for configuring and manipulating PHT Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ pht_cfg_setup()

void pht_cfg_setup ( pht_cfg_t * cfg)

PHT configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See pht_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ pht_generic_read()

err_t pht_generic_read ( pht_t * ctx,
uint8_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

PHT I2C reading function.

This function reads a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
[in]reg: Start register address.
[out]rx_buf: Output read data.
[in]rx_len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ pht_generic_write()

err_t pht_generic_write ( pht_t * ctx,
uint8_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

PHT I2C writing function.

This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
[in]reg: Start register address.
[in]tx_buf: Data to be written.
[in]tx_len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ pht_get_prom()

uint8_t pht_get_prom ( pht_t * ctx,
uint8_t sel_data,
uint32_t * tx_data )

Calibration Data Read function.

The function reads calibration data from PROM of MS8607 PHT ( Pressure, Humidity and Temperature ) Combination Sensor on the PHT click board.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
[in]sel_data: Select coefficient from 0 to 7 which be read;
[in]tx_data: Buffer where coefficient be stored;
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ pht_get_relative_humidity()

void pht_get_relative_humidity ( pht_t * ctx,
float * humidity )

Get humidity function.

The function performs humidity measurements with desired oversampling ratio and performs the calculations that converts humidity data in mBar of MS8607 PHT ( Pressure, Humidity and Temperature ) Combination Sensor on the PHT click board.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
[out]humidity: Pointer to the memory location where humidity (percentage) be stored.
Returns
Nothing.

◆ pht_get_temperature_pressure()

void pht_get_temperature_pressure ( pht_t * ctx,
float * temperature,
float * pressure )

Get temperature and pressure function.

The function performs temperature and pressure measurements with desired oversampling ratio and performs the calculations that converts temperature data in celsius value and pressure data in mbar value of MS8607 PHT ( Pressure, Humidity and Temperature ) Combination Sensor on the PHT click board.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
[out]temperature: Pointer to the memory location where temperature (degree Celsius) be stored.
[out]pressure: Pointer to the memory location where pressure (mBar) be stored.
Returns
Nothing.

◆ pht_init()

err_t pht_init ( pht_t * ctx,
pht_cfg_t * cfg )

PHT initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See pht_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See pht_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ pht_measure_rh()

uint8_t pht_measure_rh ( pht_t * ctx,
uint16_t * rh_data )

Measure RH function.

The function performs humidity measurements of MS8607 PHT ( Pressure, Humidity and Temperature ) Combination Sensor on the PHT click board.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
[out]rh_data: Pointer to the memory location where humidity data be stored.
Returns
8-bit status.

◆ pht_read_user_register()

uint8_t pht_read_user_register ( pht_t * ctx)

Raed User Register function.

The function read the byte of the data from the user register of MS8607 PHT ( Pressure, Humidity and Temperature ) Combination Sensor on the PHT click board.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
Returns
8-bit status register.

◆ pht_reset()

void pht_reset ( pht_t * ctx)

Reset function.

The function performs the device reset and reads calibration coefficients after reset, which are necessary for temperature and pressure calculation of MS8607 PHT ( Pressure, Humidity and Temperature ) Combination Sensor on the PHT click board.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
Returns
Nothing.

◆ pht_set_command()

void pht_set_command ( pht_t * ctx,
uint8_t sensor_type,
uint8_t cmd )

Set Command function.

The function set desired command to the desired sensor type of MS8607 PHT ( Pressure, Humidity and Temperature ) Combination Sensor on the PHT click board.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
[in]sensor_type: Selection between temperature and pressure or humidity.
[in]cmd: Command byte to be written.
Returns
Nothing.

◆ pht_set_ratio()

uint8_t pht_set_ratio ( pht_t * ctx,
uint8_t temp_ratio,
uint8_t press_ratio )

Set Ratio function.

The function determines the oversampling ratio value for temperature and pressure measurements of MS8607 PHT ( Pressure, Humidity and Temperature ) Combination Sensor on the PHT click board.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
[in]temp_ratio: Determines the oversampling ratio for temperature measurement:
[in]press_ratio: Determines the oversampling ratio for pressure measurement:
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ pht_soft_reset()

void pht_soft_reset ( pht_t * ctx,
uint8_t sensor_type )

Soft Reset function.

The function is performed by a software reset of MS8607 PHT ( Pressure, Humidity and Temperature ) Combination Sensor on the PHT click board.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
[in]sensor_type: Selection between temperature and pressure or humidity.
Returns
Nothing.

◆ pht_write_user_register()

void pht_write_user_register ( pht_t * ctx,
uint8_t tx_data )

Write User Register function.

The function write the byte of the data to the user register of MS8607 PHT ( Pressure, Humidity and Temperature ) Combination Sensor on the PHT click board.

Parameters
[in]ctx: Click context object. See pht_t object definition for detailed explanation.
[in]tx_data: 8-bit data to be written to the user register;
Returns
Nothing.