The MTCH9010 is a turn-key liquid leak detector ASIC that can use either conductivity or changes in capacitance to detect liquid leaks, and to provide a flexible and easy to set up IC for customers to develop their design on. To speed development of this device even further, Microchip has written and contributed a sensor driver and driver sample for the MTCH9010 in Zephyr® RTOS.
Prerequisites and Background
The Zephyr Project provides official installation and setup instructions online. This blog post will assume that Zephyr is installed and running, and the Python Virtual Environment is currently running. This sample uses the SAM L21 Xplained Pro Evaluation Kit (ATSAML21-XPRO-B) wired to the MTCH9010 Evaluation Kit, however other boards (including from other MCU vendors) are compatible but will have differences in UART / GPIO setup.
Note: If you are in the root folder of a standard zephyr install, the path to the sample is samples/sensor/mtch9010.
KConfig Setup
KConfig is a system that Zephyr uses (generally) for software configuration flags. The sample project already contains the required KConfig values for the MTCH9010 in the file prj.conf of the project, but if you would like to modify the flags, you can access the KConfig system by building the project and then running:
west build -t menuconfig
Running this command will show a GUI. If setup correctly, the MTCH9010 options will appear under the following path: Device Drivers → Sensor drivers → MTCH9010. Alternatively, press “/” to search for the symbol and press enter.
Figure 1 – Default MTCH9010 settings in KConfig
These settings apply to all instances of the MTCH9010 in the project. In this instance, the default values are acceptable.
Driver Design
The sample application initializes the sensor and periodically prints all the sensor values to terminal. The MTCH9010 implements the sensor API as Fetch and Get – meaning that the sensor data is loaded into an internal buffer, and then sensor values are decoded from the buffer later, when requested by the application.
Building and Programming
If this is the first build of this project, then the command below will force a clean rebuild:
west build -p always -b saml21_xpro <folder_to_project>
If the project has already been built before, then this command will let the toolchain decide if it needs to be rebuilt fully:
west build -b saml21_xpro <folder_to_project>
After compilation is complete, the board can be flashed using:
west flash
This command will automatically search for and program the SAM L21 XPlained Pro through the debug USB header. If unable to program the board via west, the compiled binary can be passed to another program for programming, like MPLAB® X IPE or equivalent.
Hardware Setup
First, disable the USB bridge and enable UART configuration on the MTCH9010 Evaluation Kit. Ensure the jumpers are in the positions shown below.
| Switch | State |
|---|---|
| OUTPUT | N/A |
| LOCK | OFF |
| ECFG | ON |
| MODE | N/A |
| USB BRIDGE | OFF |
| SLEEP PERIOD | N/A |
Then, connect the MTCH9010 development board to the development board at the GPIO pins specified in Devicetree. For the SAM L21 Xplained Pro, the following pins are used on the EXT2 header.
| MTCH9010 Evaluation Kit | SAML21 XPlained Pro |
|---|---|
| VDD | VCC |
| GND | GND |
| HBEAT | PA20 |
| DETECT (OUT) | PB15 |
| WAKE | PB14 |
Now plug in and flash the board via the debug USB interface. Connect to the Virtual COM Port opened by the board at 115200 baud (8-bit characters, 1 stop bit, no parity) using MPLAB Data Visualizer or another serial terminal. Press the reset button on the MTCH9010 board to ensure the board is ready to accept a configuration, before pressing the reset button on the MCU development board. If everything is working correctly, it should start printing out information, as shown below.

