This is really a followup to a previous question to provide an updated schematic and photograph at the request of a commenter on that question. I'm not sure if there is a better way to provide such an update to a question but here it is anyway...
I have the following circuit:
simulate this circuit – Schematic created using CircuitLab
When I measure the voltage across R2 I don't see the 18V being supplied into the collector of transistor scaling linearly with the value of the PWM GPIO of the NodeMCU. It ranges from 9.35V with the GPIO at 0 (i.e. off) and 17.14V with the GPIO at 1023 (on "full"). With a GPIO value of 512 it reads 13.16V.
I tried my best a photograph of my set up:
About the only thing that is not clear in the photo I think is that the resistor "above" the transistor is between the GPIO with an orange wire and connects to the base (middle pin) of the transistor.