pH click
pH Click is a compact add-on board that provides an opportunity for the user to read pH with the same accuracy and capabilities as with some other expensive solutions. This board features the pH EZO™, a 6th generation embedded pH circuit that offers the highest level of stability and accuracy from AtlasScientific.
click Product page
Click library
- Author : Stefan Ilic
- Date : Oct 2021.
- Type : UART type
Software Support
We provide a library for the pH Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for pH Click driver.
Standard key functions :
ph_cfg_setup
Config Object Initialization function.
void ph_cfg_setup(ph_cfg_t *cfg)
pH configuration object setup function.
pH Click configuration object.
Definition ph.h:193
ph_init
Initialization function.
err_t ph_init(ph_t *ctx, ph_cfg_t *cfg)
pH initialization function.
pH Click context object.
Definition ph.h:178
ph_default_cfg
Click Default Configuration function.
err_t ph_default_cfg(ph_t *ctx)
pH default configuration function.
Example key functions :
ph_send_cmd
Send command function.
void ph_send_cmd(ph_t *ctx, char *p_cmd)
Send command function.
ph_get_cmd_resp
Send get response function.
void ph_get_cmd_resp(ph_t *ctx, char *p_cmd, char *p_resp)
Send get response function.
ph_switch_led
Toggle LED function.
void ph_switch_led(ph_t *ctx, uint8_t state, char *p_resp)
Toggle LED function.
Example Description
This example reads and processes data from pH clicks.
The demo application is composed of two sections :
Application Init
Initializes UART driver, performing a factory reset of the device, disabling continuous read, and performing calibration at the midpoint on the pH scale.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( UART_ERROR ==
ph_init( &ph, &ph_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
Delay_ms ( 1000 );
log_printf( &logger, "-----------------------\r\n" );
log_printf( &logger, " -- Initialized -- \r\n" );
log_printf( &logger, "-----------------------\r\n" );
log_printf( &logger, " Place probe into pH \r\n" );
log_printf( &logger, " neutral substance for \r\n" );
log_printf( &logger, " mid point calibration \r\n" );
log_printf( &logger, "-----------------------\r\n" );
for ( uint8_t n_cnt = 0; n_cnt < 20; n_cnt++ )
{
Delay_ms ( 1000 );
}
log_printf( &logger, " Starting calibration \r\n" );
log_printf( &logger, "-----------------------\r\n" );
Delay_ms ( 1000 );
log_printf( &logger, " Calibration done! \r\n" );
log_printf( &logger, "-----------------------\r\n" );
log_printf( &logger, " - Application task -\r\n" );
log_printf( &logger, "-----------------------\r\n" );
Delay_ms ( 1000 );
}
#define PH_CMD_DIS_RSP_CODES
Definition ph.h:103
#define PH_CMD_CALIB_MID
Definition ph.h:78
#define PH_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition ph.h:167
void ph_cont_read(ph_t *ctx, uint8_t time, char *p_resp)
Set Continous read function.
void ph_perf_calib(ph_t *ctx, char *point, float flt_val, char *p_resp)
Perform Calibration function.
void ph_factory_rst(ph_t *ctx, char *p_resp)
Perform Factory Reset function.
void ph_clr_log_buf(char *p_str)
Clear log buffer function.
void application_init(void)
Definition main.c:34
Application Task
This example shows the capabilities of the pH Click board by performing a reading of the pH value of the substance in which the probe is submerged and displaying readings via the USART terminal.
{
log_printf( &logger, " pH value: %s ", app_buf );
log_printf( &logger, "-----------------------\r\n" );
Delay_ms ( 1000 );
}
#define PH_CMD_SET_SNGL_READ
Definition ph.h:95
uint8_t ph_response(ph_t *ctx, char *p_resp)
pH Response handler function
void application_task(void)
Definition main.c:90
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.pH
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.