Smoke 2 click
Smoke 2 Click is a compact add-on board that contains the most efficient version of the smoke detector. This board features the ADPD188BI, a complete photometric system for smoke detection using optical dual-wavelength technology from Analog Devices.
click Product page
Click library
- Author : Jelena Milosavljevic
- Date : Jul 2021.
- Type : I2C/SPI type
Software Support
We provide a library for the Smoke2 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 Smoke2 Click driver.
Standard key functions :
smoke2_cfg_setup
Config Object Initialization function.
void smoke2_cfg_setup(smoke2_cfg_t *cfg)
Smoke 2 configuration object setup function.
Smoke 2 Click configuration object.
Definition smoke2.h:302
smoke2_init
Initialization function.
err_t smoke2_init(smoke2_t *ctx, smoke2_cfg_t *cfg)
Smoke 2 initialization function.
Smoke 2 Click context object.
Definition smoke2.h:278
smoke2_default_cfg
Click Default Configuration function.
void smoke2_default_cfg(smoke2_t *ctx)
Smoke 2 default configuration function.
Example key functions :
smoke2_get_int_pin
This function eget state of int pin of Smoke 2 click board.
uint8_t smoke2_get_int_pin(smoke2_t *ctx)
Smoke 2 get state of int pin function.
smoke2_write_data
This function is generic for writing data to register of Smoke 2 click board.
void smoke2_write_data(smoke2_t *ctx, uint8_t reg, uint16_t tx_data)
Smoke 2 generic function for writing data to register function.
smoke2_read_data
This function is generic for reading data from registar of Smoke 2 click board.
uint16_t smoke2_read_data(smoke2_t *ctx, uint8_t reg)
Smoke 2 generic function for reading data from registar.
Example Description
This example is made to see how Smoke 2 clicks work. The purpose of this example is that, depending on the way we choose,
it collects data from the external environment about smoke, processes it, and prints it via the UART terminal.
The demo application is composed of two sections :
Application Init
Initialization of communication modules, additional pins, Mapping pins and configures device for measurement.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_printf( &logger, ">> ID: 0x%.2X\r\n", ( uint16_t ) ( devid & 0xFF ) );
log_printf( &logger, ">> REV: 0x%.2X\r\n", ( uint16_t ) ( ( devid >> 8 ) & 0xFF ) );
Delay_ms ( 1000 );
log_printf( &logger, ">> Configuration <<\r\n" );
Delay_ms ( 1000 );
#if ( EXAMPLE_MODE == EXAMPLE_MODE_SMOKE )
log_printf( &logger, ">> SMOKE MODE <<\r\n" );
log_printf( &logger, ">> Calibration <<\r\n" );
log_printf( &logger, ">> Calibration data: %u\r\n", calib_data );
#elif ( EXAMPLE_MODE == EXAMPLE_MODE_PROXIMITY )
log_printf( &logger, ">> PROXIMITY MODE <<\r\n" );
#endif
log_info( &logger, " Application Task " );
}
#define SMOKE2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition smoke2.h:244
#define SMOKE2_REG_DEVID
Definition smoke2.h:80
#define SMOKE2_MODE_IDLE
Smoke 2 description setting to select mode.
Definition smoke2.h:192
void smoke2_soft_reset(smoke2_t *ctx)
Smoke 2 reseting device function.
void smoke2_set_mode(smoke2_t *ctx, uint8_t mode)
Smoke 2 setting mode function.
uint16_t smoke2_smoke_calibration(smoke2_t *ctx, uint16_t threshold)
Smoke 2 calibrating data and setting threshold function.
void application_init(void)
Definition main.c:52
Application Task
Example shows module working depending on example mode. We can choose between: EXAMPLE_MODE_PROXIMITY and EXAMPLE_MODE_SMOKE.
{
#if ( EXAMPLE_MODE == EXAMPLE_MODE_SMOKE )
#elif ( EXAMPLE_MODE == EXAMPLE_MODE_PROXIMITY )
#endif
}
void application_task(void)
Definition main.c:104
void proximity_example(void)
Smoke 2 Proximity example.
Definition main.c:153
void smoke_example(smoke2_t *ctx)
Smoke 2 Smoke example.
Definition main.c:130
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.Smoke2
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.