Intermediate
30 min

Transform the way you perceive and interact with your surroundings using VL53L1 and PIC32MZ2048EFM100

The unseen connection: Enriching your everyday life

Proximity 15 Click with Curiosity PIC32 MZ EF

Published Oct 17, 2023

Click board™

Proximity 15 Click

Dev Board

Curiosity PIC32 MZ EF

Compiler

NECTO Studio

MCU

PIC32MZ2048EFM100

Our purpose is to empower individuals and industries with proximity technology that enhances convenience, safety, and efficiency

A

A

Hardware Overview

How does it work?

Proximity 15 Click is based on the VL53L1, a third-generation time-of-flight (ToF) laser-ranging sensor from STMicroelectronics. The VL53L1 brings multi-object detection and multi-array scanning, doubling the range of operation to above 4m. It also allows novel features such as multi-target detection and programmable multi-zone scanning, suitable for robotics, user detection, drones, IoT, and wearable applications. The sensor module integrates a VCSEL that emits at a wavelength of 940nm, a processor core, and a SPAD photon detector. The addition of the optical lens system increases the photon detection rate to

boost the module’s ranging performance. The VL53L1 performs an entire measurement operation in as little as 5ms, and for Auto-Focus applications, the sensor detects objects twice. Proximity 15 Click communicates with MCU using the standard I2C 2-Wire interface to read data and configure settings, supporting Fast Mode Plus Mode up to 1MHz. It also features an intelligent interrupt function that generates every time a ranging measurement is available. The interrupt is cleared once the host reads the result, and the ranging sequence can repeat. Besides the interrupt pin, the Xshutdown (reset) pin labeled as XSH and

routed to the CS pin of the mikroBUS™ socket optimizes power consumption used for power ON/OFF purposes. This option optimizes power consumption as the VL53L1 can be completely powered off when unused and then woken up through the host GPIO (using the XSH pin). This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.

Proximity 15 Click top side image
Proximity 15 Click bottom side image

Features overview

Development board

Curiosity PIC32 MZ EF development board is a fully integrated 32-bit development platform featuring the high-performance PIC32MZ EF Series (PIC32MZ2048EFM) that has a 2MB Flash, 512KB RAM, integrated FPU, Crypto accelerator, and excellent connectivity options. It includes an integrated programmer and debugger, requiring no additional hardware. Users can expand

functionality through MIKROE mikroBUS™ Click™ adapter boards, add Ethernet connectivity with the Microchip PHY daughter board, add WiFi connectivity capability using the Microchip expansions boards, and add audio input and output capability with Microchip audio daughter boards. These boards are fully integrated into PIC32’s powerful software framework, MPLAB Harmony,

which provides a flexible and modular interface to application development a rich set of inter-operable software stacks (TCP-IP, USB), and easy-to-use features. The Curiosity PIC32 MZ EF development board offers expansion capabilities making it an excellent choice for a rapid prototyping board in Connectivity, IOT, and general-purpose applications.

Curiosity PIC32MZ EF double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
Shutdown
RPD4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
RF13
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RPA14
SCL
I2C Data
RPA15
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Proximity 15 Click Schematic schematic

Step by step

Project assembly

Curiosity PIC32MZ EF front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity PIC32 MZ EF as your development board.

Curiosity PIC32MZ EF front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
Curiosity PIC32 MZ EF MB 1 Access - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Curiosity PIC32 MZ EF MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

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.

Software Support

Library Description

This library contains API for Proximity 15 Click driver.

Key functions:

  • proximity15_get_distance - This function waits for the data ready, then reads the distance measured by the sensor in milimeters and clears interrupts.

  • proximity15_set_inter_measurement_period - This function programs the inter measurement period in miliseconds.

  • proximity15_set_timing_budget - This function programs the timing budget in miliseconds.

Open Source

Code example

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.

/*!
 * @file main.c
 * @brief Proximity15 Click example
 *
 * # Description
 * This example demonstrates the use of Proximity 15 click board.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration which 
 * enables the sensor and sets it to long distance mode with 50ms timing budget and 100ms
 * inter measurement periods.
 *
 * ## Application Task
 * Reads the distance measured by the sensor in milimeters and displays the 
 * value on the USB UART approximately every 100ms.
 * 
 * @note 
 * In order to measure longer distance, increase the timing budget and inter measurement periods.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "proximity15.h"

static proximity15_t proximity15;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;                  /**< Logger config object. */
    proximity15_cfg_t proximity15_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.
    proximity15_cfg_setup( &proximity15_cfg );
    PROXIMITY15_MAP_MIKROBUS( proximity15_cfg, MIKROBUS_1 );
    err_t init_flag = proximity15_init( &proximity15, &proximity15_cfg );
    if ( I2C_MASTER_ERROR == init_flag ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );
        for ( ; ; );
    }

    init_flag = proximity15_default_cfg ( &proximity15 );
    if ( PROXIMITY15_ERROR == init_flag ) 
    {
        log_error( &logger, " Default Config Error. " );
        log_info( &logger, " Please, run program again... " );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    uint16_t distance = 0;
    
    if ( PROXIMITY15_OK == proximity15_get_distance ( &proximity15, &distance ) )
    {
        log_printf( &logger, " Distance(mm): %u\r\n\n", distance );
    }
}

void main ( void ) 
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.