PD Buddy Sink

USB Power Delivery for everyone

Similar projects worth following
USB Power Delivery is a cool standard for getting lots of power—up to 100 W—from a USB Type-C port. Being an open standard for supplying enough power to charge phones, laptops, and just about anything else under the sun, USB PD is poised to greatly reduce the amount of e-waste produced worldwide from obsolete proprietary chargers. Unfortunately, like all USB standards, it's quite complex, putting it out of reach of the average electronics hobbyist.

PD Buddy Sink solves this problem, letting any hacker or maker use USB PD in their projects. Think of it as a smart power jack. To use it, first configure a voltage and current via the USB configuration interface. Then whenever the Sink is plugged in to a USB PD power supply, it negotiates the power your project needs and provides it on the output connector.

The Idea

One day I was digging through a box of wall warts, trying to find one with the voltage I needed at a high enough current, and with the right output connector. Untangling cords and checking labels was taking a while, and I started thinking. "If I could use USB Power Delivery, I wouldn't ever have to do this again." Since USB PD power supplies can provide a multitude of voltages at sizable currents, all you'd need is a little circuit board that takes the place of a power jack and tells the power supply what your project needs.

I searched the web, and to my surprise, no such device was available! I realized that I would have to create it myself, so I started figuring out the device's requirements. It would be a small (<2 in²) circuit board with a USB Type-C connector on one side and a screw terminal block for power output on the other. When plugged in, an on-board microcontroller would negotiate the power for your project. Originally I thought it could be configured with a few jumpers, but after reading the relevant parts of the USB Power Delivery standard I realized that a more fine-grained way of setting current would be necessary. For safety, the output would have to be controlled by a MOSFET so as to only turn on once negotiation is complete.

A couple days later, I had a hardware design. A couple weeks later, I built a prototype, and the first PD Buddy Sink was born.

PD Buddy Sink

PD Buddy Sink is a smart power jack for USB Power Delivery. Configure it with the voltage and current your project needs, then plug it into any USB PD power supply with a high enough power capability. It negotiates with the power supply and turns on its output, giving your project up to 3 A at 5, 9, or 15 V, and up to 5 A at 20 V.

PD Buddy Sink is simple to configure. Just plug it into a computer while holding the setup button, and connect to the USB CDC console interface. Alternatively, use the (still experimental) configuration GUI.

Project Status


Initial PCB prototypes (0.1) were developed in early February 2017, and built mid February. A few schematic changes were necessary, but were nothing a little point-to-point wiring couldn't fix on the prototype boards. A revised board (v0.2) has been developed and tested incorporating these fixes and some other improvements.

Firmware has been developed supporting most use cases of the PD Buddy Sink. It features a USB serial console interface for editing and saving configuration, and is able to negotiate with power supplies to request fixed voltages and currents. An option for GiveBack is available, which allows the power supply to reduce power temporarily if another device needs more. It is recommended to enable GiveBack if the Sink is being used to charge a battery. To the best of my knowledge, the firmware is compliant with the USB Power Delivery Specification, Revision 2.0, Version 1.3.

The firmware's configuration API has been documented. This API can be used to produce libraries and applications which allow configuration of the PD Buddy Sink.

I have written a small Python library for configuring the PD Buddy Sink, providing both direct and abstracted access to the serial configuration API. A basic configuration GUI has been implemented using this library and GTK+. It allows editing and saving configuration in a more user-friendly way than the console interface. It also displays a list of all connected PD Buddy devices, in case several are plugged in to the computer at once.

In Progress

The firmware at this point is essentially API-stable. No formal release has been made yet though, so this is not a guarantee. Before making the first release of the firmware, I'd like to get a USB PID for the project from I've been waiting patiently for this for several weeks. Once a PID is assigned, I'll update the firmware and GUI to use it, and release firmware v1.0, representing a guaranteed API-stable firmware.

A smaller, four-layer circuit board (v0.3) is in development, intended for automated assembly....

Read more »

  • 1 × PD Buddy Sink v0.2 PCB 0.8 or 1.0 mm thick, 2 oz copper preferred
  • 1 × STM32F072CBT6 ARM Cortex-M0 Microcontroller
  • 1 × FUSB302BMPX USB PD Revision 2.0 PHY
  • 1 × 12401548E4#2A USB Type-C Hybrid Receptacle
  • 1 × DMP4015SSS Discrete Semiconductors / Power Transistors and MOSFETs

View all 21 components

  • Python Configuration Library

    Clayton G. Hobbs05/11/2017 at 22:14 0 comments

    Looking over the GUI code recently, I realized what a mess it was. This was partially because of the cobbled-together way it communicated with the PD Buddy Sink. I decided to make a better interface for configuring the Sink from Python code. It made sense to do that as a separate Python package, mostly because I might want to write a GUI with some other library for better portability than GTK+ offers. After a day or so of writing the library and accompanying unit tests, I made the first release of pd-buddy-python.

    The GTK+ GUI now uses this library rather than pySerial for communication with the Sink. Several portions of code were greatly simplified in the process, notably configuration loading and testing if the "Save" button should be visible. I'm very happy with the new library, and all the possibilities it opens. Expect a more portable configuration interface soon!

  • The First v0.2 Board Assembled

    Clayton G. Hobbs05/06/2017 at 20:37 0 comments

    The first three v0.2 PCBs just arrived from @oshpark today. I was excited to build one, so I ran the 1.5 miles to the mailbox and back to burn off some excess energy. When I got back, I opened the envelope and found these lovely little pieces of FR4.

    Then began the arduous process of hand-assembling a board with a 0.5 mm pitch QFN and USB Type-C connector. Not too scary, especially with a vacuum pick-up tool, but still not easy.

    After about two hours of soldering, I had a beautiful board assembled. Those 10 kΩ and 2 kΩ SMD resistors look almost exactly the same, don't they?

    I bought STM32F072C8T MCUs for these instead of the STM32F072CBT I used on the v0.1 boards. They're almost exactly the same, except the chip on the new board has only 64 KiB of flash instead of 128 KiB. Since the firmware is only about 28 KiB, the smaller chip still has plenty of room for expansion, and costs less too. I had to make a few changes to the firmware to support the smaller flash, but that went very smoothly.

    All in all, I'm really happy with how the new board came out. It's a fairly minor revision compared to what v0.3 will bring, but it has a lot of little improvements that make the Sink so much nicer. The USB connector hangs off the board farther, so enclosure walls can be thicker. The current carrying traces are thicker, so the board shouldn't even get warm when it's carrying 5 A. Plus, no rework is needed in the output circuit, so that's nice.

    Onward to v0.3!

  • GiveBack Support Added

    Clayton G. Hobbs04/29/2017 at 20:51 0 comments

    I just pushed commits for both the firmware and configuration GUI to add GiveBack support. GiveBack is a mechanism defined in the USB Power Delivery spec that allows the power supply to temporarily reduce power to one device in order to provide more to another. The implementation in the PD Buddy Sink works by removing power from the output when the power supply asks the Sink to reduce power.

    "Why would I want my power supply to stop powering my device?" I hear you cry. GiveBack is largely intended for use in non-critical applications, such as battery charging. If a laptop is charging its battery from a USB PD powered hub while sharing power with an external hard drive, the hub power supply's limit could be approached during normal operation. If the hard drive needs to spin up, it will require more power than normal, which could overload the power supply. Making the laptop stop charging for a second while the hard drive spins up allows all devices involved to keep running without drawing too much power.

    In short, if you're using a PD Buddy Sink to charge a battery, it would be polite to enable GiveBack to allow power supplies to manage their loads more effectively.

  • Why the Output MOSFET Is Important

    Clayton G. Hobbs04/23/2017 at 01:30 0 comments

    Or: Why the USB-C Easy Bake Oven Is Dangerous

    This is just a quick little post to explain why the PD Buddy Sink has a MOSFET to switch its output. There are several reasons, but they all boil down to the same thing: without it, a device like the USB-C Easy Bake Oven would be dangerous.

    The PD Buddy Sink has a MOSFET controlling its output. It turns on when the Sink establishes an Explicit Contract for the power configured, and remains off if the power supply cannot provide the power you wanted. One obvious consequence of this is that your project only gets the voltage you configured the Sink to request, preventing any possible undervoltage from occurring.

    More importantly though, this MOSFET is essential to the safe operation of any device utilizing the PD Buddy Sink. Take for example the USB-C Easy Bake Oven made by Jason Cerundolo. It's a modified Easy Bake Oven that gets its power from USB Power Delivery, made using an Arduino and a breakout for the FUSB302B (the same USB PD PHY used in the PD Buddy Sink). Jason modified the resistive heating element to dissipate 80 W at 20 V, producing enough heat to bake cookies.

    Time for some analysis. His heating element is a (20 V)² / 80 W = 5 Ω resistor. In his system there's no circuitry to switch it on and off, so it's always connecting VBUS to GND. Before any negotiations are done, it draws 1 A at 5 V. For a USB PD supply like the one he used, it's entirely likely that nothing bad is happening yet: it probably advertises a Type-C Current of 3 A, so it's safe to draw up to that much current at 5 V without doing any PD negotiations. I'm not sure if Jason's firmware checks this however, and even if it did, it would have no way to stay within the limits of the advertised current.

    Read more »

  • Application: USB PD Bench Power Supply

    Clayton G. Hobbs04/18/2017 at 20:29 0 comments

    Inspired by a comment, I put a PD Buddy Sink in a box with a DPH3205 buck-boost power supply module to make a USB-powered bench supply. Check it out on its project page!

  • PCB v0.2 Released!

    Clayton G. Hobbs04/16/2017 at 16:34 0 comments

    Get it while it's hot!

    Finally, a hand-solderable Sink that doesn't need rework! The output circuit has been fixed, so no cutting traces and point-to-point wiring should be necessary.

    Other changes:

    Read more »

  • Support for Type-C Current Added

    Clayton G. Hobbs04/13/2017 at 22:44 0 comments

    The USB Type-C spec defines a much simpler mechanism than Power Delivery for ports to advertise their current capability. Type-C Current works by just putting a different pull-up resistor on the CC line of the Type-C connector to indicate different source currents. Combined with the pull-down in the sink, this creates a voltage that indicates how much current the sink can draw from the source. Table 4-27 from the USB Type-C spec shows these voltages.

    I just pushed a commit adding support for Type-C Current as a fallback when Power Delivery communications fail. This means the PD Buddy Sink is now capable of getting up to 3 A at 5 V for your project even from non-PD power supplies.

  • Prototype Configuration GUI

    Clayton G. Hobbs03/30/2017 at 01:51 0 comments

    I've now created a prototype configuration GUI with GTK+ in Python. It should be able to run on OS X and Windows, but I haven't tested it on anything other than Linux. If you were paying close attention, you might've seen the link to the Git repository appear in the sidebar a couple days ago, but now it's working well enough that I feel like writing about it.

    The GUI detects all the PD Buddy Sink devices connected to the computer and presents them in a list (which updates automatically!). Each list entry has a button to identify the device: click the button and the Sink's LED blinks fast for a couple seconds. The GUI allows you to easily configure each device's voltage and current. The settings are loaded from the device when it's selected from the device list, and new settings can be saved at the press of a button.

    There are still a few bugs to iron out (mostly regarding serial port permissions and device disconnection), but I'm becoming increasingly happy with this little interface.

  • Wrote a Console Configuration Interface

    Clayton G. Hobbs03/25/2017 at 03:13 0 comments

    I just put the finishing touches on the initial PD Buddy Sink console configuration interface. It's based on the ChibiOS command shell, but with some changes I feel make it much nicer. First, it has PD Buddy branding, rather than the ChibiOS branding the original had. The help text has been improved, providing a short synopsis for each command rather than simply a list of commands. There's also no way to exit the shell, because I really don't know why that would be necessary in this application. After all, when you're done configuring the Sink and your changes have been written to flash, there's no harm done by just unplugging it.

    The new code has been pushed to the main firmware repository. This brings the PD Buddy Sink much closer to being fully functional, so I'm really happy about it. Next, I think I'll work on the GUI before returning to the firmware.

    Some implementation details follow, as well as next steps for the firmware.

    As is common with Cortex-M microcontrollers, there's no EEPROM here, only flash. That means the configuration has to be stored somewhere in flash, so the last page makes sense to me. Only a few bytes of flash are needed to store the configuration, but since I had to reserve a whole 2 KiB page for it anyway, I figured I might as well go ahead and do some wear leveling. The page is used as an array of 128 structs, each beginning with a magic value indicating its status. An empty struct is identified by the magic value 0xFFFF (naturally), the one that currently stores the configuration is identified by 0xBEEF, and old ones that aren't being used right now are 0x0000. As the configuration is updated, the page fills from low to high addresses, until eventually it's completely full. Then on the next update, it's automatically erased before the new configuration is written. The flash in the STM32F0s is rated at a minimum of 10k cycles, so with my wear leveling, the Sink can be configured at least 1,280,000 times before the flash might wear out. That should be far more than anyone ever needs.

    There's enough space left over in the struct for a few new features as well, but they're not implemented yet. One half-word is set aside for flags, which will eventually include at least whether we should enable GiveBack and whether we can get power from batteries and variable power supplies. GiveBack support would allow the power supply to temporarily remove power if another device needs extra power, and would be mostly useful in the PD Buddy Sink for battery charging applications. Support for drawing power from batteries and variable supplies requires specifying a voltage range, and they will be lower priority than fixed supplies.

    (N.B. "Variable supply" in USB PD parlance is really just a euphemism for "poorly regulated supply", not the kind of variable power supply you're probably thinking of. For those, USB PD 3.0 support is needed, and they're called "programmable". I'm not aware of any programmable USB PD power supplies on the market yet, but if I've just missed them, please let me know!)

View all 9 project logs

Enjoy this project?



oshpark wrote 04/18/2017 at 01:45 point

Very interesting project!

  Are you sure? yes | no

Andrew Bolin wrote 03/21/2017 at 04:25 point

Hey, I had almost the same idea recently, but you've actually built it!
If you stick it in a box with one of those cheap DPS3005 type regulator modules you could probably take some money from me ;)

  Are you sure? yes | no

Clayton G. Hobbs wrote 03/21/2017 at 14:28 point

That would be a pretty cool idea. It would be better to use one of the buck-boost versions, like a DPH3205, so it's not limited by the 20 V maximum voltage of USB PD.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates