Wemos D1 Mini + BJT Unstable

Hi,

I am using a Wemos D1 Mini (Cheap clone) to control a 5V Songle relay. I have pin D4 set as an output and it is connected to the Base of a 2N3903 NPN BJT, through a 1KOhm resistor. The Emitter of the BJT is connected to ground, and the Collector is connected to +5V through a Songle relay coil (I measured 70Ohms for the coil). I also have a flyback diode across the relay coil.

When I RESET the Wemos board, even without commanding the D4 output, the D4 pin, as well as the 3.3V pin oscillate between 0 and 3.3V. This happens also if I keep the Collector unconnected to anything.

Does anyone have an idea about what the problem might be? I did some tests on the side, and with this setup, the BJT should consume about 2.5mA at the base (3.3V through 1KOhm resistor to the base). So even though I am using a cheap Wemos with a crappy 3.3V regulator, 2.5mA should be low enough not to cause any trouble.

Any help would be appreciated!

zouje.

Quick update: I tried using a 47 Ohm resistor instead of the Songle relay (My thinking was: maybe there is some inductance issues at play). Same issue!

The Wemos board has a 10K pull-up resistor attached to D4. This is because D4 is the esp's GPIO2 pin, which determines the boot mode. Your 1K resistor and the BJT will be pulling the pin low at startup, preventing it from booting correctly.

Try using D1 or D2.