Hi there,
So there are a couple ways (2) AFAIK, use “&xiao_d” for the “D Pins” with these, “the SILK pins” i.e. the diagram pic or the
GPIO’s “&gpio0<pin…>”
on the XIAO nRF54L15 Sense the mappings are:
- USER button:
P0.00
(active-low to GND). Seeed Studio Files+1 - D0 pin:
P1.04
(also labeled A0/D0). Seeed Studio Files
Below is a clean Zephyr setup that replaces the DK button masks and gives you debounced events for both buttons via gpio-keys
.
1) Devicetree overlay
Create boards/xiao_nrf54l15_nrf54l15_cpuapp.overlay
(or your app’s overlay) with:
/ {
aliases {
sw0 = &user_btn; /* USER button (P0.00) */
sw1 = &ext_btn; /* External button on D0 (P1.04) */
};
buttons: buttons {
compatible = "gpio-keys";
/* On-board USER button: P0.00 → GND (pull-up, active-low) */
user_btn: user_btn {
gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "USER_BUTTON_P0_00";
zephyr,code = <INPUT_KEY_0>;
};
/* External button on D0: P1.04 → GND (pull-up, active-low) */
ext_btn: ext_btn {
gpios = <&gpio1 4 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "EXT_BUTTON_D0_P1_04";
zephyr,code = <INPUT_KEY_1>;
};
};
};
2) prj.conf
Enable the input stack and gpio-keys
(and stop using the DK helper):
CONFIG_GPIO=y
CONFIG_INPUT=y
CONFIG_INPUT_GPIO_KEYS=y
CONFIG_DK_LIBRARY=n
3) Minimal app code (works great for Matter samples too)
// src/main.c
#include <zephyr/kernel.h>
#include <zephyr/input/input.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);
static void input_cb(const struct device *dev, struct input_event *evt)
{
if (evt->type != INPUT_EV_KEY) return;
const bool pressed = (evt->value != 0);
switch (evt->code) {
case INPUT_KEY_0: // USER (P0.00)
LOG_INF("USER (P0.00) %s", pressed ? "pressed" : "released");
/* TODO: in Matter contact_sensor, flip contact attribute here */
break;
case INPUT_KEY_1: // D0 (P1.04)
LOG_INF("D0 (P1.04) %s", pressed ? "pressed" : "released");
break;
default:
break;
}
}
INPUT_CALLBACK_DEFINE(NULL, input_cb);
int main(void)
{
LOG_INF("Buttons ready: USER=P0.00 (INPUT_KEY_0), D0=P1.04 (INPUT_KEY_1)");
while (1) { k_sleep(K_SECONDS(1)); }
}
Hookup reality (no hand-waving)
- USER button is already wired to GND on the board—keep
GPIO_PULL_UP | GPIO_ACTIVE_LOW
. Seeed Studio Files+1 - D0 external button: wire D0 → switch → GND; no external resistor needed (we enable the internal pull-up). D0 maps to P1.04. Seeed Studio Files
- Boot-time safety: Using D0 at runtime is fine. Just don’t hold it asserted at reset if any boot strap is ever assigned to that pad in other firmware.
I like using the onboard buttons, why NOT ? just don’t mess with them at boot time as always. I don’t like them location wise though, "Best in Button Class " goes to the C3 IMO.
HTH
GL PJ