Turn fan on and off - there are regulators with ENABLE pins.
There are fan controller ICs but often they're expensive in small quantities.
You could just use a switching regulator in SEPIC mode and control the output voltage ignoring the current and that would allow you a wide output voltage range, like 3v.. 12v.
You can go for the cheaper route and use only step-up regulator, and configure fan between 5v and 12v... step up would only allow you an output voltage as low as the input voltage.
You could set the output voltage of a regulator using a DAC on your microcontroller, here's a "tutorial" :
https://www.microchip.com/forums/FindPost/688260You can use ANY switching regulator, just have to look up the datasheet and determine the voltage reference value inside the chip (listed in datasheet) and adjust resistor values accordingly (keeping in mind minimum resistor value mentioned in datasheet)
34063 or 33063 would work, but personally I would choose a switching regulator that works at slightly higher frequency than 100-150kHz because while you lose a bit of conversion efficiency, you get much smaller and cheaper inductors and you can use smaller ceramic capacitors instead of electrolytic capacitors.
For example, have a look at
* LM4510 :
https://www.digikey.com/product-detail/en/texas-instruments/LM4510SD-NOPB/LM4510SD-NOPBCT-ND/1679844* MP1540 :
https://www.digikey.com/product-detail/en/monolithic-power-systems-inc/MP1540DJ-LF-Z/1589-1857-1-ND/5291720(up to 12v 200mA with 5v input , 2.7v..5.5v input voltage, 1.3 mhz switching frequency, super simple to wire and very few extra components)
You can use the DAC method on these to mess with the adjust to limit current. But if you don't want or don't have DAC....
Another trick you could do would be to use a LED driver IC as a fan controller... use a regular switching regulator to boost your battery voltage of 3.7v .. 5v to around 12v or whatever voltage you want (maybe you'd like max 10v for a more silent fan ... and pick inductor and other parts, for example to really optimize for around 12v.. 12.5v output instead of a wide output voltage range - would be safe to go up to around 13v, most PC fans have +/- 10% tolerance) and then use a super cheap and simple buck (step-down) led driver IC to limit the current. The fan always gets around 12v (minus some losses in the led driver and resistor that measures current) but the current is limited by the "brightness" setting which you could control through PWM or i2c commands.
Here's a short selection of such led drivers :
https://www.digikey.com/short/pzh00pFor example the cheapest AL8860 would be quite suitable:
https://www.digikey.com/product-detail/en/diodes-incorporated/AL8860WT-7/AL8860WT-7DICT-ND/6226981Datasheet:
https://www.diodes.com/assets/Datasheets/AL8860.pdfYou can set the maximum current (for example 0.2A) using a resistor, and then you can use the CTRL pin for ON/OFF or adjust current between 5% and 100% of the value set using the resistor:
Multi-function On/Off and brightness control pin:
•Leave floating for normal operation.
•Drive to voltage below 0.2V to turn off output current
•Drive with DC voltage (0.3V < CTRL< 2.5V) to adjust output current from 0 to 100% of IOUT_NOM
•Drive with PWM signal from open-collector or open-drain transistor, to adjust output current.Linear adjustment range from 1% to 100% of IOUT_NOMfor f < 500Hz
•Connect a capacitor from this pin to ground to increase soft-start time.(Default soft-start time = 0.1ms. Additional soft-start time is approx.1.5ms/1nF
Another example : TS19376 :
https://www.digikey.com/product-detail/en/taiwan-semiconductor-corporation/TS19376CY5-RMG/TS19376CY5RMGCT-ND/7359728Datasheet :
https://www.taiwansemi.com/products/datasheet/TS19376_A12.pdfAgain, set maximum current using a resistor and then use PWM pin to "dim", aka adjust current to your desires.
The TS19376 allow dimming with a PWM signal at the DIM input. A logic level below 0.3V at DIM forces TS19376 to turn off the LED and the logic level at DIM must be at least 2.0V to turn on the full LED current. The frequency of PWM dimming ranges from 100Hz to more than 20 kHz.
You could use a step-up led driver IC and basically use it to also boost 3v..5v to 12v ... but you'd have to add a zener diode or something to cap the output voltage to 12v or thereabouts..
There's loads of 10v, 11v and 12v zener diodes... and cheap :
https://www.digikey.com/short/pzhv3z