Feather external power issue

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
soulenya
 
Posts: 3
Joined: Sat Sep 18, 2021 9:33 pm

Feather external power issue

Post by soulenya »

I have a feather RP2040 with circuitpython that I am using as a basic HID keyboard with buttons to various GPIO inputs for different keystrokes. I also have a 128x64 OLED connected through stemma displaying a message when each keystroke is made.

The issue I am having is when the board is connected via USB to my laptop, everything works perfectly. Code executes with no issues. However when I try to power via usb adapter, I get two red LED blinks in succession on the Neopixel, and the code will not run. I have tried 5v 1a, 5v 2a, 5v 3a, different cables, different USB adapters, i have also tried running it off of a 3.3v 500ma LiPo battery with no success.

Without 100% certainty, I am assuming two red LED blinks means a power supply issues, but I am confused why it works via computer USB and not external adapter power.

Any input would be helpful. Code below:

import time
import board
import digitalio
import usb_hid
import displayio
import terminalio
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
from adafruit_display_text import label
import adafruit_displayio_ssd1306

# Create the keyboard object
kbd = Keyboard(usb_hid.devices)

# Define the buttons and their corresponding keycodes
buttons = [
{"pin": board.D5, "keycode": Keycode.K, "name":
[" YES/OK ", "****************"], "pressed": False},
{"pin": board.D6, "keycode": Keycode.N, "name":
[" NO ", "!!!!!!!!!!!!!!!!"], "pressed": False},
{"pin": board.D9, "keycode": Keycode.ESCAPE, "name":
[" ESC/BACK ", "^^^^^^^^^^^^^^^^"], "pressed": False},
{"pin": board.D10, "keycode": Keycode.RIGHT_ARROW, "name":
[" NEXT PAGE ", "------------>>>>"], "pressed": False},
{"pin": board.D11, "keycode": Keycode.LEFT_ARROW, "name":
[" PREVIOUS PAGE ", "<<<<------------"], "pressed": False},
]

# Configure the buttons as input
for button in buttons:
button["button_obj"] = digitalio.DigitalInOut(button["pin"])
button["button_obj"].direction = digitalio.Direction.INPUT
button["button_obj"].pull = digitalio.Pull.UP

# Initialize display
displayio.release_displays()
i2c = board.I2C()
display_bus = displayio.I2CDisplay(i2c, device_address=0x3D)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=64)
splash = displayio.Group() # limit the splash group to two elements
display.show(splash)

# Create two Labels to display the button states
text_area_1 = label.Label(terminalio.FONT, text='', color=0xFFFF00, x=16, y=16)
text_area_2 = label.Label(terminalio.FONT, text='', color=0xFFFF00, x=16, y=48)
text_area_1.anchor_point = (0.5, 0.5)
text_area_2.anchor_point = (0.5, 0.5)
splash.append(text_area_1)
splash.append(text_area_2)

# Add a variable to keep track of the last button pressed
last_button = None

def update_display(last_button, text_area_1, text_area_2, display, splash):
# Update the display based on the last button pressed
if last_button is not None:
text_area_1.text = last_button["name"][0]
text_area_2.text = last_button["name"][1]
display.show(splash)
return None
return last_button

DEBOUNCE_TIME = 0.05 # Debounce time in seconds

for button in buttons:
button["debounce"] = time.monotonic()

while True:
for button in buttons:
if button["button_obj"].value and button["pressed"]:
# Button is released, so release the corresponding keycode
kbd.release(button["keycode"])
button["pressed"] = False
# Update the display immediately
text_area_1.text = ''
text_area_2.text = ''
display.show(splash)

elif not button["button_obj"].value and not button["pressed"]:
# Button is pressed for the first time, so press the corresponding keycode
# But only if the debounce time has passed
if time.monotonic() - button["debounce"] >= DEBOUNCE_TIME:
kbd.press(button["keycode"])
button["pressed"] = True
button["debounce"] = time.monotonic() # Update the debounce time
last_button = button # Save the button that was pressed

# Call the function to update the display
last_button = update_display(last_button, text_area_1, text_area_2, display, splash)

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: Feather external power issue

Post by dastels »

If it's working as a HID keyboard, why are you trying to run it without a USB connection?

FWIW it's probably crashing trying to set up the Keyboard(usb_hid.devices).

Dave

User avatar
soulenya
 
Posts: 3
Joined: Sat Sep 18, 2021 9:33 pm

Re: Feather external power issue

Post by soulenya »

I will eventually be connecting it to my raspberry pi 4 via usb, I am more curious than anything as to why it won’t run with external power.

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: Feather external power issue

Post by dastels »

It's a USB HID device. It needs a USB connection to function. It's not the power source that matters here, it's the lack of a USB data connection.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”