alcohol2 2.0.0.0
Main Page

Alcohol 2 click

Alcohol 2 click is a very accurate ethanol gas (alcohol) sensor Click boardâ„¢, equipped with the SPEC amperometric gas sensor which electrochemically reacts with the ethanol.

click Product page


Click library

  • Author : MikroE Team
  • Date : Dec 2019.
  • Type : I2C type

Software Support

We provide a library for the Alcohol2 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

‍This library contains API for Alcohol2 Click driver.

Standard key functions :

  • Config Object Initialization function.

    ‍void alcohol2_cfg_setup ( alcohol2_cfg_t *cfg );

    - Initialization function.

    ‍ALCOHOL2_RETVAL alcohol2_init ( alcohol2_t *ctx, alcohol2_cfg_t *cfg );

  • Click Default Configuration function.

    ‍void alcohol2_default_cfg ( alcohol2_t *ctx );

Example key functions :

  • This function writes one byte to the register.

    ‍void alcohol2_write_byte ( alcohol2_t *ctx, uint8_t reg, uint8_t w_data );

    - This function reads one byte from the register.

    ‍uint8_t alcohol2_read_byte ( alcohol2_t *ctx, uint8_t reg );

  • This function reads Alcohol data.

    ‍uint16_t alcohol2_read_alcohol ( alcohol2_t *ctx );

    Examples Description

‍The demo application gets Alcohol data and logs data to USBUART.

The demo application is composed of two sections :

Application Init

‍Initializes device configuration.

oid application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----\r\n" );
// Click initialization.
ALCOHOL2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
alcohol2_init( &alcohol2, &cfg );
log_printf( &logger, "Alcohol 2 is initialized\r\n");
Delay_ms ( 300 );
}
#define ALCOHOL2_MAP_MIKROBUS(cfg, mikrobus)
Definition alcohol2.h:66
#define ALCOHOL2_DEEP_SLEEP_MODE
Definition alcohol2.h:154
#define ALCOHOL2_WRITE_MODE
Definition alcohol2.h:98
#define ALCOHOL2_EXT_TIA_RES
Definition alcohol2.h:106
#define ALCOHOL2_100_OHM_LOAD_RES
Definition alcohol2.h:117
#define ALCOHOL2_BIAS_POL_NEGATIVE
Definition alcohol2.h:130
#define ALCOHOL2_0_PERCENTS_BIAS
Definition alcohol2.h:132
#define ALCOHOL2_50_PERCENTS_INT_ZERO
Definition alcohol2.h:127
#define ALCOHOL2_VREF_INT
Definition alcohol2.h:124
ALCOHOL2_RETVAL alcohol2_init(alcohol2_t *ctx, alcohol2_cfg_t *cfg)
Initialization function.
void alcohol2_write_byte(alcohol2_t *ctx, uint8_t reg, uint8_t w_data)
Function writes one byte to the register.
#define ALCOHOL2_MODECN_REG
Definition alcohol2.h:91
#define ALCOHOL2_TIACN_REG
Definition alcohol2.h:89
#define ALCOHOL2_LOCK_REG
Definition alcohol2.h:88
#define ALCOHOL2_REFCN_REG
Definition alcohol2.h:90
void application_init(void)
Definition main.c:34
Click configuration structure definition.
Definition alcohol2.h:212

Application Task

‍Gets Alcohol (C2H5OH) data and logs data to USBUART every 500ms.

void application_task ( void )
{
alcohol_value = alcohol2_read_alcohol( &alcohol2 );
log_printf( &logger, "Alcohol value : %f \r\n",alcohol_value );
Delay_ms ( 500 );
}
uint16_t alcohol2_read_alcohol(alcohol2_t *ctx)
Function for read Alcohol data.
void application_task(void)
Definition main.c:67

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Alcohol2

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. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.