pir3 2.2.0
Loading...
Searching...
No Matches
pir3


PIR 3 Click

PIR 3 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Jun 2024.
  • Type : I2C type

Software Support

Example Description

This example demonstrates the use of PIR 3 Click board by reading and displaying the peak hold tracking data.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.PIR3

Example Key Functions

  • pir3_cfg_setup Config Object Initialization function.
    void pir3_cfg_setup ( pir3_cfg_t *cfg );
    void pir3_cfg_setup(pir3_cfg_t *cfg)
    PIR 3 configuration object setup function.
    PIR 3 Click configuration object.
    Definition pir3.h:161
  • pir3_init Initialization function.
    err_t pir3_init ( pir3_t *ctx, pir3_cfg_t *cfg );
    err_t pir3_init(pir3_t *ctx, pir3_cfg_t *cfg)
    PIR 3 initialization function.
    PIR 3 Click context object.
    Definition pir3.h:142
  • pir3_default_cfg Click Default Configuration function.
    err_t pir3_default_cfg ( pir3_t *ctx );
    err_t pir3_default_cfg(pir3_t *ctx)
    PIR 3 default configuration function.
  • pir3_set_detection_level This function sets the detection threshold level in the ctx->config structure.
    void pir3_set_detection_level ( pir3_t *ctx, uint8_t detlvl );
    void pir3_set_detection_level(pir3_t *ctx, uint8_t detlvl)
    PIR 3 set detection level function.
  • pir3_write_config This function writes a config structure to the sensor by using I2C serial interface.
    err_t pir3_write_config ( pir3_t *ctx );
    err_t pir3_write_config(pir3_t *ctx)
    PIR 3 write config function.
  • pir3_read_peak_hold This function reads a 12-bit signed peak hold data by using I2C serial interface.
    err_t pir3_read_peak_hold ( pir3_t *ctx, int16_t *peak_hold );
    err_t pir3_read_peak_hold(pir3_t *ctx, int16_t *peak_hold)
    PIR 3 read peak hold function.

Application Init

Initializes the driver and performs the Click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
pir3_cfg_t pir3_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
pir3_cfg_setup( &pir3_cfg );
PIR3_MAP_MIKROBUS( pir3_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == pir3_init( &pir3, &pir3_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( PIR3_ERROR == pir3_default_cfg ( &pir3 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define PIR3_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition pir3.h:116
void application_init(void)
Definition main.c:32
@ PIR3_ERROR
Definition pir3.h:179

Application Task

Reads the peak hold tracking data every 100ms and displays the results on the USB UART.

void application_task ( void )
{
int16_t peak_hold = 0;
if ( PIR3_OK == pir3_read_peak_hold ( &pir3, &peak_hold ) )
{
log_printf( &logger, " PEAK HOLD: %d\r\n\n", peak_hold );
Delay_ms ( 100 );
}
}
void application_task(void)
Definition main.c:68
@ PIR3_OK
Definition pir3.h:178

Note

In order to establish communication with the sensor, some of the supported MCUs may require the I2C lines to be pulled up additionally either with the external or internal weak pull-up resistor.

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.