中级
30 分钟

使用MCP606和MK64FN1M0VDC12简化水存在监测

监测水侵入,安心无忧

Water Detect Click with Clicker 2 for Kinetis

已发布 6月 26, 2024

点击板

Water Detect Click

开发板

Clicker 2 for Kinetis

编译器

NECTO Studio

微控制器单元

MK64FN1M0VDC12

该解决方案的目的是提供可靠的水检测,帮助预防水灾和减轻各种环境中潜在风险。

A

A

硬件概览

它是如何工作的?

Water Detect Click用于检测水和其他导电液体。如果检测区域潮湿,Microchip的MCP606 CMOS运算放大器的输出将变为正值,表示液体存在。Water Detect Click可用作家庭洪水报警传感器、智能建筑的雨水检测器,或用于水箱,作为泵的限位开关。Water Detect Click通过比较使用MCP606比较器的两个电阻分压器的电压来工作。电阻分压器(由R2和R3组成)用作电压参考。 MCP606在这个Click板上作为

比较器工作。第二个分压器由电阻R1和感应区域组成。当感应区域干燥时,其电阻接近无穷大,并且应用于比较器反向输入的电压等于VCC。由于连接到非反向输入的参考分压器的电压为VCC/2,因此比较器的输出为零电压。一旦液体出现在感应区域,其电阻下降,并将比较器反向输入的电压拉向零电压。一旦此电压降至VCC/2以下,比较器输出会向VCC摆动,表示液体存在。比较器输出连接到

mikroBUS™头上的INT引脚。水检测区实际上是由裸露的导电线组成的 - 简单但有效的技术。该Click板可以通过VCC SEL跳线选择3.3V或5V逻辑电压电平操作。这样,既能支持3.3V又能支持5V的MCU可以正确使用通信线。此外,该Click板配备了一个包含易于使用的函数和示例代码的库,可用作进一步开发的参考。

Water Detect Click top side image
Water Detect Click bottom side image

功能概述

开发板

Clicker 2 for Kinetis 是一款紧凑型入门开发板,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位 ARM Cortex-M4F 微控制器,NXP 半导体公司的 MK64FN1M0VDC12,两个 mikroBUS™ 插槽用于 Click 板™连接,一个 USB 连接器,LED 指示灯,按钮,一个 JTAG 程序员连接器以及两个 26 针头用于与外部电子设备的接口。其紧凑的设计和清晰、易识别的丝网标记让您能够迅速构建具有独特功能和特性

的小工具。Clicker 2 for Kinetis 开发套件的每个部分 都包含了使同一板块运行最高效的必要组件。除了可以选择 Clicker 2 for Kinetis 的编程方式,使用 USB HID mikroBootloader 或外部 mikroProg 连接器进行 Kinetis 编程外,Clicker 2 板还包括一个干净且调节过的开发套件电源供应模块。它提供了两种供电方式;通过 USB Micro-B 电缆,其中板载电压调节器为板上每个组件提供适当的电压水平,或使用锂聚合物 电池通过板载电池连接器供电。所有 mikroBUS™ 本

身支持的通信方法都在这块板上,包括已经建立良好的 mikroBUS™ 插槽、重置按钮和几个用户可配置的按钮及 LED 指示灯。Clicker 2 for Kinetis 是 Mikroe 生态系统的一个组成部分,允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。

Clicker 2 for Kinetis dimensions image

微控制器概述 

MCU卡片 / MCU

default

建筑

ARM Cortex-M4

MCU 内存 (KB)

1024

硅供应商

NXP

引脚数

121

RAM (字节)

262144

使用的MCU引脚

mikroBUS™映射器

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
Water Detect Interrupt
PB13
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Water Detect Click Schematic schematic

一步一步来

项目组装

Clicker 2 for PIC32MZ front image hardware assembly

从选择您的开发板和Click板™开始。以Clicker 2 for Kinetis作为您的开发板开始。

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

实时跟踪您的结果

应用程序输出

此款Click板可通过两种方式进行接口连接和监控:

  • Application Output - 在调试模式下,使用“Application Output”窗口进行实时数据监控。按照本教程正确设置它。

软件支持

库描述

这个库包含Water DetectClick驱动程序的API。

关键函数:

  • waterdetect_get_status - 获取水检测功能的状态

开源

代码示例

完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio 应用程序代码也可以在MIKROE的GitHub账户中找到。

/*!
 * \file 
 * \brief Water Detect Click example
 * 
 * # Description
 * Water Detect click is used for detecting water and other electroconductive liquids. If the detection area is wet the output of Microchip's MCP606 CMOS op-amp will go positive, signaling the presence of liquid.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes GPIO and LOG structures, set INT pins as input and starts to write log.
 * 
 * ## Application Task  
 * Reads device status and determines if there are water presence or not.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "waterdetect.h"

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

static waterdetect_t waterdetect;
static log_t logger;

uint8_t wd_state = 0;
uint8_t wd_state_old = 0;

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

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

    waterdetect_cfg_setup( &cfg );
    WATERDETECT_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    waterdetect_init( &waterdetect, &cfg );
    Delay_100ms();
    
    log_printf( &logger, "  Initialization Driver   \r\n" );
    log_printf( &logger, "------------------------- \r\n" );
    log_printf( &logger, "  Wait to detect water... \r\n" );
    log_printf( &logger, "------------------------- \r\n" );
}

void application_task ( void )
{
    wd_state = waterdetect_get_status( &waterdetect );

    if ( wd_state > wd_state_old )
    {
        log_printf( &logger, " >  Water is detected  < \r\n" );
        log_printf( &logger, "------------------------- \r\n" );
        wd_state_old = 1;
    }

    if ( wd_state < wd_state_old )
    {
        log_printf( &logger, " There is no water \r\n" );
        log_printf( &logger, "------------------- \r\n" );
        wd_state_old = 0;
    }
}

void main ( void )
{
    application_init( );

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

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

额外支持

资源

喜欢这个项目吗?

'购买此套件' 按钮会直接带您进入购物车,您可以在购物车中轻松添加或移除产品。