botpeddler
Posts: 11
Joined: Thu May 25, 2017 8:13 pm

Zero W as HID device draws too much power

Mon Apr 02, 2018 10:06 pm

Hi,
I followed this tutorial and got my Pi Zero W working as an HID keyboard with python: https://randomnerdtutorials.com/raspber ... board-hid/
I'd like it to work with my iphone using a camera adapter (lightning to USB) cable. However any time I plug the phone via the camera adapter into the data USB port, even when I have another 5V adapter plugged in to the power USB port, the phone says "Cannot Use Device: The connected device requires too much power." Does anyone have any ideas on how to stop this?
I'm thinking either a resistor on the 5V line between the phone and pi, or I might try a powered hub in between the two.
Thanks

drgeoff
Posts: 10236
Joined: Wed Jan 25, 2012 6:39 pm

Re: Zero W as HID device draws too much power

Mon Apr 02, 2018 10:20 pm

I don't know anything about iphones but I can guarantee that a resistor is not going to help.

botpeddler
Posts: 11
Joined: Thu May 25, 2017 8:13 pm

Re: Zero W as HID device draws too much power

Tue Apr 03, 2018 4:14 am

Can you explain why not? I was thinking something like this http://www.dummies.com/programming/elec ... -resistor/

fanoush
Posts: 504
Joined: Mon Feb 27, 2012 2:37 pm

Re: Zero W as HID device draws too much power

Tue Apr 03, 2018 5:51 am

It can be also software issue. Check your Zero usb config how much power you advertise to draw over USB bus (MaxPower), reduce it to 100mA or even lower if you have it powered externally.

EDIT:
the linked tutorial has this line

Code: Select all

echo 250 > configs/c.1/MaxPower
so that value may be too high for the phone to accept. However lowering it below real current draw of the device may cause Zero or phone to fail.
Last edited by fanoush on Tue Apr 03, 2018 7:24 am, edited 1 time in total.

User avatar
Gavinmc42
Posts: 4301
Joined: Wed Aug 28, 2013 3:31 am

Re: Zero W as HID device draws too much power

Tue Apr 03, 2018 6:14 am

Perhaps iPhones only allow 100ma devices?
Zero W's probably identify as 500ma devices.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

rotwang
Posts: 243
Joined: Sat Dec 07, 2013 1:12 pm

Re: Zero W as HID device draws too much power

Tue Apr 03, 2018 10:20 am

Rule 1 for Pi Zero's -- Either power it from the USB Data port OR from the power port NEVER BOTH.
Read the specs for the zero, the 5v GPIO pins, the 5V USB data pin and the 5v USB power pin are all connected directly together.
I suggest you devote your energies to finding out what Apple's idea of USB is this week.
botpeddler wrote:
Mon Apr 02, 2018 10:06 pm
Hi,
I followed this tutorial and got my Pi Zero W working as an HID keyboard with python: https://randomnerdtutorials.com/raspber ... board-hid/
I'd like it to work with my iphone using a camera adapter (lightning to USB) cable. However any time I plug the phone via the camera adapter into the data USB port, even when I have another 5V adapter plugged in to the power USB port, the phone says "Cannot Use Device: The connected device requires too much power." Does anyone have any ideas on how to stop this?
I'm thinking either a resistor on the 5V line between the phone and pi, or I might try a powered hub in between the two.
Thanks

fanoush
Posts: 504
Joined: Mon Feb 27, 2012 2:37 pm

Re: Zero W as HID device draws too much power

Tue Apr 03, 2018 10:48 am

rotwang wrote:
Tue Apr 03, 2018 10:20 am
Read the specs for the zero, the 5v GPIO pins, the 5V USB data pin and the 5v USB power pin are all connected directly together.
So if powered externally the easiest is probably to cut 5V line from the phone to the pi completely (instead of using any resistor). Thin/tiny USB OTG adapter with 5V pin covered with tape and normal microusb data cable attached to it might do the trick.

botpeddler
Posts: 11
Joined: Thu May 25, 2017 8:13 pm

Re: Zero W as HID device draws too much power

Tue Apr 03, 2018 10:24 pm

Thanks for all the suggestions! I didn't realize the iphone went by what was reported by the device as opposed to what it was actually drawing.
I read the iphone could handle 160ma and the zero W uses 160ma with wifi, but I tried changing it to 160 but it still said too much power. It's probably a 100ma limit.
Didn't know that about not using both ports -- but I'm curious, if both the iphone and zero are expecting 5V, and I assume they have common ground, what's the problem in having two power sources? I've had other circuits with multiple power sources hooked up this way.

botpeddler
Posts: 11
Joined: Thu May 25, 2017 8:13 pm

Re: Zero W as HID device draws too much power

Tue Apr 03, 2018 10:30 pm

Ok now I'm reading if the voltages are different they'll equalize and backfeed.
https://www.eevblog.com/forum/beginners ... ne-to-usb/
I guess I'll try fanoush's suggestion.
Thanks!

botpeddler
Posts: 11
Joined: Thu May 25, 2017 8:13 pm

Re: Zero W as HID device draws too much power

Tue Apr 03, 2018 10:32 pm

It sounds like I could also cut the 5v trace to the data port, or cut the 5v wire in the adapter. I'll probably cut the wire. http://forums.reprap.org/read.php?158,197972

fanoush
Posts: 504
Joined: Mon Feb 27, 2012 2:37 pm

Re: Zero W as HID device draws too much power

Wed Apr 04, 2018 6:48 pm

botpeddler wrote:
Tue Apr 03, 2018 10:24 pm
I didn't realize the iphone went by what was reported by the device as opposed to what it was actually drawing.
Good explanation how it works is here
http://dangerousprototypes.com/docs/Des ... d_MaxPower
100ma is minimum always allowed, anything above can be denied by usb host in software but real current is not limited nor measured, device is expected to draw over 100mA only when allowed (which usb host does by enabling specific device configuration - MaxPower value is part of configuration description)

so technically Pi Zero does not comply to usb device rules if it draws over 100mA at boot time without first negotiating its configuration with higher MaxPower with usb host

botpeddler
Posts: 11
Joined: Thu May 25, 2017 8:13 pm

Re: Zero W as HID device draws too much power

Thu Apr 05, 2018 6:18 am

Cutting the red 5v wire and setting MaxPower to 100 worked! Thanks all!

Return to “Troubleshooting”