Intermediate
30 min

Breathe easier with PIC24FJ1024GB610

Say goodbye to air pollution

Air quality 3 Click with Clicker 2 for PIC24

Published Aug 29, 2023

Click board™

Air quality 3 Click

Dev Board

Clicker 2 for PIC24

Compiler

NECTO Studio

MCU

PIC24FJ1024GB610

Our cutting-edge air quality monitor is vital in urban planning, equipping city officials with essential data to shape policies that prioritize citizen well-being

A

A

Hardware Overview

How does it work?

Air Quality 3 Click is based on the CCS811, an advanced ultra-low power digital gas sensor for monitoring indoor air quality (IAQ) from ScioSense. This IC consists of an analog section consisting of a MOX gas sensor based on ScioSense unique micro-hotplate technology, which allows high reliability, fast cycle times, and low power consumption, and the digital section, which consists of an embedded microcontroller (MCU) and an analog to digital converter (ADC). The CCS811 sensor IC employs advanced algorithms to calculate the raw sensor data and output the equivalent CO2 and TVOC values. It utilizes the internal MCU for this purpose, reducing the payload on the host MCU. Because of the nature of the MOX sensors, the CCS811 sensitivity will change over time, especially in early-life use. The internal sensor resistance will change the most for the first 48 hours of operation. So, to achieve proper operation of this sensor, it has to be calibrated during several different phases of its lifecycle. Since this step is important for achieving accurate IAQ results, it is strongly advised to be

carefully studied from the CCS811 datasheet. The Click board™ communicates with the host MCU via the I2C bus. SCL and SDA pins of the CCS811 IC are routed to the corresponding mikroBUS™ pins, allowing an easy and secure connection with the development system. Yet another pin is used with the I2C communication that is not part of the standard I2C bus: the #WAKE pin has to be set to a LOW logic level before the communication is attempted. This pin is routed to the CS pin of the mikroBUS™. The I2C bus lines are equipped with pull-up resistors, so communication can be established as soon as the click board is installed on the mikroBUS™. The least significant bit of the I2C address is routed to the external pin of the CCS811 IC, and it can be set to either a HIGH or a LOW logic level. This can be done by an onboard SMD jumper labeled as ADDR. It is useful when multiple devices are used on the same I2C bus. The #RESET pin is used to reset the device and must be pulled to a LOW logic level for at least 20μs. It is pulled to a HIGH logic level by the onboard resistor and filtered by a capacitor

to prevent random reset of the device. The #RESET of the CCS811 sensor IC is routed to the mikroBUS RST pin. The #INT pin allows another powerful Air Quality 3 Click feature to be used - a programmable interrupt request. This pin can be driven to a LOW state when data is ready to be read via the I2C. It can also be programmed to be driven when the eCO2 measurement data exceeds the programmed threshold by the hysteresis value. This can be extremely useful for making an early CO2 warning system. Interrupts, in general, are useful to avoid constant polling by the MCU, saving resources and energy that way. The #INT of the CCS811 sensor IC is routed to the mikroBUS INT 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.

Air quality 3 Click top side image
Air quality 3 Click bottom side image

Features overview

Development board

Clicker 2 for PIC24 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 16-bit PIC microcontroller, the PIC24FJ1024GB610 from Microchip, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a mikroProg programmer connector, and two 26-pin headers for interfacing with external electronics. Its compact design with clear and easily recognizable silkscreen markings allows you to build gadgets with unique

functionalities and features quickly. Each part of the Clicker 2 for PIC24 development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the Clicker 2 for PIC24 programming method, using a USB HID mikroBootloader or an external mikroProg connector for PIC24 programmer, the Clicker 2 board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Micro-B cable, where onboard voltage regulators provide the appropriate voltage levels to each

component on the board, or using a Li-Polymer battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several user-configurable buttons and LED indicators. Clicker 2 for PIC24 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.

Clicker 2 for PIC24 dimensions image

Microcontroller Overview

MCU Card / MCU

default

Architecture

dsPIC

MCU Memory (KB)

1024

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

32768

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
RE3
RST
Wake up
RE4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
RC1
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RE6
SCL
I2C Data
RE7
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Air quality 3 Click Schematic schematic

Step by step

Project assembly

Clicker 2 for PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Clicker 2 for PIC24 as your development board.

Clicker 2 for PIC32MZ front image hardware assembly
Buck 22 Click front image hardware assembly
Prog-cut hardware assembly
Micro B Connector Clicker 2 - 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

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for Air Quality 3 Click driver.

Key functions:

  • airquality3_get_co2_and_tvoc - Get CO2 and TVOC data

  • airquality3_set_environment_data - Temperature and humidity data settings

  • airquality3_set_measurement_mode - Function for settings sensor drive mode and interrupts.

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * \file 
 * \brief AirQuality3 Click example
 * 
 * # Description
 * The demo application shows air quality measurement.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Configuring clicks and log objects.
 * Settings the click in the default configuration.
 * Call the procedure the wakeup function of the chip.
 * 
 * ## Application Task  
 * Reads CO2 and TVOC value in the air and logs this data on the USBUART.
 * 
 * \author Katarina Perendic
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "airquality3.h"

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

static airquality3_t airquality3;
static log_t logger;

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

void application_init ( void )
{
    log_cfg_t log_cfg;
    airquality3_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.

    airquality3_cfg_setup( &cfg );
    AIRQUALITY3_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    airquality3_init( &airquality3, &cfg );

    // Wake-up click procedure

    airquality3_set_power( &airquality3, AIRQUALITY3_POWER_STATE_ON );
    airquality3_hardware_reset( &airquality3 );
    airquality3_app_function( &airquality3, AIRQUALITY3_APP_START );

    airquality3_default_cfg( &airquality3 );

    Delay_ms( 500 );
    log_info( &logger, "---- Start measurement ----" );
}

void application_task ( void )
{
    airquality3_air_data_t air_data;

    //  Task implementation.

    airquality3_get_co2_and_tvoc ( &airquality3, &air_data );
    log_printf( &logger, "\r\n---- AirQuality data ----\r\n" );
    log_printf( &logger, ">> CO2 data is %d ppm.\r\n", air_data.co2 );
    log_printf( &logger, ">> TVOC data is %d ppb.\r\n", air_data.tvoc );

    Delay_1sec( );
}

void main ( void )
{
    application_init( );

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


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

Additional Support

Resources