-1

Can I configure an Arduino Uno as a power source to recharge a USB device while being powered by another external power device? I asked ChatGPT for input and it gave me this code:

#include <USBHost.h> // Include USB host library if needed for specific board/shield
void setup() {
 // Initialize USB power if required (for boards with USB Host capability)
 #ifdef USB_HOST_ENABLED
 USBHost.begin(); // Only needed for USB Host shields or boards with host support
 Serial.begin(9600);
 Serial.println("USB power enabled.");
 #endif
 // Enable power to the USB port (depends on board; most Arduinos provide this automatically)
 Serial.println("System ready. USB power is being supplied.");
}
void loop() {
 // Continuously provide power to the USB port
 // No specific commands are needed for simple powering.
 // If needed, monitor the USB or other pins.
 delay(1000);
}

Does this make any sense?

Nick Gammon
38.9k13 gold badges69 silver badges125 bronze badges
asked Dec 27, 2024 at 5:16
1

1 Answer 1

0

You are planning to plug a (say) 12V power source into the Arduino Uno power jack, and then plug something into the USB port, hoping that the Arduino's voltage regulator would provide 5V at the USB port?

I tested with my Uno, and under those circumstances it did indeed provide 5V at the USB port. However, it isn't designed to do that, and USB chargers generally negotiate with the plugged-in device via the data lines. Depending on the device, it may ignore the 5V and not charge.

Also you would be limited to a slow charge rate (say 500 mA) which may result in a slow charge.

answered Dec 27, 2024 at 6:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.