motion2 2.0.0.0
Main Page

Motion 2 click

Motion 2 Click is a Click board™ based on EKMC1607112, PIR motion sensor from Panasonic Corporation that's used as human motion detector. Also featured on Motion 2 Click bord is TLP241A photorelay from Toshiba that is used to provide a reinforced galvanic isolation for the external signals used to drive some external high power electronic equipment when motion is detected. It's allowing up to 40V between the SSR contacts in OFF state, and currents up to 2A while in ON state, thanks to a very low ON-state resistance. Motion 2 Click board™ is supported by a mikroSDK compliant library, which includes functions that simplify software development. This Click board™ comes as a fully tested product, ready to be used on a system equipped with the mikroBUS™ socket.

click Product page


Click library

  • Author : Jelena Milosavljevic
  • Date : Jun 2021.
  • Type : GPIO type

Software Support

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

Standard key functions :

Example key functions :

Example Description

‍This example demonstrates the use of Motion 2 click boards.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and enables the motion sensor.

void application_init ( void ) {
log_cfg_t log_cfg;
motion2_cfg_t motion2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
motion2_cfg_setup( &motion2_cfg );
MOTION2_MAP_MIKROBUS( motion2_cfg, MIKROBUS_1 );
if ( motion2_init( &motion2, &motion2_cfg ) == DIGITAL_OUT_UNSUPPORTED_PIN ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
Delay_ms ( 100 );
log_printf( &logger, "The sensor is ready.\r\n" );
log_printf( &logger, "-----------------------\r\n" );
}
#define MOTION2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition motion2.h:93
#define MOTION2_MODULE_ENABLE
MikroBUS pin set.
Definition motion2.h:72
void application_init(void)
Definition main.c:36

Application Task

‍It checks if the sensor has detected movement and therefore displays the desired message on the USB UART.

void application_task ( void ) {
uint8_t int_status;
int_status = motion2_detect_state( &motion2 );
if ( int_status == MOTION2_DETECT_OBJECT ) {
log_printf( &logger, "Motion detected!\r\n" );
log_printf( &logger, "-----------------------\r\n" );
while ( int_status == MOTION2_DETECT_OBJECT ) {
int_status = motion2_detect_state( &motion2 );
}
log_printf( &logger, "The sensor is ready.\r\n" );
log_printf( &logger, "-----------------------\r\n" );
Delay_ms ( 100 );
}
}
#define MOTION2_DETECT_OBJECT
Definition motion2.h:75
void application_task(void)
Definition main.c:72

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.Motion2

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.