TOP Contributors

  1. MIKROE (2751 codes)
  2. Alcides Ramos (372 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139060 times)
  2. FAT32 Library (71592 times)
  3. Network Ethernet Library (56989 times)
  4. USB Device Library (47330 times)
  5. Network WiFi Library (43006 times)
  6. FT800 Library (42297 times)
  7. GSM click (29777 times)
  8. mikroSDK (27874 times)
  9. PID Library (26858 times)
  10. microSD click (26129 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

Motion 2 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.11

mikroSDK Library: 2.0.0.0

Category: Motion

Downloaded: 97 times

Not followed.

License: MIT license  

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.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Motion 2 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Motion 2 Click" changes.

Do you want to report abuse regarding "Motion 2 Click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


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.

motion2_click.png

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 :

  • motion2_cfg_setup Config Object Initialization function.

    void motion2_cfg_setup ( motion2_cfg_t *cfg );
  • motion2_init Initialization function.

    motion2_return_value_t motion2_init ( motion2_t *ctx, motion2_cfg_t *cfg );

Example key functions :

  • motion2_enable Enable motion sensor function.

    void motion2_enable ( motion2_t *ctx, uint8_t state );
  • motion2_detect_state Get detection state function.

    uint8_t motion2_detect_state ( motion2_t *ctx );

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;  /**< Logger config object. */
    motion2_cfg_t motion2_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    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 ( ; ; );
    }

    motion2_enable( &motion2, MOTION2_MODULE_ENABLE );
    Delay_ms ( 100 );
    log_printf( &logger, "The sensor is ready.\r\n" );
    log_printf( &logger, "-----------------------\r\n" );
}

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 );
    }
}

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.


ALSO FROM THIS AUTHOR

DAC 18 Click

0

DAC 18 Click is a compact add-on board for converting general-purpose input to PWM signals. This board features the DAC539G2-Q1, a 10-bit smart DAC from Texas Instruments. The board offers two key output channels: one for digital-to-analog conversion (OUT1) and the other for voltage-to-PWM conversion (OUT0) supporting triangle or sawtooth waveforms. It features an operational mode selection pin for I2C programming or standalone operation, along with nonvolatile memory for storing register settings. DAC 18 Click is ideal for automotive lighting systems and industrial environments requiring reliable signal conversion.

[Learn More]

Balancer 2 Click

0

Balancer 2 Click is an overvoltage protection device for a 2-series cell lithium-ion battery. Click contains two separate overvoltage battery detection circuits and automatic cell imbalance correction.

[Learn More]

Thumbwheel click

15

Thumbwheel click is a mikroBUS add-on board with a 10-position rotary sprocket connected to a 1-Wire 8-Channel Addressable Switch.

[Learn More]