https://github.com/canonical/matter-pi-gpio-commander Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} canonical / matter-pi-gpio-commander Public * Notifications * Fork 1 * Star 20 Matter Raspberry Pi GPIO Commander - Turn your Pi into a Matter lighting device! License Apache-2.0 license 20 stars 1 fork Star Notifications * Code * Issues 1 * Pull requests 3 * Actions * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Wiki * Security * Insights canonical/matter-pi-gpio-commander This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 3 branches 3 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/c] Use Git or checkout with SVN using the web URL. [gh repo clone canoni] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @farshidtz farshidtz Add avahi-control connection command to Ubuntu Core ... 4c6e274 May 10, 2023 Add avahi-control connection command to Ubuntu Core 4c6e274 Git stats * 24 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time app Initialize the actual GPIO state to on/high (#15) April 28, 2023 20:55 snap Fix license expression March 8, 2023 11:11 .gitignore Switch to C++ app (#3) February 17, 2023 08:43 LICENSE Initialize bridge app December 9, 2022 17:54 README.md Add avahi-control connection command to Ubuntu Core May 10, 2023 11:07 test-blink.cpp Switch from WiringPi pin to BCM GPIO numbering (#7) February 24, 2023 14:54 View code [ ] Matter Pi GPIO Commander Install Configure Set the pin Set CLI flags Grant access DNS-SD GPIO Run Control with Chip Tool Commissioning Command Development Test Blink README.md Matter Pi GPIO Commander matter-pi-gpio-commander This small application can turn your Raspberry Pi into a Matter lighting device. Once setup and commissioned, it allows control of a configured GPIO pin via Matter on/off commands. The GPIO output can be used switch an LED or another device via a relay. The application is based on CHIP's Linux Lighting App example. It used the WiringPi library to control the GPIO of Raspberry Pi. Install sudo snap install matter-pi-gpio-commander Configure Set the pin sudo snap set matter-pi-gpio-commander gpio=4 Make sure to also grant the GPIO access. Set CLI flags By default, the lighting app runs as a service without any CLI flags. The snap allows passing flags to the service via the args snap option. This is useful for overriding SDK defaults to customize the application behavior. For example, to set the --wifi --passcode 1234 flags: snap set matter-pi-gpio-commander args="--wifi --passcode 1234" To see the list of all flags and SDK default, run the help app: $ matter-pi-gpio-commander.help Usage: /snap/matter-pi-gpio-commander/x3/bin/lighting-app [opti GENERAL OPTIONS --ble-device The device number for CHIPoBLE, without 'hci' prefix, can be found by hciconfig. --wifi Enable WiFi management via wpa_supplicant. --thread Enable Thread management via ot-agent. ... Grant access The snap uses interfaces to allow access to external resources. Depending on the use case, you need to "connect" certain interfaces to grant the necessary access. DNS-SD The avahi-control is necessary to allow discovery of the application via DNS-SD: sudo snap connect matter-pi-gpio-commander:avahi-control Note To make DNS-SD discovery work, the host also needs to have a running avahi-daemon which can be installed with sudo apt install avahi-daemon or sudo snap install avahi. Note On Ubuntu Core, the avahi-control interface is not provided by the system. Instead, it depends on the Avahi snap. To use the avahi-control interface from avahi snap, run: sudo snap connect matter-pi-gpio-commander:avahi-control avahi:avahi-control GPIO The gpio-memory-control grants access to all GPIO memory. sudo snap connect matter-pi-gpio-commander:gpio-memory-control Run sudo snap start matter-pi-gpio-commander Add --enable to make the service automatically start at boot. Query and follow the logs: sudo snap logs -n 100 -f matter-pi-gpio-commander Control with Chip Tool For the following examples, we use the Chip Tool snap to commission and control the lighting app. Commissioning sudo chip-tool pairing ethernet 110 20202021 3840 192.168.1.111 5540 where: * 110 is the assigned node id * 20202021 is the default passcode (pin code) for the lighting app * 3840 is the discriminator id * 192.168.1.111 is the IP address of the host for the lighting app * 5540 the the port for the lighting app Alternatively, to commission with discovery which works with DNS-SD: sudo snap connect chip-tool:avahi-observe sudo chip-tool pairing onnetwork 110 20202021 Command Switching on/off: sudo chip-tool onoff toggle 110 1 # toggle is stateless and recommended sudo chip-tool onoff on 110 1 sudo chip-tool onoff off 110 1 where: * onoff is the matter cluster name * on/off/toggle is the command name. The toggle command is RECOMMENDED because it is stateless. The lighting app does not synchronize the actual state of devices. * 110 is the node id of the lighting app assigned during the commissioning * 1 is the endpoint of the configured device Development Build: snapcraft -v This will download >500MB and requires around 8GB of disk space. To build for other architectures, customize the architectures field inside the snapcraft.yaml and use snapcraft's Remote build. Install it as described in the install section by replacing matter-pi-gpio-commander with the locally built snap file name and setting --dangerous flag. Test Blink This project includes an app to quickly verify the chosen pin and snap GPIO access control without using a Matter Controller. The app will toggle the output voltage of the pin to high/low periodically. To use, install the snap and configure the GPIO as explained above. Then, run it via sudo snap run matter-pi-gpio-commander.test-blink snap command or directly: sudo matter-pi-gpio-commander.test-blink About Matter Raspberry Pi GPIO Commander - Turn your Pi into a Matter lighting device! Topics matter Resources Readme License Apache-2.0 license Stars 20 stars Watchers 5 watching Forks 1 fork Report repository Releases 3 tags Packages 0 No packages published Contributors 2 * @farshidtz farshidtz Farshid Tavakolizadeh * @MonicaisHer MonicaisHer Mengyi Wang Languages * C++ 98.6% * Shell 1.4% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.