The pin at pin GND ESP8266 connects to a pin from the ESP. The A0 pin as well.
But the voltage the ESP is measuring is referenced to the ESP GND, the same GND used to set a pin high to trigger your transistor. This is the PWR-GND of the complete ESP. All GND pins on the ESP are connected internally.
Regarding your ESP is working correctly; you get a voltage readout on a terminal, the GND of the ESP is connected to the PWR-GND. and will not be switched, according to your circuit
Meaning the GND at the cap is somewhere in the rest of your circuit connected to GND ESP8266.
The transistor is shorted by yourself.
Try using a CD4066