为了应对日益严重的空气污染问题,我们的监控解决方案如同守护者,确保您呼吸的空气质量最高。
A
A
硬件概览
它是如何工作的?
Air Quality 8 Click基于ZMOD4510,这是一款由瑞萨设计的预校准数字传感器,旨在可靠检测室内外空气质量。该传感器具备选择性臭氧测量能力(NO2和O3),在连续运行中功耗低于23mW,提高了能效而不影响空气质量。它还具有电气和气体校准、经过验证的MOx材料、数字接口、硅氧烷耐受性、高灵敏度和长期稳定性,可实现ppb级检测限度。其扩展的工作湿度和温度范围覆盖5至90%RH和-20°C至50°C,臭氧和二氧化氮的测量范围为20至500ppb。ZMOD4510的气体传感元件由硅基MEMS结构上的加热元件、金属氧化物(MOx)化学电阻器和CMOS信号调节IC组成,该IC控制传感
器温度并测量MOx电阻,电阻是气体浓度的函数。它有两种工作模式。第一种模式允许对空气质量进行一般测量,包括对二氧化氮(NO2)和臭氧(O3)的非选择性测量。第二种模式允许选择性测量臭氧(O3),在快速采样率为2秒时,平均功耗为0.2mW。它根据研究和国际标准检测典型气体,并使用一系列应用温度对空气进行采样并报告空气质量指数(AQI)。传感器不需要主动或直接的气流通过传感器模块,因为环境气体的扩散不会限制传感器的响应时间。ZMOD4510还可以检测安全相关气体;然而,该传感器模块并非设计用于可靠检测这些干扰物,因此未获批准用于安全关键或生命保
护应用。Air Quality 8 Click使用标准I2C两线接口与MCU通信,以读取数据和配置设置,支持100kHz时钟频率的标准模式和高达400kHz的快速模式操作。此外,它还具有其他功能,如连接到mikroBUS™插座RST引脚的复位引脚,将模块置于低逻辑电平时进入复位状态,以及连接到mikroBUS™插座INT引脚的额外中断信号,用于指示测量过程的状态。此Click board™只能在3.3V逻辑电压水平下运行。因此,在使用不同逻辑电平的MCU之前,必须进行适当的逻辑电压电平转换。此外,此Click board™配备了包含函数和示例代码的库,可用作进一步开发的参考。
功能概述
开发板
EasyPIC v8 是一款专为快速开发嵌入式应用的需求而特别设计的开发板。它支持许多高引脚计数的8位PIC微控制器,来自Microchip,无论它们的引脚数量如何,并且具有一系列独特功能,例如首次集成的调试器/程序员。开发板布局合理,设计周到,使得最终用户可以在一个地方找到所有必要的元素,如开关、按钮、指示灯、连接器等。得益于创新的制造技术,EasyPIC v8 提供了流畅而沉浸式的工作体验,允许在任何情况下、任何地方、任何时候都能访问。
EasyPIC v8 开发板的每个部分都包含了使同一板块运行最高效的必要组件。除了先进的集成CODEGRIP程 序/调试模块,该模块提供许多有价值的编程/调试选项和与Mikroe软件环境的无缝集成外,该板还包括一个干净且调节过的开发板电源供应模块。它可以使用广泛的外部电源,包括电池、外部12V电源供应和通过USB Type-C(USB-C)连接器的电源。通信选项如USB-UART、USB DEVICE和CAN也包括在内,包括 广受好评的mikroBUS™标准、两种显示选项(图形和
基于字符的LCD)和几种不同的DIP插座。这些插座覆盖了从最小的只有八个至四十个引脚的8位PIC MCU的广泛范围。EasyPIC v8 是Mikroe快速开发生态系统的一个组成部分。它由Mikroe软件工具原生支持,得益于大量不同的Click板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作和开发的许多方面。
微控制器概述
MCU卡片 / MCU

建筑
PIC
MCU 内存 (KB)
32
硅供应商
Microchip
引脚数
40
RAM (字节)
2048
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
软件支持
库描述
该库包含 Air quality 8 Click 驱动程序的 API。
关键功能:
airquality8_calc_oaq- Air Quality 8 计算空气质量指数(AQI)功能airquality8_read_rmox- Air Quality 8 计算rmox电阻功能airquality8_start_measurement- Air Quality 8 开始测量功能
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* @file main.c
* @brief AirQuality8 Click example
*
* # Description
* This library contains API for Air Quality 8 Click driver.
* The library initializes and defines the I2C bus drivers
* to write and read data from registers.
* The library also includes a function for configuring sensor and measurement,
* read and calculate mox resistance ( RMOX ) and air quality index ( AQI ), etc.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initialization of I2C module and log UART, and additional pins.
* After the driver inits and executes a default configuration,
* the app read product ID and configuration parameters,
* initializes the sensor and measurement.
*
* ## Application Task
* This is an example that demonstrates the use of the Air Quality 8 Click board™.
* In this example, the app performs the start of the measurement,
* reads an array of the 15 mox resistances measurements ( RMOX ),
* and calculates the air quality index ( AQI ), the app also, displays if an error occurs.
* Results are being sent to the Usart Terminal where you can track their changes.
*
* ## Additional Function
* - static void display_error ( void )
*
* @author Nenad Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "airquality8.h"
static airquality8_t airquality8;
static log_t logger;
static uint16_t mox_lr;
static uint16_t mox_er;
static uint8_t status_flag;
static void display_error ( void )
{
if ( status_flag == AIRQUALITY8_ERROR_INIT_OUT_OF_RANGE )
{
log_printf( &logger, " The initialize value is out of range.\r\n" );
}
if ( status_flag == AIRQUALITY8_ERROR_GAS_TIMEOUT )
{
log_printf( &logger, " The operation took too long.\r\n" );
}
if ( status_flag == AIRQUALITY8_ERROR_I2C )
{
log_printf( &logger, " Failure in i2c communication.\r\n" );
}
if ( status_flag == AIRQUALITY8_ERROR_SENSOR_UNSUPPORTED )
{
log_printf( &logger, " Sensor is not supported with this firmware.\r\n" );
}
if ( status_flag == AIRQUALITY8_ERROR_CONFIG_MISSING )
{
log_printf( &logger, " There is no pointer to a valid configuration.\r\n" );
}
if ( status_flag == AIRQUALITY8_ERROR_SENSOR )
{
log_printf( &logger, " Sensor malfunction.\r\n" );
}
}
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
airquality8_cfg_t airquality8_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.
airquality8_cfg_setup( &airquality8_cfg );
AIRQUALITY8_MAP_MIKROBUS( airquality8_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == airquality8_init( &airquality8, &airquality8_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( AIRQUALITY8_ERROR == airquality8_default_cfg ( &airquality8 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
Delay_ms ( 100 );
static uint8_t cfg_data[ 6 ];
static uint8_t prod_data[ 5 ];
static uint16_t pid;
airquality8_get_sensor_info( &airquality8, &cfg_data[ 0 ], &prod_data[ 0 ], &pid );
if ( pid != AIRQUALITY8_PRODUCT_ID )
{
status_flag = AIRQUALITY8_ERROR_I2C;
display_error( );
for ( ; ; );
}
Delay_ms ( 100 );
log_printf( &logger, "---------------------------\r\n" );
log_printf( &logger, " Product ID : 0x%.2X \r\n", pid );
Delay_ms ( 100 );
airquality8_init_sensor( &airquality8, &mox_lr, &mox_er );
Delay_ms ( 10 );
airquality8_init_measurement( &airquality8 );
Delay_ms ( 10 );
log_printf( &logger, "---------------------------\r\n" );
log_info( &logger, " Application Task " );
log_printf( &logger, "---------------------------\r\n" );
log_printf( &logger, " Air Quality Index\r\n" );
log_printf( &logger, "- - - - - - - - - - - - - -\r\n" );
Delay_ms ( 100 );
}
void application_task ( void )
{
static uint8_t status_data;
static float rmox;
static float rmox_seq[ 15 ];
static float aqi;
status_flag = airquality8_start_measurement( &airquality8 );
airquality8_get_status( &airquality8, &status_data );
Delay_ms ( 10 );
while ( ( status_data & AIRQUALITY8_STATUS_LAST_SEQ_STEP_MASK ) != AIRQUALITY8_OK )
{
airquality8_get_status( &airquality8, &status_data );
Delay_ms ( 10 );
}
for ( uint8_t n_cnt = 0; n_cnt < 15; n_cnt++ )
{
status_flag = airquality8_read_rmox( &airquality8, &rmox, mox_lr, mox_er );
rmox_seq[ n_cnt ] = rmox;
Delay_ms ( 100 );
if ( status_flag != AIRQUALITY8_OK )
{
display_error( );
}
}
aqi = airquality8_calc_oaq( rmox_seq, AIRQUALITY8_RCDA_STRATEGY_ADJ, AIRQUALITY8_GAS_DETECTION_STRATEGY_AUTO );
log_printf( &logger, " \tAQI : %.3f \r\n", aqi );
log_printf( &logger, "---------------------------\r\n" );
Delay_ms ( 1000 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END

































