I have a simple project where I want to turn a 5v fan on/off and both the MCU and fan will powered by a LiPo battery.
I'm powering the ESP and fan directly from the battery in the attached circuit. For now I've decided not to boost the power to 5v for the fan because the fan runs fine at lower voltage. Also using a BJT transistor as a low side switch.
This all seems to work fine except at full duty cycle the voltage to the fan seems to completely collapse. At just below full (like if a do analogWrite(pin 1000) it's humming along fine but when I go to 1023 the voltage drops from around 4 to closer to 2 and the fan stops. Even at lower duty cycles like 50% the fan operates nice and slow.
I put a multimeter on the leads to the fan and observe the voltage drop at full duty.
I'm very new to all this and have done a lot of reading but I haven't been able to solve this. Also this is my first fritzing drawing so I hope it makes sense.
Edit: I made some changes to the circuit and it's working as expected. I have also updated the circuit diagram below.