I am running 4 meters of 12V LED strip lights off of a USB-C power bank using a HUSB238. This results in ~24 W (2 A @ 12 V) and works fine for my use case. To modulate the intensity, I have an ATtiny85 with a voltage regulator (currently prototyped via a DigiSpark) powered via the same 12 V rail. The ATtiny85 produces a PWM signal paired with a logic-level MOSFET. The schematic is roughly:

Setup Schematic


How can I add an on/off switch to this setup? Specifically, I am looking to take advantage of USB-C's cold-plugging, such that when in the off position, all current draw is effectively eliminated (as if the UFP is disconnected). The use case being to preserve power bank capacity, to make it last as long as possible.

I would like the solution to be agnostic to the power bank (DFP/source).

My background on USB-C / PD spec is as deep as: TI's "A Primer on USB Type-C® and USB Power Delivery Applications and Requirements".

I have seen cables like below when working with various Raspberry Pi kits. However, I haven't found anything that appears to be PD compatible. (A modified cable could be an option - open to others).

EDIT: I reached out to CanaKit and asked if they were planning a PiSwitch that will be compatible with the Raspberry Pi 5 (which takes 5 V/5 A via USB-C PD) - they said a new version is forthcoming which would "be PD compatible" in the following weeks. This "device"/cable would be one example of a solution to the problem.

Original cable example:

Example USB C cable that isn't PD compatible


3 Answers 3


From the discussion, the most straightforward implementation would be to trigger a cable removal condition by opening the CC1 & CC2 lines. An unpowered approach would be to add a mechanical DPST switch for both CC lines. This DPST switch on the CC1/CC2 lines could go:

  1. In a USB-C cable assembly that otherwise complies with USB-C PD spec (plug to plug).
  2. In a "vendor-specific USB device with captive Type-C cable", see last paragraph in section 3.1.2, and corresponding section 3.4.3. Likely to be implemented in the new PiSwitch that's compatible with RPi5.
  3. In the device circuit itself, between the USB-C receptacle and the HUSB238 (or similar PD sink IC).

A 3PST switch may be necessary if immediate removal from VBUS is also required. Type C Spec "4.11.2 Timing Parameters" specifies 0ms - 650ms for VBus to drain to vSafe0v.

  • \$\begingroup\$ At least disconnecting CC pins won't be enough with HUSB238. Because if the power supply or power bank supports also other charging communication protocols like BC over the D+/D- lines, or is a dummy 5V source, disconnecting CC pins that are not even used will do nothing. \$\endgroup\$
    – Justme
    Oct 8, 2023 at 10:35

How about disconnecting/Connecting the gate resistor R2 via a ON/OFF switch and the MOSFET will not be ON if the switch disconnects the R2.

Will that be a solution?


These cables induce noise. Connect one via a portable LCD and watch the static in the screen


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.