Intermediate
30 min

Monitor smoke levels and conditions remotely using the MAX30105 and PIC32MZ1024EFH064

Clearing the air: The future of smoke detection and prevention

Smoke Click with PIC32MZ clicker

Published Sep 19, 2023

Click board™

Smoke Click

Dev. board

PIC32MZ clicker

Compiler

NECTO Studio

MCU

PIC32MZ1024EFH064

Discover how our advanced smoke detection solution enhances your ability to prevent and mitigate fire risks, creating safer environments for everyone

A

A

Hardware Overview

How does it work?

Smoke Click is based on the MAX30105, a high-sensitivity optical sensor for smoke detection applications from Analog Devices. The sensor is an integrated particle-sensing module with internal LEDs, photodetectors, optical elements, and low-noise electronics with ambient light rejection. To detect the smoke, the MAX30105 senses the light of LEDs that are rejected from the smoke particles by the photodetectors. The particle-sensing subsystem contains ambient light cancellation (ALC), a continuous-time sigma-delta 18-bit ADC, and a proprietary discrete time filter. The ALC has an internal track/hold circuit to cancel ambient light and increase dynamic range. The ADC output data rate can be programmed from 50sps to 3200sps. The MAX30105 integrates red, green, and IR LED drivers to modulate LED pulses for

particle-sensing measurements. The LED current can be programmed from 0 up to 50mA. The onboard temperature sensor is used for calibrating the temperature dependence of the particle-sensing subsystem. This temperature sensor has an inherent resolution of 0.0625°C. After the particle-sensing initiation, the IR LED is activated in proximity mode; when an object is detected, it goes automatically to the normal mode. The proximity mode can be re-entered. Smoke Click uses a standard 2-Wire I2C interface to communicate with the host MCU, supporting the clock data rates up to 400KHz. The sensor uses 1.8V for a power supply, which on this Click board™ is available over the SPX3819MS, a 500mA low-noise LDO voltage regulator from MaxLinear. For this sensor to work with higher logic levels,

Smoke Click features the PCA9306, a dual bidirectional I2C bus, and an SMBus voltage-level translator from Texas Instruments. One of the available interrupt statuses can be received over the INT pin and the SN74LVC1T45, a single-bit dual-supply bus transceiver with configurable voltage translation and 3-state outputs from Texas Instruments. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the PWR SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

Smoke Click top side image
Smoke Click bottom side image

Features overview

Development board

PIC32MZ Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32MZ microcontroller with FPU from Microchip, a USB connector, LED indicators, buttons, a mikroProg connector, and a header for interfacing with external electronics. Thanks to its compact design with clear and easy-recognizable silkscreen markings, it provides a fluid and immersive working experience, allowing access anywhere and under

any circumstances. Each part of the PIC32MZ Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the PIC32MZ Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for PIC, dsPIC, or PIC32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Micro-B connection can provide up to 500mA of current, which is more than enough to operate all onboard

and additional modules. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. PIC32MZ Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

PIC32MZ clicker double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

1024

Silicon Vendor

Microchip

Pin count

64

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
RB5
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RD10
SCL
I2C Data
RD9
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Smoke Click Schematic schematic

Step by step

Project assembly

PIC32MZ clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the PIC32MZ clicker as your development board.

PIC32MZ clicker front image hardware assembly
Thermo 26 Click front image hardware assembly
Prog-cut hardware assembly
Micro B Connector clicker - 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
Flip&Click PIC32MZ 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

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for Smoke Click driver.

Key functions:

  • smoke_set_registers - Set registers values function

  • smoke_enable_disable_interrupts - Enable or disable interrupt function

  • smoke_read_leds - Function for reading enabled led values

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 
 * \brief Smoke Click example
 * 
 * # Description
 * This click includes internal LEDs, photodetectors, optical elements, and low-noise electronics 
 * with ambient light rejection. The sensor can detect a wide variety of smoke particle sizes. 
 * It also has an on-chip temperature sensor for calibrating the temperature dependence of the 
 * particle sensing subsystem. The temperature sensor has an inherent resolution 0.0625°C.
 *
 * 
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initalizes I2C driver, applies "set registers check green values" settings, 
 * "enable FIFO data ready interrupt" and makes an initial log.
 * 
 * ## Application Task  
 * This example demonstrates the use of Smoke Click board. It reads reflected green values and
 * temperature from an internal sensor and displays the results on USART terminal.
 * It usualy takes two or three readings in order to get corect readings. Expect big values when you do.
 * 
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "smoke.h"

// ------------------------------------------------------------------ VARIABLES

static smoke_t smoke;
static log_t logger;

static float temperature;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    smoke_cfg_t cfg;

    /** 
     * 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.

    smoke_cfg_setup( &cfg );
    SMOKE_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    smoke_init( &smoke, &cfg );

    smoke_reset( &smoke );
    smoke_default_cfg ( &smoke );

    log_info( &logger, "---- Application Task ----" );
    Delay_ms( 100 );
    if ( smoke_read_leds( &smoke ) != SMOKE_OK )
    {
        log_info( &logger, "---- Init Error ----" );
        for( ; ; );
    }
}

void application_task ( void )
{
    smoke_read_leds( &smoke );
    
    log_printf( &logger, "Red : %llu\r\n", smoke.red_value );
    log_printf( &logger, "IR : %llu\r\n", smoke.ir_value );
    log_printf( &logger, "Green : %llu\r\n", smoke.green_value );
    log_printf( &logger, "------------------------------\r\n" );
    
    temperature = smoke_read_temp( &smoke );
    
    log_printf( &logger, "Read Temperature[ degC ]: %.2f\r\n",  temperature );
    log_printf( &logger, "------------------------------\r\n" );

    Delay_ms( 1000 );
}

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.