1
\$\begingroup\$

I am creating a PCB where a ESP32-S3-WROOM-1 sits on, which shall be powered by an external power supply (and a NCP1117 3.3V LDO) and not by USB. However, I will use USB to flash the ESP32, so the PCB will have a USB socket which connects to the cip.

However, there is a risk that both USB and power adapter are plugged in and the same time. Also, as per specification, USB will not deliver more than 100mA if the device has not been registered at the host and I don't want to handle that, even if I know, that in real world almost every PC will deliver way more than 100 mA. Additionally, the inrush current for USB as per specification must be not more than 10µF which might be a problem if I want to use larger capacitors for power stabilization.

I therefore wonder if I can simply cut-off VCC of the USB. Can it then still transmit the data betwen D-/D+ and GND?

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

However, there is a risk that both USB and power adapter are plugged in and the same time. Also, as per specification, USB will not deliver more than 100mA if the device has not been registered at the host and I don't want to handle that, even if I know, that in real world almost every PC will deliver way more than 100 mA.

The safest thing to do here is to connect the USB+5v to the main system power with a Schottky diode. If the device is powered the diode will prevent current draw from USB. If it's unpowered you'll get current from USB and avoid damaging the USB port by driving it unpowered.

If your device can program itself using 100mA, then you are done. If it can't you have a few options:

  1. Instruct the user to power the device when programming it. It'll work even if they don't, but you're following the spec.

  2. Use USB-C where you can receive 1.5A using resistors on the CC lines. See: Is it sufficient to put 5.1k pulldowns on CC1 and CC2 of USBC to get 5V 1.5A?

Personally I would use USB-C now that USB2-only C jacks cost a few cents more than micro-B.

\$\endgroup\$
3
  • \$\begingroup\$ These are weird suggestions. If the device is unpowered and you plug it into PC, then it will try to draw all the current it needs from PC. Now if the ESP can work with 100mA only, you could have a separate regulator for ESP only that can take input from USB or external supply, and ESP will then enable the second regulator only if external supply is present or it may enable automatically. And you cannot request 1.5A with resistors on CC lines - only supplies can advertize support for 1.5A, and your device needs to be able to detect it, it cannot request. \$\endgroup\$
    – Justme
    Commented Jun 15 at 18:23
  • \$\begingroup\$ @Justme I'll change "request" to "receive". Otherwise I don't see what is weird about my suggestion, this is actually what a lot of externally powered USB hubs do. \$\endgroup\$ Commented Jun 15 at 19:03
  • \$\begingroup\$ The ESP would have to sense how much is available and act accordingly - in practice if you want to assume your device is connected to a PC and it is a USB2 device, it's 100mA unless negotiated otherwise. You can draw more if (a) negotiated via USB2 or USB3 or (b) negotiated via PD (not going to happen without PD chipset) or (c) measured how much is available from CC voltage. \$\endgroup\$
    – Justme
    Commented Jun 15 at 20:02
0
\$\begingroup\$

If you simply cut 5V from USB and power the ESP separately, it may work.

So you can do that.

But it will also violate USB specs.

Which is why you should not do it.

Any device that is self-powered (instead of bus-powered) must wait for 5V from host before activating the USB interface and signal the speed by pulling up one of the data wires.

If the PC is unpowered, and your ESP can't detect that, it will pull up one of the data wires towards the unpowered PC.

Also you can't assume that user will connect directly to a PC. If you have a hub, which already has multiple devices, then obviously the next device plugged in may exceed the port rating, so that is why all devices must obey the rules (unless you make the device only for yourself as a hobby and when making an error you may either end up with a damaged PC, damaged hub, losing data on USB hard drive connected to same hub, etc, so it's really up to you if you want to build devices that are outside the specs).

And if a 10uF capacitor is not enough for stabilization at 5V VBUS side, it is highly likely you are doing something that's outside the specs anyway. Any modern regulator, linear or switch mode, should work stably with less than 10uF. If it's not enough for stable enough use, you may have damaged cable or damaged USB supply source.

\$\endgroup\$
3
  • \$\begingroup\$ But how could I solve this issue then? \$\endgroup\$ Commented Jun 15 at 15:57
  • \$\begingroup\$ @Tintenfisch I have read, that the USB device stack offers to declare a GPIO pin as VBUS monitor pin if connected to a VBUS voltage divider. See tinyusb_config_t struct and vbus_monitor_io field. Not sure if this is available for the S3, for S2 it is. \$\endgroup\$
    – Jens
    Commented Jun 15 at 16:08
  • 1
    \$\begingroup\$ @Tintenfisch Most chips and MCUs have a dedicated pin that control the chip to disable USB section and the 5V VBUS is detected with this pin. Some chips and MCUs can just use any GPIO pin for this and can read this pin and control the USB section in software. Whether the ESP has one is unknown to me. Especially if you plan to use the USB bootloader, it may not have support for detecting VBUS. But of course if you intend to only go to bootloader when PC is providing 5V, then you could use the 5V to go to bootloader anyway, and it will not use USB at all in your own software. \$\endgroup\$
    – Justme
    Commented Jun 15 at 16:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.