I am building a project in which I am using esp32 (please excuse if this forum does not deal with esp). I have the need to power a simple peizzo buzzer from it.
If I power the buzzer with 3.3v it is not very audible. So I need 9v for clarity. Esp digital pin will only output 3.3v.
Can I use a dc to dc step up converter for this ? I understand peizzo buzzers don't really use lot of current. Am I right to use a step up here then?
No. An ESP pin doesn't have enough current to drive a step up convertor. You just use the ESP output to gate a 9V power supply to the buzzer. A FET circuit can do that.
Generally, a transistor will do such as the the ubiquitous 2N2222 with a 2k2 base resistor. Of coruse a FET is better but you have to pick a logic-level one - I was about to suggest the 2N7000 for up to 150 mA but it is marginal on 3.3 V.
You show it running on 9V. The 2N7002 has a VGSth of 2.5V max, so the pre-driver just barely makes it. That will rise as the temperature drops, so it would be sensitive to cold environments. Mathematically, it's okay, but you are supposed to leave a noise margin...