The purpose of this solution is to offer reliable water detection, helping prevent water damage and mitigate potential risks in various environments
A
A
Hardware Overview
How does it work?
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. Water Detect click can be used as a household flood alarm sensor, rain detector for smart buildings or for water tanks that act as a limit switch for a pump. Water Detect click works by comparing the voltage of two resistor dividers using the MCP606 comparator. The resistor divider (made of R2 and R3) is used as a voltage reference. The MCP606 functions as a comparator on this
Click board™. The second divider is made of resistor R1 and the sensory area. When the sensory area is dry, it's resistance is near infinite, and the voltage applied to the inverting terminal of the comparator equals VCC. Since the voltage of the reference divider connected to the non-inverting input is VCC/2, the output of the comparator is at zero voltage. Once the liquid is present at the sensory area, it's resistance drops and pulls the voltage on the inverting input of the comparator toward zero volts. Once this voltage falls below VCC/2, the comparator output swings toward VCC
signaling the presence of liquid. The comparator output is tied to the INT pin on the mikroBUS™ header. The water detection area is actually made of exposed conducting wires - simple but effective technology. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC 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.
Features overview
Development board
Clicker 4 for STM32F3 is a compact development board designed as a complete solution, you can use it to quickly build your own gadgets with unique functionalities. Featuring a STM32F302VCT6, four mikroBUS™ sockets for Click boards™ connectivity, power managment, and more, it represents a perfect solution for the rapid development of many different types of applications. At its core, there is a STM32F302VCT6 MCU, a powerful microcontroller by STMicroelectronics, based on the high-
performance Arm® Cortex®-M4 32-bit processor core operating at up to 168 MHz frequency. It provides sufficient processing power for the most demanding tasks, allowing Clicker 4 to adapt to any specific application requirements. Besides two 1x20 pin headers, four improved mikroBUS™ sockets represent the most distinctive connectivity feature, allowing access to a huge base of Click boards™, growing on a daily basis. Each section of Clicker 4 is clearly marked, offering an intuitive and clean interface. This makes working with the development
board much simpler and thus, faster. The usability of Clicker 4 doesn’t end with its ability to accelerate the prototyping and application development stages: it is designed as a complete solution which can be implemented directly into any project, with no additional hardware modifications required. Four mounting holes [4.2mm/0.165”] at all four corners allow simple installation by using mounting screws. For most applications, a nice stylish casing is all that is needed to turn the Clicker 4 development board into a fully functional, custom design.
Microcontroller Overview
MCU Card / MCU

Architecture
ARM Cortex-M4
MCU Memory (KB)
256
Silicon Vendor
STMicroelectronics
Pin count
100
RAM (Bytes)
40960
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Software Support
Library Description
This library contains API for Water DetectClick driver.
Key functions:
waterdetect_get_status- Get the status of the water detection function
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 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;
}
}
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
Additional Support
Resources
Category:Miscellaneous
































