I recently got some rp2040s for a keyboard project. I have used these before and never had any trouble.
However this time I would flash them with firmware and everything would appear to be fully operational and then suddenly one pin would give out. It happened twice today where a perfectly working pin stopped working. on my first one it was D5. I figured it was just one defective board so I used another one from the same batch which I triple checked and it seemed to be all set, but then it gave out as well on D10. I am able to run a simple program and touch the pins to ground and it will recognize that but in both kmk and qmk keyboard firmware they don’t function.
I am quite confused and looking for any advice/guidance. Thank you, and please let me know if you need any more information
So Sounds to me like a power problem? My first guess, What is the power source?
You try a different one? You have a schematic to reference?
What is the BSP your using (look at compiler output , first 3 lines)for it, was it updated?
Check those things and come back let us know.
You’ll need a few posts to paste a picture, but do use the code tags above if you want to post your code " </> " just paste it in there.
I do have a a schematic but as you said I am not able to attach it. the schematic is very similar to a previous design that has worked for me. the only big difference is ti do run traces under the board in this design, and I wasn’t sure if that was an issue.
I am using circuit python as the package, I believe. I tried the most recent one for the xiao rp2040 here Seeed Studio XIAO RP2040 Download however I also tried 9.1.0 and 8.2.3(or something similar) all three of them produce the same issue. Using qmk, which just uploads its own uf2 file directly I saw the same issue.
as for code I am stuggling a bit to get it formatted correctly here but the below program runs in the same circuit py and will print when I connect a pin to ground. this works for all my pins. however once I try using the pin for the software I need it for it is unresponsive. I tried the same code but checking if they are connected to power but that just resulted in them all printing they worked even when not touched. please let me know if you need anything else or if I misunderstood anything you were asking for. thank you again for your time.
`import board
import digitalio
import time
pin_objects = [configure_pin(pin) for pin in pins]
while True:
for pin, pin_obj in zip(pins, pin_objects):
if not pin_obj.value: # LOW means connected to ground
print(f"Pin {pin} valid")
time.sleep(0.1)
`
`import board
import digitalio
import time
pins = [
board.D0, board.D1, board.D2, board.D3, board.D4,
board.D5, board.D6, board.D7, board.D8, board.D9, board.D10
]
def configure_pin(pin):
gpio = digitalio.DigitalInOut(pin)
gpio.direction = digitalio.Direction.INPUT
gpio.pull = digitalio.Pull.UP # Use pull-up resistors to detect ground connection
return gpio
pin_objects = [configure_pin(pin) for pin in pins]
while True:
for pin, pin_obj in zip(pins, pin_objects):
if not pin_obj.value: # LOW means connected to ground
print(f"Pin {pin} valid")
time.sleep(0.1)
`
So I’m thinking is this the correct syntax? Should it be “switch = DigitalInOut(board.Dx)”
What about this example, Here is the page link it’s from See if this will compile and run?
Also check the power supply you are using… and Know sometimes you need to use the pin number and sometimes the GPIO numbers… be aware!
# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""CircuitPython Essentials Digital In Out example"""
import time
import board
from digitalio import DigitalInOut, Direction, Pull
# LED setup.
led = DigitalInOut(board.LED)
# For QT Py M0. QT Py M0 does not have a D13 LED, so you can connect an external LED instead.
# led = DigitalInOut(board.SCK)
led.direction = Direction.OUTPUT
# For Gemma M0, Trinket M0, Metro M0 Express, ItsyBitsy M0 Express, Itsy M4 Express, QT Py M0
switch = DigitalInOut(board.D2)
# switch = DigitalInOut(board.D5) # For Feather M0 Express, Feather M4 Express
# switch = DigitalInOut(board.D7) # For Circuit Playground Express
switch.direction = Direction.INPUT
switch.pull = Pull.UP
while True:
# We could also do "led.value = not switch.value"!
if switch.value:
led.value = False
else:
led.value = True
time.sleep(0.01) # debounce delay
I appreciate the help. I am fairly certain I found the cause. my design had an aluminum plate and I believe I was shocking it with static electricity which was transferring to the xiao. I have never had a problem like that before with the xiao however I created another working model, then went to move it, heard a spark from touching the plate and then the same behavior of the D10 pin ceasing to function occurred. I believe I will have to re design my project with this in mind. Thank you again for your help!