I have a nodemcu acting as a thermostat home office. The wall heating element is controlled with a solid state relay on D2. If i have it connected, I cannot program the board from the arduino ide. I disconnect it, I can program it, and then plug it back in and it runs fine. However if i push the reset button the serial output is garbage and the device does not seem to be doing what it should be(does not seem to connect to wifi or publish mqtt messages). I even tried delaying when I set D2 to an output to see if there was just too much current draw when it first powers up (even though it was not being set to ON until later in the code)
What I did find that worked is rather then connecting the other side of the solid state relay to GND, I connected it to another IO pin (D5). Then to actually initialize the relay, I set D2 and D5 to outputs, set D5 LOW and then use toggling D2 HIGH and LOW to actually toggle the heating. This seems to work fine even through a reset.
Any thoughts why this would be happening?