Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By btidey
#76739 If you want to use the bare relay directly then you just need a driver (bjt + base resistor or mosfet) plus a catch diode for the reverse voltage spike when relay turns off.

The 3V relay needs 120mA to turn on well. A 2n2222 could handle the current but needs about 5mA base current to saturate it on. So a bias resistor of say 470 Ohm.

MOSFET case you just need to select a MOSFET like AO3400 that has low threshold and turns on well with 3.3V logic. The gate resistor to ground just ensures that relay is off by default even before pin is set to output low.
You do not have the required permissions to view the files attached to this post.
User avatar
By btidey
#76740 Looking back at your original board it looks like you are using a HT7333 regulator to derive the 3.3V for the ESP-12.

That has a max current of 250mA which is low for even the ESP-12 on its own. It certainly wouldn't do the relay current as well. So you need one with higher capacity (500mA). Maybe increase decoupling capacitor as well to minimise spiking when relay switches.

What is the incoming supply volts? If it is unregulated then I'd worry about the power dissipation of the regulator. If it was +5V then a better option might be to use a 5V relay. Schematic remain largely unchanged just connect top of relay coil to +5V instead of 3.3V. THis lowers work the regulator has to do and keeps spikes away from the 3.3V logic.
User avatar
By rudy
#76741 One important thing to consider. When the ESP8266 is reset and has not started executing our code yet, many of the I/O pins have internal pull-up resistors enabled and that might cause your relay to operate when you didn't want it to. For the mosfet circuit the relay would turn on, for the transistor circuit with a 3 volt relay it might turn on but maybe not as the current through the pull-up resistor is smaller than for reliably the current needed. Not a thing to count on.

GPIO12, 13, 14 have pull-ups enabled. GPIO15 needs an external pull down so that is one that I would use, but it can go high when in bootloader mode. GPIO4, 5 are the best choice as they have no pull up or down nor unexpected operations.

As stated above, I would recommend not using the 3.3 volt processor power if possible. And if you do then the power supply must be able to reliably source the relay current and the ESP peak currents.
User avatar
By ErikLem
#76754 Thanks btidey. I ordered a few 2n2222 to toy around with.

I'm indeed using a HT7333, well spotted. I just checked the datasheet and I see your're right, it can only provide 250mA. For the way I used it now, it was ok, but I think I should upgrade it to a HT7833, which can provide 500mA.

I usually use a simple power adapter, like this , but also sometimes use a 9V one. I would rather not rely on the power supply directly.

The decoupling capacitor I now use is 470uf, which is already rather large I believe. what value would you recommend?