README.rst
1.. zephyr:code-sample:: mtch9010
2 :name: MTCH9010 Liquid Leak Detector Testbench
3 :relevant-api: sensor_interface
4
5 Configure an MTCH9010 and receive data from it periodically.
6
7Description
8***********
9
10This sample application configures the MTCH9010 in either
11capacitive or conductive sensing mode, triggers a sample
12once per second, and reports the data received from the
13sensor node.
14
15Requirements
16************
17
18This sample application uses the `MTCH9010 Evaluation board (EV24U22A)`_
19wired to the EXT2 header. A valid UART bus and :dtcompatible:`wake-gpios` are required
20in this device configuration. :dtcompatible:`heartbeat-gpios` and
21and :dtcompatible:`output-gpios`, if not specified, will cause the warnings to be
22emitted and/or the relevant values being invalid, however the example
23will function.
24
25.. _MTCH9010 Evaluation board (EV24U22A): https://www.microchip.com/en-us/development-tool/EV24U22A
26
27MTCH9010 Evaluation Board Setup
28*******************************
29
30**Important: The MTCH9010 can only be configured once per
31Power-on-Reset (POR). Press the RESET button on this board
32before resetting the MCU.**
33
34The MTCH9010 Evaluation Board has DIP switches to allow for multiple different
35evaluation conditions. For this example, place the switches and jumpers in the
36following configuration for the SAM L21:
37
38.. list-table:: DIP Switches and Jumper Positions
39 :widths: 1 1
40 :header-rows: 1
41
42 * - DIP Switch or Jumper
43 - Position
44
45 * - Power Supply
46 - 3.3V
47
48 * - OUTPUT
49 - N/A
50
51 * - LOCK
52 - OFF
53
54 * - ECFG
55 - ON
56
57 * - MODE
58 - N/A
59
60 * - USB Bridge
61 - OFF
62
63 * - Sleep Period
64 - N/A
65
66For more information about the function of each switch,
67please consult the `User Manual`_.
68
69.. _User Manual: https://onlinedocs.microchip.com/oxy/GUID-346BCDAA-3BE2-4A0F-8F60-13EDF8CC90A1-en-US-1/index.html
70
71Wiring
72******
73
74.. list-table:: Wiring Configuration
75 :widths: auto
76 :header-rows: 1
77
78 * - MTCH9010 Signal
79 - GPIO Pin
80 - Pin Direction
81 - Required for example
82
83 * - VDD
84 - VCC
85 - N/A
86 - Yes
87
88 * - GND
89 - GND
90 - N/A
91 - Yes
92
93 * - UART TX
94 - PA18
95 - GPIO_OUTPUT
96 - Yes
97
98 * - UART RX
99 - PA19
100 - GPIO_INPUT
101 - Yes
102
103 * - Wake
104 - PB14
105 - GPIO_OUTPUT
106 - Yes
107
108 * - Output
109 - PB15
110 - GPIO_INPUT
111 - No
112
113 * - Heartbeat
114 - PA20
115 - GPIO_INPUT
116 - No
117
118References
119**********
120
121For more information about the MTCH9010, please see
122https://www.microchip.com/en-us/product/mtch9010.
123
124Building and Running
125********************
126
127To build the application, a board with the MTCH9010 connected to
128a non-console UART bus is required. Two example overlays are
129provided for the :zephyr:board:`saml21_xpro`.
130
131.. tabs::
132
133 .. tab:: Capacitive Liquid Mode
134
135 .. zephyr-app-commands::
136 :zephyr-app: samples/sensor/mtch9010
137 :west-args: -- -DDTC_OVERLAY_FILE=capacitive.overlay
138 :board: saml21_xpro
139 :goals: build flash
140
141 .. tab:: Conductive Liquid Mode
142
143 .. zephyr-app-commands::
144 :zephyr-app: samples/sensor/mtch9010
145 :west-args: -- -DDTC_OVERLAY_FILE=conductive.overlay
146 :board: saml21_xpro
147 :goals: build flash
148
149Sample Output
150*************
151
152*Note: The output above the "Booting Zephyr..." line are the literal values
153being sent to the MTCH9010 to configure it.*
154
155.. code-block:: console
156
157 [00:00:00.010,000] <inf> mtch9010.0: "0"
158 [00:00:00.011,000] <inf> mtch9010.0: "0"
159 [00:00:00.013,000] <inf> mtch9010.0: "1"
160 [00:00:00.014,000] <inf> mtch9010.0: "2"
161 [00:00:00.197,000] <inf> mtch9010.0: "0"
162 [00:00:00.199,000] <inf> mtch9010.0: "100"
163 *** Booting Zephyr OS build v4.3.0-2498-gcefd950c5cc5 ***
164 MTCH9010 is Ready
165 SENSOR_CHAN_MTCH9010_SW_OUT_STATE = 0
166 SENSOR_CHAN_MTCH9010_OUT_STATE = 0
167 SENSOR_CHAN_MTCH9010_REFERENCE_VALUE = 508
168 SENSOR_CHAN_MTCH9010_THRESHOLD_VALUE = 100
169 SENSOR_CHAN_MTCH9010_MEAS_RESULT = 508
170 SENSOR_CHAN_MTCH9010_MEAS_DELTA = 0
171 SENSOR_CHAN_MTCH9010_HEARTBEAT_ERROR_STATE = 0
172
173 SENSOR_CHAN_MTCH9010_SW_OUT_STATE = 0
174 SENSOR_CHAN_MTCH9010_OUT_STATE = 0
175 SENSOR_CHAN_MTCH9010_REFERENCE_VALUE = 508
176 SENSOR_CHAN_MTCH9010_THRESHOLD_VALUE = 100
177 SENSOR_CHAN_MTCH9010_MEAS_RESULT = 508
178 SENSOR_CHAN_MTCH9010_MEAS_DELTA = 0
179 SENSOR_CHAN_MTCH9010_HEARTBEAT_ERROR_STATE = 0
180
181<Repeats once per second>
182