presence  2.0.0.0
Main Page

Presence click

Presence click is an infrared sensing Click boardâ„¢ which can be used for presence sensing, motion detection, and a remote overtemperature protection.

click Product page


Click library

Software Support

We provide a library for the Presence 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 Presence Click driver.

Standard key functions :

Example key functions :

Examples Description

This application enables usage of sensor for motion and presence sensing and measuring of object's and ambient temperature.

The demo application is composed of two sections :

Application Init

Initializes driver init, start eeprom process and configuration chip for measurement.

void application_init ( void )
{
log_cfg_t log_cfg;
uint8_t tmp;
uint8_t w_temp;
// Logger initialization.
log_cfg.level = LOG_LEVEL_DEBUG;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
PRESENCE_MAP_MIKROBUS( cfg, MIKROBUS_1 );
presence_init( &presence, &cfg );
// General call address
Delay_1sec( );
// EEPROM
tmp = presence_eeprom_process( &presence );
if ( tmp == 0 )
{
log_printf( &logger, "----- EEPROM READ OK! ------\r\n" );
}
else
{
log_printf( &logger, "---- EEPROM READ ERROR! ----\r\n" );
log_printf( &logger, "----------------------------\r\n" );
while ( 1 );
}
Delay_ms( 2000 );
w_temp = 0x22;
w_temp = 0x0A;
w_temp = 0x00;
log_printf( &logger, "-------- INIT DONE ---------\r\n" );
log_printf( &logger, "----------------------------\r\n" );
Delay_ms( 3000 );
}

Application Task

Check whether a new event (Motion, Presence or Temp threshold exceeded) is detected.

void application_task ( void )
{
// Task implementation.
uint8_t int_status;
float tamb;
float tobj;
tamb = presence_ambient_temperature( &presence );
log_printf( &logger, "---- Ambient Temperature: %.2f\r\n", tamb );
Delay_ms( 100 );
tobj = presence_object_temperature( &presence );
log_printf( &logger, "---- Object Temperature: %.2f\r\n", tobj );
Delay_ms( 800 );
if ( ( int_status & 0x08 ) != 0 )
{
log_printf( &logger, "--- Presence detected! ---\r\n" );
}
else if ( ( int_status & 0x04 ) != 0 )
{
log_printf( &logger, "--- Motion detected! ---\r\n" );
}
else if ( ( int_status & 0x10 ) != 0 )
{
log_printf( &logger, "--- Temp threshold exceeded! ---\r\n" );
}

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:

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.