Skip to content

PinAlarm triggers from capacitive touch instead of button press on RP2040 #10630

@rbrian

Description

@rbrian

CircuitPython version and board name

Adafruit CircuitPython 10.0.0-beta.3 on 2025-08-29; Adafruit Feather RP2040 with rp2040

Code/REPL

import board
import time
import neopixel
import digitalio

import alarm

import adafruit_debouncer

from adafruit_led_animation.color import RED, GREEN, BLUE, PURPLE, BLACK, GOLD


class Main:

    def __init__(self):
        ########################
        # set up key

        self.keypin = digitalio.DigitalInOut(board.A1)
        self.keypin.direction = digitalio.Direction.INPUT
        self.keypin.pull = digitalio.Pull.DOWN
        self.btn = adafruit_debouncer.Debouncer(self.keypin)
        print(dir(self.keypin))

        ########################
        # set up button neopixel

        print(type(alarm.wake_alarm))

        self.pixels = neopixel.NeoPixel(board.A0, 30)

        if self.keypin.value:
            self.pixels[0] = GREEN
            self.wokeup = True
        else:
            self.pixels[0] = GOLD

    lastaction = time.monotonic()

    def Loop(self):
        while True:
            self.btn.update()

            if self.btn.rose:
                self.lastaction = time.monotonic()
                self.pixels[0] = GREEN
            elif self.btn.fell:
                self.lastaction = time.monotonic()
                print("Fell")
                self.pixels[0] = BLACK

            if time.monotonic() - self.lastaction > 5:
                self.pixels[0] = GOLD
                time.sleep(0.1)
                self.pixels[0] = BLACK

                self.btn = None
                self.keypin.deinit()
                print("Goodnight")
                pin_alarm = alarm.pin.PinAlarm(pin=board.A1, value=True)
                alarm.exit_and_deep_sleep_until_alarms(pin_alarm)


main = Main()
main.Loop()

Behavior

After entering sleep mode, putting a finger near the button or it's connecting cable will trigger the PinAlarm.

Description

Hardware: Feather RP2040 with NeoKey breakout attached to A0 (neopixel) and A1 (key)

Key will turn yellow (if key is low) or green (if key is high) at boot. Code will enter deep sleep after 5 seconds. Touching or getting near enough to the cable or the breakout will trigger the pinalarm. I've had it happen at almost 1" distance, and sometimes needs to be as close as actually pinching the connecting wires between 2 fingers.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugrp2040Raspberry Pi RP2040supportissues that involve helping a user accomplish a task

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions