When the ESP32 is booting up, it draws enough current to keep the MC34063's switch on for part of every MC34063 cycle. When the ESP32 becomes idle, the amount of current it draws falls, and the MC34063 starts to "skip" cycles. That is, there are MC34063 cycles in which the switch is never turned on. The effective frequency of the switch, thus falls, and may fall into the audio range, as in your circuit.
When the effective frequency of the switch is in the audio range, the inductor (or possibly the capacitor) may make an audible noise, especially if the turns are not wound tightly to the core.
There are a number of steps you can take to mitigate this noise, each having its own benefits and downsides.
- You can try to find an inductor with less tendency to whine
- You can try to fix the inductor turns in place with some kind of conformal coating or glue, provided the inductor does not get too hot as a result.
- You can add a dummy load to the output of the buck converter to ensure that the frequency stays above the audible range even when the ESP32 is idle. The upside is this is very easy to implement. The downside is that it will waste power, which may or may not be a concern for you.
- You could use a converter IC chip that uses "forced CCM" (FCCM) also known in TI's literature as "Forced Pulse Width Modulation" (FPWM). The idea behind FCCM/FPWM is to never skip switching pulses, even when the load is very light. Instead, excess charge at the output is "recycled" back to the input during part of a switching cycle. This trades efficiency at light loads for a constant frequency at light loads. Since the switching frequency is set above the audible range, there is no audible coil whine.
Note that the available chips for this last option (for example TI's LMR50410XFDBVR) generally run at much higher frequencies than a typical MC34063A circuit. This requires care in choosing the inductor and capacitors and in the layout of the circuit. However, as you have been successful in implementing a MC34063A circuit, I believe you will be successful at these higher frequencies. Note that the inductance and capacitance of inductors and capacitors at high frequencies may be very different from their low frequencies values. So, not just any inductor or capacitor will serve.