I have a circuit to control my doorbell but Voltage on pin is too low

TomGeorge:
Hi,

const int buttonPin = 2;

const int relayPin = 4 ;



I think you have a problem here.

Your buttonPin is 4
You relayPin is 2

Tom.... :o :o :o

So D4 is GPIO 2 and D2 is GPIO 4 so I think the way this is set up is ok because I put it without the D here so it goes to the GPIO number.

Most relay modules have a transistor built in also. Maybe you don't need the 2n2222. Many relay modules won't trigger with 3.3V if they are powered by 5V. it would be worth trying to connect the 5V pin on the relay module to the 3.3V output on the NodeMcu. Then connect the relay input direct to the digital pin. It's not guaranteed to work, but many do.

So a little background on what happened. I had a an ESP8266 for this circuit which was working for awhile but as of a few weeks ago it stopped working for some reason. I thought maybe it had something to do with the doorbell so I tried replacing that but it still wasn't fixed so now I decided to change out the ESP2866 with a NodeMCU because it is much easier to reprogram. So I know the circuit works but now I am just trying to troubleshoot.

I have opened and MQTT subscribe feed and when I push the doorbell button there is no number sent to MQTT saying the button was pushed so I know that that is my problem. (hence why i thought maybe it was the button) I think it has to do with the pin voltage being low so when it goes to ground (when i push the button) it thinks it is already low thus doesn't signal a change.