Skip to content

Latest commit

 

History

History
222 lines (140 loc) · 6.6 KB

File metadata and controls

222 lines (140 loc) · 6.6 KB

Matter: Contact sensor

This sample demonstrates how to use the :ref:`Matter <ug_matter>` application layer to build a device capable of detecting a contact.

The sample supports the following development kits:

.. table-from-sample-yaml::

The sample does not use a real contact sensor due to a hardware limitation. It simulates contact detection, which you can initiate by pressing and releasing a button. The contact sensor state is represented by the BooleanState cluster on the endpoint 1.

You can test the device remotely over a Thread network, which requires more devices.

The remote control testing requires a Matter controller that you can configure either on a PC or a mobile device.

The Contact sensor implements the following features. Use the click to show toggle to expand the content.

The sample supports the following build configurations:

First LED:
Second LED:

Shows the state of the contact detection. The following states are possible:

  • Solid On - The contact is detected.
  • Off - The contact is not detected.

Additionally, the LED starts blinking evenly (500 ms on/500 ms off) when the Identify command of the Identify cluster is received on the endpoint 1. You can specify the duration of the effect using the command arguments.

First Button:
Second Button:
Simulates contact detection. Pressing the button sets the contact state to detected. Releasing the button sets the contact state to not detected.
Third Button:
Functions as the User Active Mode Trigger (UAT) button. For more information about Intermittently Connected Devices (ICD) and User Active Mode Trigger, see the :ref:`ug_matter_device_low_power_icd` documentation section.

|matter_ble_advertising_auto|

Complete the following steps to test the Contact sensor device using CHIP Tool:

.. rst-class:: numbered-step

Run CHIP Tool interactive mode

Enter the interactive mode by running the following command:

chip-tool interactive start
.. rst-class:: numbered-step

Read the contact detection state

In the interactive mode, read the contact detection state by running the following command:

booleanstate read state-value 1 1

The received output will look similar to the following:

[1756375237.321] [61118:61120] [TOO] Endpoint: 1 Cluster: 0x0000_0045 Attribute 0x0000_0000 DataVersion: 2772696482
[1756375237.321] [61118:61120] [TOO]   StateValue: FALSE
.. rst-class:: numbered-step

Simulate contact detection

Press and hold the |Second Button| to simulate contact detection. In the interactive mode, read the contact detection state again (do not release the button) by running the following command:

booleanstate read state-value 1 1

The received value will be different, for example:

[1756375237.321] [61118:61120] [TOO] Endpoint: 1 Cluster: 0x0000_0045 Attribute 0x0000_0000 DataVersion: 2772696482
[1756375237.321] [61118:61120] [TOO]   StateValue: TRUE
.. rst-class:: numbered-step

Subscribe to the contact detection state changes

In the interactive mode, subscribe to the contact detection state changes to see the state change in real time by running the following command:

booleanstate subscribe state-value 0 300 1 1
.. rst-class:: numbered-step

Observe the contact detection state changes

Press and release the |Second Button| a few times and observe the state changes reported automatically in the CHIP Tool interactive mode.