Control USBC voltage supplied to a device

I would like to control a USBC-powered fan via Home Assistant. From the fan description:

  • Fan will run at a slower, quiet speed with a USB-C 5v source
  • Fan will run at a faster speed with a PD/QC (9v) source

So I would need something that can dynamically switch between 5v and 9v and be controllable by Home Assistant. But I ran out of keywords to google for.

Anyone here has any tips for me?

Tip

Thanks! I was hoping for something a little more off-the-shelf, but I’ll have a look at this DIY solution when I am well rested.

https://iniushop.com/en-au/blogs/blog/pd-and-qc-fast-charging-explained may be of good background to explain the two different power supply technologies involved with competing PD and QC techniques.

Trigger modules can be used to connect the appropriate resistance across the USB terminals to specify the correct voltage to be supplied, in what is effectively a variable voltage power supply to your fan. In this case you will need a separate fixed power source for your smart automation, or one that can cope with a supply range of 5v to 9v without getting upset by switching action. You may have to add a big smoothing capacitor across the power supply terminals to absorb any glitches during transition.

The other option is fixed voltage and pulse width modulation (pwm) to control the speed which was suggested by @tmjpugh above, but may not be compatible with your fan if it doesn’t have pwm support.

You could do a digital to analog output with a heavy duty current output suitably rated for your fan. Direct connection to your GPIO is strongly discouraged - it doesn’t have enough oomph to do the job.

If this fan is inside your pc, most motherboards support fan speed control and you may be able to do this entirely in software.

Other option is just switch between the two voltages with a HomeAssistant controlled relay. One voltage output from a power supply that gives two voltages simultaneously may be cheaper. If the internals of your fan already have the two voltages available, you may already have most of the hard work done for you. Alternatively, intercepting the control pin of the voltage regulator and switching in and out a resistor or reference voltage may do the trick.

You didn’t tell us the fan make or model, or use case specified making it difficult to address your specific requirement, hence guessing, so my first tip to you is give us more detail.

How do you control fan speed now? Switch or vendor software?

How much does this fan cost? Is an alternative controlled fan using pwm rather than voltage levels going to be a cheaper and easier option?

Thank you so much for the detailed reply!

Here’s the fan: DIY Kit - UCGF Cooler – EXEN

I got it preinstalled in this enclosure: Cloud Gateway Fiber Cooler – EXEN

It is currently plugged in an old 5v iPhone charger cube and working fine. I simply would like to be able to make it spin faster (9v) if the SFP stick gets above a certain temperature threshold, then back to quieter 5v speed when temperature drops.

I see you are running a standard two wire Sunon 12Volts DC fan. No pwm here. You could swap it for one that is pwm at low cost.

The “Pre-installed USB-C power input module” is your key to this conundrum. Contact the vendor for how to switch the voltage as that website has no information whatsoever. Even a closeup photo of the chip involved may lead you to a data sheet and application note from the vendor that may have a simple sample circuit that is being used.

GitHub - iceteaSA/ucg-max-fan-control: UXG-Max/Fibre Dynamic Fan Control · GitHub for possible pwm code.

Thanks for your help, much appreciated!

A way to cobble together an elementary solution would be to use two different USB power adapters (one standard 5V and another QC 9V), then plug in a usb switch into each one (like this), and then use a USB dual power cable (like this).

You’d then set up a switch in home assistant with logic to ensure that you never have both turned on at the same time. The obvious downside here is that if both do get turned on at the same time, it comes down to the quality of the two USB adapters to determine if the magic smoke comes out or your house burns down.

Diode can prevent undesired smokes…

Double pole relay would make an ideal switcher and prevent short circuot situation too. Common ESP8266 with a cheap relay board should do the job quite well and be integrated easily with HomeAssistant. You could even use a two relay board, one to switch the mains on and off, and the other to select speed/voltage.

Most modern power supplies would probably be designed to survive a direct short.

What is the chip numbers on the power module?

Thanks to everyone who chimed in, I really appreciate all the info! However, I think I’ll stick to a fixed 5v power supply for now, as I’m not much of a DIY-er with electronic components.

See ESP32-S2 PWM Fan Controller for server racks (ESPHome, 4 channels) for ideas too.