tfmini  2.0.0.0
Main Page

TFmini click

TFmini Click is an adapter Click boardâ„¢ used to interface a compatible ToF (Time of Flight) LiDAR sensor with the host MCU. This board features one four positions 1.25mm connector suitable for a TFmini LiDAR module (TFmini Plus and TFmini-S) specially made to measure an object's distance. Depending on the used LiDAR module, it is possible to achieve different measurement ranges and the use of a different serial interface, such as the UART or I2C. This Click boardâ„¢ is suitable for various industrial environments like pedestrian detection, vehicle testing, and altitude.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Nov 2021.
  • Type : UART type

Software Support

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

Standard key functions :

Example key functions :

  • tfmini_get_firmware_version This function reads the sensor firmware version.
    err_t tfmini_get_firmware_version ( tfmini_t *ctx, uint32_t *fw_version );
  • tfmini_get_measurement This function reads the output data frame and obtains the distance, strength and temperature values from it.
    err_t tfmini_get_measurement ( tfmini_t *ctx, int16_t *distance, int16_t *strength, float *temperature );
  • tfmini_send_frame This function sends a command frame to the sensor.

Example Description

This example demonstrates the use of TFmini click board by reading the measurements from the attached TFmini-S or TFmini Plus sensors.

The demo application is composed of two sections :

Application Init

Initializes the driver and the click board, and reads the firmware version of the attached sensor.

void application_init ( void )
{
log_cfg_t log_cfg;
tfmini_cfg_t tfmini_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
tfmini_cfg_setup( &tfmini_cfg );
TFMINI_MAP_MIKROBUS( tfmini_cfg, MIKROBUS_1 );
if ( TFMINI_OK != tfmini_init( &tfmini, &tfmini_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( TFMINI_OK != tfmini_default_cfg ( &tfmini ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
uint32_t fw_version = 0;
if ( TFMINI_OK == tfmini_get_firmware_version ( &tfmini, &fw_version ) )
{
log_printf( &logger, " FW Version: 0x%.6LX\r\n", fw_version );
}
Delay_ms( 1000 );
log_info( &logger, " Application Task " );
}

Application Task

Reads the target distance, signal strength and the internal sensor temperature every 100ms approximately, and displays the results on the USB UART.

void application_task ( void )
{
int16_t distance = 0, strength = 0;
float temperature = 0;
if ( TFMINI_OK == tfmini_get_measurement ( &tfmini, &distance, &strength, &temperature ) )
{
log_printf( &logger, " Target distance: %d cm\r\n", distance );
log_printf( &logger, " Signal strength: %d\r\n", strength );
log_printf( &logger, " Sensor temperature: %.2f C\r\n\n", temperature );
}
}

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

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.


tfmini_drv_interface_selection
void tfmini_drv_interface_selection(tfmini_cfg_t *cfg, tfmini_drv_t drv_sel)
TFmini driver interface setup function.
tfmini_init
err_t tfmini_init(tfmini_t *ctx, tfmini_cfg_t *cfg)
TFmini initialization function.
tfmini_frame_t
TFmini Click command frame definition structure.
Definition: tfmini.h:153
TFMINI_DRV_SEL_UART
@ TFMINI_DRV_SEL_UART
Definition: tfmini.h:143
tfmini_cfg_setup
void tfmini_cfg_setup(tfmini_cfg_t *cfg)
TFmini configuration object setup function.
application_task
void application_task(void)
Definition: main.c:73
tfmini_default_cfg
err_t tfmini_default_cfg(tfmini_t *ctx)
TFmini default configuration function.
TFMINI_OK
@ TFMINI_OK
Definition: tfmini.h:210
tfmini_send_frame
err_t tfmini_send_frame(tfmini_t *ctx, tfmini_frame_t frame)
TFmini send frame function.
tfmini_get_firmware_version
err_t tfmini_get_firmware_version(tfmini_t *ctx, uint32_t *fw_version)
TFmini get firmware version function.
tfmini_cfg_t
TFmini Click configuration object.
Definition: tfmini.h:184
application_init
void application_init(void)
Definition: main.c:29
tfmini_get_measurement
err_t tfmini_get_measurement(tfmini_t *ctx, int16_t *distance, int16_t *strength, float *temperature)
TFmini get measurement function.
TFMINI_MAP_MIKROBUS
#define TFMINI_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: tfmini.h:128
tfmini_t
TFmini Click context object.
Definition: tfmini.h:165