I recently bought a bunch of ESP-12Fs. I created my own PCB for simple switching a relay over the net. I want to control some power sockets with it. First my setup
VCC=3.3V
VCC --> VCC
CH_PD --> 1k --> VCC
GND --> GND
GPIO15 --> GND
GPIO0 --> Push Button to GND for programming
--> Pull up 1k to VCC
GPIO2 --> Pull up 1k to VCC
TX --> RX
RX --> TX
RES --> Push Button to GND
On my board I'm coming in with 5V and convert to 3.3V with a AMS1117 step down module to have both available.
At first I tried the standard arduino relay board which is LOW active. When I connect the board to 5V, GND to GND and IN to GPIO2, the relay does not switch at all. If I connect the board to 3.3V VCC everything works fine! First question, why doesn't it work with 5V ?? GND is always the same.
Because I wanted to have all components on one board which fits exactly into my enclosure I would like to switch the relay directly with a BC337 transistor. Connection:
GPIO2 --> 220R --> Base of BC337
+5V --> relay1 relay2 --> collector
emmiter --> GND
And there come the problems. I always use the Arduino IDE for programming. I flashed the software onto the ESP (works only when GPIO2 is not connected). When I reset the ESP and connect the GPIO2 afterwards, everything works. I can switch the relay without a problem (switching is inverted of course, because now it is HIGH actived).
But when I press reset I get a ton of fatal exception (0) from the bootloader and it stays this way. Only when I disconnect the GPIO2 it starts normal.
I measured the current on GPIO2 and when the relay is active it draws about 10mA, seems ok....
Maybe GPIO2 draws to much on startup??
What can I do to prevent this?
Do I have to increase the base resistor ?
thanks for your help
regards
Erich