TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (405 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (133 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (141952 times)
  2. FAT32 Library (75140 times)
  3. Network Ethernet Library (59420 times)
  4. USB Device Library (49408 times)
  5. Network WiFi Library (45227 times)
  6. FT800 Library (44808 times)
  7. GSM click (31355 times)
  8. mikroSDK (30364 times)
  9. microSD click (27741 times)
  10. PID Library (27595 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

APC1 Sensor Demo

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.6

mikroSDK Library: 2.0.0.0

Category: Environmental

Downloaded: 183 times

Not followed.

License: MIT license  

APC1 Air Quality Sensor Bundle - Experience advanced air quality monitoring with our bundle solution, merging the ScioSense APC1 Air Quality sensor and the MIKROE Terminal Click board™. This dynamic combination creates a compact and precise system that measures PM levels, VOCs, temperature, humidity, and more. Explore this bundle to build an effective monitoring solution perfect for ensuring healthy indoor spaces or contributing to broader air quality research efforts.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "APC1 Sensor Demo" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "APC1 Sensor Demo" changes.

Do you want to report abuse regarding "APC1 Sensor Demo".

  • Information
  • Comments (0)

mikroSDK Library Blog


APC1 Sensor Demo

APC1 Air Quality Sensor Bundle - Experience advanced air quality monitoring with our bundle solution, merging the ScioSense APC1 Air Quality sensor and the MIKROE Terminal Click board™. This dynamic combination creates a compact and precise system that measures PM levels, VOCs, temperature, humidity, and more. Explore this bundle to build an effective monitoring solution perfect for ensuring healthy indoor spaces or contributing to broader air quality research efforts.

apc1sensor.png

Click Product page


Demo library

  • Author : Stefan Filipovic
  • Date : Sep 2023.
  • Type : I2C/UART type

Software Support

We provide a library for the APC1 Sensor Demo 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 APC1 Sensor Demo driver.

Standard key functions :

  • apc1sensor_cfg_setup Config Object Initialization function.

    void apc1sensor_cfg_setup ( apc1sensor_cfg_t *cfg );
  • apc1sensor_init Initialization function.

    err_t apc1sensor_init ( apc1sensor_t *ctx, apc1sensor_cfg_t *cfg );
  • apc1sensor_default_cfg Demo Default Configuration function.

    err_t apc1sensor_default_cfg ( apc1sensor_t *ctx );

Example key functions :

  • apc1sensor_start_measurement This function starts measurement by setting the device to measurement mode.

    err_t apc1sensor_start_measurement ( apc1sensor_t *ctx );
  • apc1sensor_read_info This function reads the device name, serial number, and firmware version.

    err_t apc1sensor_read_info ( apc1sensor_t *ctx, apc1sensor_info_t *info );
  • apc1sensor_read_measurement This function reads the measurement 64-bytes output structure data.

    err_t apc1sensor_read_measurement ( apc1sensor_t *ctx, apc1sensor_measurement_t *measurement );

Example Description

This example demonstrates the use of APC1 Air Quality Sensor Bundle by reading measurement results (PM1.0, PM2.5, PM10, TVOC, eCO2, AQI, temperature, relative humidity, etc.).

The demo application is composed of two sections :

Application Init

Initializes the driver, performs the sensor default configuration, and reads the sensor name, serial number, and firmware version.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    apc1sensor_cfg_t apc1sensor_cfg;  /**< Demo 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 " );

    // Sensor initialization.
    apc1sensor_cfg_setup( &apc1sensor_cfg );
    APC1SENSOR_MAP_MIKROBUS( apc1sensor_cfg, MIKROBUS_1 );
    if ( APC1SENSOR_OK != apc1sensor_init( &apc1sensor, &apc1sensor_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( APC1SENSOR_OK != apc1sensor_default_cfg ( &apc1sensor ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    apc1sensor_info_t info;
    if ( APC1SENSOR_OK == apc1sensor_read_info ( &apc1sensor, &info ) )
    {
        log_printf ( &logger, " Module name: %s\r\n", info.module_name );
        log_printf ( &logger, " Serial number: " );
        for ( uint8_t cnt = 0; cnt < 8; cnt++ )
        {
            log_printf ( &logger, "%.2X", ( uint16_t ) info.serial_num[ cnt ] );
        }
        log_printf ( &logger, "\r\n FW version: %.2X%.2X\r\n", 
                     ( uint16_t ) info.fw_version[ 0 ], ( uint16_t ) info.fw_version[ 1 ] );
    }
    Delay_ms ( 1000 );

    log_info( &logger, " Application Task " );
}

Application Task

Reads the measurement results and displays all data on the USB UART once per second.

void application_task ( void )
{
    apc1sensor_measurement_t meas;
    if ( APC1SENSOR_OK == apc1sensor_read_measurement ( &apc1sensor, &meas ) )
    {
        log_printf ( &logger, "--- MEASUREMENT RESULTS ---\r\n" );
        log_printf ( &logger, " PM1.0: %u ug/m3\r\n", meas.pm1_0 );
        log_printf ( &logger, " PM2.5: %u ug/m3\r\n", meas.pm2_5 );
        log_printf ( &logger, " PM10: %u ug/m3\r\n", meas.pm10 );
        log_printf ( &logger, " PM1.0 in air: %u ug/m3\r\n", meas.pm1_0_air );
        log_printf ( &logger, " PM2.5 in air: %u ug/m3\r\n", meas.pm2_5_air );
        log_printf ( &logger, " PM10 in air: %u ug/m3\r\n", meas.pm10_air );
        log_printf ( &logger, " # particles >0.3um: %u\r\n", meas.part_over_0_3um );
        log_printf ( &logger, " # particles >0.5um: %u\r\n", meas.part_over_0_5um );
        log_printf ( &logger, " # particles >1.0um: %u\r\n", meas.part_over_1_0um );
        log_printf ( &logger, " # particles >2.5um: %u\r\n", meas.part_over_2_5um );
        log_printf ( &logger, " # particles >5.0um: %u\r\n", meas.part_over_5_0um );
        log_printf ( &logger, " # particles >10um: %u\r\n", meas.part_over_10um );
        log_printf ( &logger, " TVOC: %u ppb\r\n", meas.tvoc );
        log_printf ( &logger, " eCO2: %u ppm\r\n", meas.eco2 );
        log_printf ( &logger, " T-comp: %.1f degC\r\n", meas.t_comp );
        log_printf ( &logger, " RH-comp: %.1f %%\r\n", meas.rh_comp );
        log_printf ( &logger, " T-raw: %.1f degC\r\n", meas.t_raw );
        log_printf ( &logger, " RH-raw: %.1f %%\r\n", meas.rh_raw );
        log_printf ( &logger, " RS0: %lu Ohm\r\n", meas.rs0 );
        log_printf ( &logger, " RS2: %lu Ohm\r\n", meas.rs2 );
        log_printf ( &logger, " RS3: %lu Ohm\r\n", meas.rs3 );
        log_printf ( &logger, " AQI: %u\r\n", ( uint16_t ) meas.aqi );
        log_printf ( &logger, " Version: 0x%.2X\r\n", ( uint16_t ) meas.version );
        log_printf ( &logger, " Error code: 0x%.2X\r\n", ( uint16_t ) meas.error_code );
        log_printf ( &logger, "---------------------------\r\n" );
    }
    Delay_ms ( 1000 );
}

Note

By default, the I2C communication interface is selected in the library, which is compatible with APC1001J sensor. If you are using an UART version of the sensor (APC1001U) refer to the apc1sensor_drv_interface_sel function description in order to properly change the interface selection in the library.

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

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.


ALSO FROM THIS AUTHOR

NTAG 5 Link Click

0

NTAG 5 Link Click is a compact add-on board that acts as a bridge between an NFC-enabled device and any I2C slave, such as a sensor or external memory. This board features the NTA5332, a highly integrated NFC IC which creates a secure standard-based link from the device to the cloud from NXP Semiconductors. Based on the NTAG 5 switch and operating at 13.56MHz, the NTA5332 represents an NFC Forum-compliant contactless tag that can be read and written by an NFC-enabled device at close range and by an ISO/IEC 15693-enabled industrial reader over a more extended range. It also incorporates an I2C interface with an I2C master features and AES mutual authentication, SRAM memory, and energy harvesting possibility, which means it can supply power to other components in the system.

[Learn More]

6DOF IMU 22 Click

0

6DOF IMU 22 Click is a compact add-on board for advanced motion tracking. This board features the ICM-42670-P, a high-performance 6-axis MEMS MotionTracking IMU from TDK InvenSense. The ICM-42670-P integrates a 3-axis gyroscope and accelerometer, offering exceptional precision in motion detection. It supports both I2C and SPI interfaces for communication, features a substantial 2.25Kbytes FIFO, and includes two programmable interrupts that enhance power efficiency through a wake-on-motion feature.

[Learn More]

RFID 2 Click

0

RFID 2 Click is a compact add-on board that contains a stand-alone RFID reader with a built-in antenna easy-to-use for embedded applications. This board features the ID-12LA-SA, an advanced low-cost RFID reader module usable with 38 different tags from ID Innovations.

[Learn More]