ph2 2.1.0.0
pH 2 Click Driver

API for configuring and manipulating pH 2 Click driver. More...

Topics

 pH 2 Commands List
 List of commands of pH 2 Click driver.
 
 pH 2 Registers Settings
 Settings for registers of pH 2 Click driver.
 
 pH 2 MikroBUS Map
 MikroBUS pin mapping of pH 2 Click driver.
 

Functions

void ph2_cfg_setup (ph2_cfg_t *cfg)
 pH 2 configuration object setup function.
 
void ph2_drv_interface_selection (ph2_cfg_t *cfg, ph2_drv_t drv_sel)
 pH 2 driver interface setup function.
 
err_t ph2_init (ph2_t *ctx, ph2_cfg_t *cfg)
 pH 2 initialization function.
 
err_t ph2_read_raw_adc (ph2_t *ctx, uint16_t *raw_adc)
 pH 2 read raw ADC value function.
 
err_t ph2_read_voltage (ph2_t *ctx, float *voltage)
 pH 2 read voltage level function.
 
err_t ph2_set_vref (ph2_t *ctx, float vref)
 pH 2 set vref function.
 
err_t ph2_calibrate (ph2_t *ctx, float pH_value)
 Ph 2 calibrate function.
 
err_t ph2_calculate_ph (ph2_t *ctx, float *pH_value)
 Ph 2 calculate pH value function.
 
void ph2_calibrate_offset (ph2_t *ctx)
 Ph 2 calibrate offset function.
 
void ph2_enable_st1 (ph2_t *ctx)
 Ph 2 enable LED STAT1 function.
 
void ph2_disable_st1 (ph2_t *ctx)
 Ph 2 disable LED STAT1 function.
 
void ph2_enable_st2 (ph2_t *ctx)
 Ph 2 enable LED STAT2 function.
 
void ph2_disable_st2 (ph2_t *ctx)
 Ph 2 disable LED STAT2 function.
 
err_t ph2_ds18b20_init (ph2_t *ctx, ph2_cfg_t *cfg)
 pH 2 DS18B20 initialization function.
 
err_t ph2_ds18b20_check_communication (ph2_t *ctx)
 pH 2 DS18B20 check communication function.
 
err_t ph2_ds18b20_select_device (ph2_t *ctx)
 pH 2 DS18B20 select device function.
 
err_t ph2_ds18b20_read_scratchpad (ph2_t *ctx, uint8_t *scratchpad)
 pH 2 DS18B20 read scratchpad function.
 
err_t ph2_ds18b20_write_scratchpad (ph2_t *ctx, uint8_t temp_high, uint8_t temp_low, uint8_t config)
 pH 2 DS18B20 write scratchpad function.
 
err_t ph2_ds18b20_default_cfg (ph2_t *ctx)
 pH 2 DS18B20 default configuration function.
 
err_t ph2_ds18b20_start_measurement (ph2_t *ctx)
 pH 2 DS18B20 start measurement function.
 
err_t ph2_ds18b20_read_temperature (ph2_t *ctx, float *temperature)
 pH 2 DS18B20 read temperature function.
 

Detailed Description

API for configuring and manipulating pH 2 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

◆ ph2_calculate_ph()

err_t ph2_calculate_ph ( ph2_t * ctx,
float * pH_value )

Ph 2 calculate pH value function.

This function is reading pH value wof substance where pH probe is placed.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
[out]pH_value: pH value of the substance.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function calculates the pH value with the assumption that the temperature of the substance is 25 deg Celsius.

◆ ph2_calibrate()

err_t ph2_calibrate ( ph2_t * ctx,
float pH_value )

Ph 2 calibrate function.

This function is performing calibration of Ph 2 click driver with known pH value substance.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
[out]pH_value: pH value of the substance where calibration is performed.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ph2_calibrate_offset()

void ph2_calibrate_offset ( ph2_t * ctx)

Ph 2 calibrate offset function.

This function is used to calibrate offset of Ph 2 click driver.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
Returns
Nothing.
Note
Disconnect the probe and short-circuit the BNC connector in order to set the reference voltage. Adjust the potentiometer until the LEDs stop blinking or until the voltage of the OUT pin is exactly at half the value of the selected VCC voltage. If you are using LEDs for calibration, turn the potentiometer clockwise when STAT1 LED is blinking and counter-clockwise when STAT2 LED is blinking.

◆ ph2_cfg_setup()

void ph2_cfg_setup ( ph2_cfg_t * cfg)

pH 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ ph2_disable_st1()

void ph2_disable_st1 ( ph2_t * ctx)

Ph 2 disable LED STAT1 function.

This function is used turn off STAT1 LED of Ph 2 click driver.

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

◆ ph2_disable_st2()

void ph2_disable_st2 ( ph2_t * ctx)

Ph 2 disable LED STAT2 function.

This function is used turn off STAT2 LED of Ph 2 click driver.

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

◆ ph2_drv_interface_selection()

void ph2_drv_interface_selection ( ph2_cfg_t * cfg,
ph2_drv_t drv_sel )

pH 2 driver interface setup function.

This function sets a serial driver interface which will be used further in the click driver.

Parameters
[out]cfg: Click configuration structure. See ph2_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See ph2_drv_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be call before init function to configure the driver to work with the serial interface which is consistent with the real state of the hardware. If this function is not called, the default driver interface will be set.

◆ ph2_ds18b20_check_communication()

err_t ph2_ds18b20_check_communication ( ph2_t * ctx)

pH 2 DS18B20 check communication function.

This function checks the communication by reading the ROM address as well as verifying family code and Maxim CRC 8.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ph2_ds18b20_default_cfg()

err_t ph2_ds18b20_default_cfg ( ph2_t * ctx)

pH 2 DS18B20 default configuration function.

This function executes a default configuration of pH 2 DS18B20 sensor.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ ph2_ds18b20_init()

err_t ph2_ds18b20_init ( ph2_t * ctx,
ph2_cfg_t * cfg )

pH 2 DS18B20 initialization function.

This function initializes all necessary pins and peripherals used for DS18B20 sensor.

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

◆ ph2_ds18b20_read_scratchpad()

err_t ph2_ds18b20_read_scratchpad ( ph2_t * ctx,
uint8_t * scratchpad )

pH 2 DS18B20 read scratchpad function.

This function reads a desired number of scratchpad bytes using One Wire communication protocol.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
[out]scratchpad: Output read scratchpad.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ph2_ds18b20_read_temperature()

err_t ph2_ds18b20_read_temperature ( ph2_t * ctx,
float * temperature )

pH 2 DS18B20 read temperature function.

This function reads the temperature value in Celsius.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
[out]temperature: Temperature in Celsius.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ph2_ds18b20_select_device()

err_t ph2_ds18b20_select_device ( ph2_t * ctx)

pH 2 DS18B20 select device function.

This function selects the device by performing a skip or match ROM commands depending on the address value set in the ctx->address.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ph2_ds18b20_start_measurement()

err_t ph2_ds18b20_start_measurement ( ph2_t * ctx)

pH 2 DS18B20 start measurement function.

This function starts the measurement by sending an appropriate command for that.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ph2_ds18b20_write_scratchpad()

err_t ph2_ds18b20_write_scratchpad ( ph2_t * ctx,
uint8_t temp_high,
uint8_t temp_low,
uint8_t config )

pH 2 DS18B20 write scratchpad function.

This function writes the temperature thresholds and configuration byte to the scratchpad.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
[in]temp_high: Temperature high limit.
[in]temp_low: Temperature low limit.
[in]config: Configuration byte.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ph2_enable_st1()

void ph2_enable_st1 ( ph2_t * ctx)

Ph 2 enable LED STAT1 function.

This function is used turn on STAT1 LED of Ph 2 click driver.

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

◆ ph2_enable_st2()

void ph2_enable_st2 ( ph2_t * ctx)

Ph 2 enable LED STAT2 function.

This function is used turn on STAT2 LED of Ph 2 click driver.

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

◆ ph2_init()

err_t ph2_init ( ph2_t * ctx,
ph2_cfg_t * cfg )

pH 2 initialization function.

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

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

◆ ph2_read_raw_adc()

err_t ph2_read_raw_adc ( ph2_t * ctx,
uint16_t * raw_adc )

pH 2 read raw ADC value function.

This function reads raw ADC value.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
[out]raw_adc: Output ADC result.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ph2_read_voltage()

err_t ph2_read_voltage ( ph2_t * ctx,
float * voltage )

pH 2 read voltage level function.

This function reads raw ADC value and converts it to proportional voltage level.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
[out]voltage: Output voltage level [V].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
The conversion to voltage depends on the entered reference voltage.

◆ ph2_set_vref()

err_t ph2_set_vref ( ph2_t * ctx,
float vref )

pH 2 set vref function.

This function sets the voltage reference for pH 2 click driver.

Parameters
[in]ctx: Click context object. See ph2_t object definition for detailed explanation.
[in]vref: Reference voltage (volts).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
The default voltage reference set with ph2_init is 3.3V.