UF_DoC
Posts: 51
Joined: Wed Jul 01, 2015 9:00 am

Using Both PWR and USB in OTG Mode on the Pi Zero

Tue Oct 02, 2018 11:38 am

Good Day,

Would it be a problem to keep the Pi Zero W powered using a Power Supply to the PWR port and at the same time connect the USB port to a PC to function in OTG mode as a Mass Storage for example.

Kind Regards,

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

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Tue Oct 02, 2018 12:07 pm

In such case it is better to cut the 5V wire of the usb cable so the 5V power is separated and does not flow from the PC to the Pi. This topic was discussed here https://www.raspberrypi.org/forums/view ... 8&t=209895 together with other (mostly unrelated) issue.

UF_DoC
Posts: 51
Joined: Wed Jul 01, 2015 9:00 am

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Tue Oct 02, 2018 12:48 pm

Thanks for the link: I guess the relavent post is by @rotwang
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.
For context sake, would someone be able to share a link to the mentioned "spec" as I have looked at the schematic which only illustrates one of the USB ports (J1) and does not explicitly state the two are directly connected.

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

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Tue Oct 02, 2018 1:32 pm

UF_DoC wrote:
Tue Oct 02, 2018 12:48 pm
Thanks for the link: I guess the relavent post is by @rotwang
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.
For context sake, would someone be able to share a link to the mentioned "spec" as I have looked at the schematic which only illustrates one of the USB ports (J1) and does not explicitly state the two are directly connected.
A simple measurement would quell any doubt you have. Otherwise find some real evidence to disprove what has been said many times and never refuted.

User avatar
HawaiianPi
Posts: 5209
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Tue Oct 02, 2018 7:50 pm

Why would you want to do that?

As stated above, the power (+5V) and ground are are connected at both ports, so only use one or the other (for gadget mode you would use the data port).
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

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

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Tue Oct 02, 2018 10:48 pm

HawaiianPi wrote:
Tue Oct 02, 2018 7:50 pm
Why would you want to do that?
Because you may want to remove Zero-as-usb-device from the PC and keep it working?

User avatar
HawaiianPi
Posts: 5209
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Wed Oct 03, 2018 4:17 am

fanoush wrote:
Tue Oct 02, 2018 10:48 pm
Because you may want to remove Zero-as-usb-device from the PC and keep it working?
I can't imagine a scenario where I would want that (but perhaps I just lack imagination).

Regardless, it is not recommended to connect multiple power sources simultaneously. If you want to switch from a USB gadget to a stand alone headless Pi0, then shut it down, remove the PC connection, and then connect it to your power supply. Or you could modify a USB cable for data only (cut the +5V power wire).

However, it's your money and Pi to burn, so you are free to ignore recommendations. It may work fine, but recommendations are there to avoid worst case scenarios, like a burned out Pi and damage to the USB port on my PC. What are the odds of that happening? I have no idea (probably low), but for me it's not worth the risk simply to avoid the slight inconvenience of shutting down and rebooting a Pi0.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

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

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Wed Oct 03, 2018 7:28 am

HawaiianPi wrote:
Wed Oct 03, 2018 4:17 am
fanoush wrote:
Tue Oct 02, 2018 10:48 pm
Because you may want to remove Zero-as-usb-device from the PC and keep it working?
I can't imagine a scenario where I would want that (but perhaps I just lack imagination).
....
for me it's not worth the risk simply to avoid the slight inconvenience of shutting down and rebooting a Pi0.
Zero can act as usb device. Zero is booted into raspbian linux from sd card mounted read/write. You are configuring zero to be mass storage device or usb serial or usb network. You want to test it with computer. Do you want to develop it in a way that you insert it into pc usb port, wait for Zero to boot and set your preferred usb device configuration (probably in /etc/rc.local), then after testing you need somehow login to the zero to shut it off properly so the sd card is not corrupted and only then remove it from PC usb port? Imagine doing this repeatedly. Also unless you set it up properly first time as networking device with ssh or usb serial device with getty running you actually need another usb serial adapter to zero serial pins 14,15 to shut it down as you have no keyboard.
HawaiianPi wrote:
Wed Oct 03, 2018 4:17 am
Or you could modify a USB cable for data only (cut the +5V power wire).
Yes, that is the very simple solution that was suggested. Also one could just cover power pin with tape in usb male to female adapter/extender and use it with unmodified cable if this is not permanent solution.

User avatar
Imperf3kt
Posts: 3246
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Wed Oct 03, 2018 7:43 am

fanoush wrote:
Wed Oct 03, 2018 7:28 am
HawaiianPi wrote:
Wed Oct 03, 2018 4:17 am
fanoush wrote:
Tue Oct 02, 2018 10:48 pm
Because you may want to remove Zero-as-usb-device from the PC and keep it working?
I can't imagine a scenario where I would want that (but perhaps I just lack imagination).
....
for me it's not worth the risk simply to avoid the slight inconvenience of shutting down and rebooting a Pi0.
Zero can act as usb device. Zero is booted into raspbian linux from sd card mounted read/write. You are configuring zero to be mass storage device or usb serial or usb network. You want to test it with computer. Do you want to develop it in a way that you insert it into pc usb port, wait for Zero to boot and set your preferred usb device configuration (probably in /etc/rc.local), then after testing you need somehow login to the zero to shut it off properly so the sd card is not corrupted and only then remove it from PC usb port? Imagine doing this repeatedly. Also unless you set it up properly first time as networking device with ssh or usb serial device with getty running you actually need another usb serial adapter to zero serial pins 14,15 to shut it down as you have no keyboard.
HawaiianPi wrote:
Wed Oct 03, 2018 4:17 am
Or you could modify a USB cable for data only (cut the +5V power wire).
Yes, that is the very simple solution that was suggested. Also one could just cover power pin with tape in usb male to female adapter/extender and use it with unmodified cable if this is not permanent solution.
To boot the Pi in Gadget mode, you don't insert the microSD card. There is no Linux running on the Pi.

Personally though, I don't think this would be an issue so long as both cables were only plugged into the same device/computer and from the same bank of USB ports, since the PSU in a PC will power several of the USB ports from the same supply rail.
55:55:44:44:4C
52:4C:52:42:41

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

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Wed Oct 03, 2018 8:42 am

Imperf3kt wrote:
Wed Oct 03, 2018 7:43 am
To boot the Pi in Gadget mode, you don't insert the microSD card. There is no Linux running on the Pi.
Check this https://randomnerdtutorials.com/raspber ... board-hid/ guide that started the topic discussing this 'powering zero while being usb device' issue previously.

User avatar
HawaiianPi
Posts: 5209
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Wed Oct 03, 2018 8:44 am

Imperf3kt wrote:
Wed Oct 03, 2018 7:43 am
To boot the Pi in Gadget mode, you don't insert the microSD card. There is no Linux running on the Pi.
That's news to me? I've always used a specially configured Raspbian image for USB Gadget mode. Got a link to no-SD Gadget mode?
Imperf3kt wrote:
Wed Oct 03, 2018 7:43 am
Personally though, I don't think this would be an issue so long as both cables were only plugged into the same device/computer and from the same bank of USB ports, since the PSU in a PC will power several of the USB ports from the same supply rail.
The way I interpreted the OP was that it would be a separate PSU on the power port, with a PC USB port connected to the data port. So 2 different power sources (not 2 USB cables from the same source).
UF_DoC wrote:
Tue Oct 02, 2018 11:38 am
Good Day,

Would it be a problem to keep the Pi Zero W powered using a Power Supply to the PWR port and at the same time connect the USB port to a PC to function in OTG mode as a Mass Storage for example.

Kind Regards,
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

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

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Wed Oct 03, 2018 9:44 am

Imperf3kt wrote:
Wed Oct 03, 2018 7:43 am
To boot the Pi in Gadget mode, you don't insert the microSD card. There is no Linux running on the Pi.
Both of those statements are 100% untrue.

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

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Wed Oct 03, 2018 1:33 pm

HawaiianPi wrote:
Wed Oct 03, 2018 8:44 am
That's news to me? I've always used a specially configured Raspbian image for USB Gadget mode. Got a link to no-SD Gadget mode?
https://bennuttall.com/raspberry-pi-zero-gpio-expander/
https://www.raspberrypi.org/blog/gpio-expander/
https://github.com/raspberrypi/usbbootgui
https://github.com/raspberrypi/gpioexpander
you can send any payload over usb, the gpio expander is small buildroot based linux userspace with usb network and usb serial devices and gpio library

hippy
Posts: 6776
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Wed Oct 03, 2018 3:00 pm

HawaiianPi wrote:
Wed Oct 03, 2018 4:17 am
fanoush wrote:
Tue Oct 02, 2018 10:48 pm
Because you may want to remove Zero-as-usb-device from the PC and keep it working?
I can't imagine a scenario where I would want that (but perhaps I just lack imagination).
I'm planning on doing that. It's the main reason I got back into looking at booting a diskless Zero from Windows.

I want a Pi, without an SD Card, to be an always on status display, and need some way to load code and have that remain running after disconnecting from the PC.

UF_DoC
Posts: 51
Joined: Wed Jul 01, 2015 9:00 am

Re: Using Both PWR and USB in OTG Mode on the Pi Zero

Thu Oct 04, 2018 1:30 pm

@drgeoff, Thanks for the suggestion, I have used a multi-meter and it appears to be a direct connection between the two. I require the clarification as the Pi Zero (not W) schematic shows the PWR USB pulled to "Vcc" and the OTG USB pulled to "VBUS".

None the less. I will cut the Vcc line of the OTG cable as suggested.

@HawaiianPi, Yes you understood correct, I would be having 2 separate power sources, 1 being a 5V PSU (into the PWR port) and the other being the 5V supplied by the host machine as Vusb 5V (into the OTG port).

@Fanoush, "SD-less" seams to still be primitive and would not be relevant in this context, but thanx for the interesting share.

Return to “General discussion”