tytower wrote:Always have trouble with transistors . Should be as easy as .
Your emitter then is connected to Ground . The base is connected to GPIO2 and Collector to middle pin on relay . A small flow on base to ground at 3.3V will allow a larger flow from Collector to Ground at 5V. In this case through the coil I assume pulling in the contacts . OK
can you point me to the example please as I do not use SDK and would like to see it. GPIO2 is an alternative pin for serial and I'm wondering if it is sending something out there after reboot . Perhaps setting GPIO as input for a couple of seconds delay in your program then set it as output.? Don't know but I'd like to see example.
You might also be able to set the pin to a different function -see Wiki
Perhaps pinMode(2, FUNCTION_1) or equivalent in Language you use and set it low immediately.
Sorry, I only use SDK, because SDK is a Base code of ESP8266. It will performance than any another code.
It looks like ESP8266 automatically switch GPIO to HIGH immediately when Boot before execute any code. I tried SET pinMode to LOW at first line function main (Function main is run top first of ESP8266) but GPIO still HIGHT for 1 second, after GPIO switch to LOW.
martinayotte wrote:This question is been asked several time!
GPIO2 (or GPIO0) need to be HIGH at Reset because of the Boot process :
https://github.com/esp8266/esp8266-wiki ... ot-Process
So, you need to have pullups on both !
if you attached ANY devices, relay or whatever, expect a HIGH at powerup to be the default OFF state.
So, in the schematic above, you need to add another NPN transistor to inverse it's active state to LOW, so in the your firmware, writting a LOW state to that pin will activated the relay.
(BTW, personally, I prefer using MOSFET since the gate current is very low, and saturation very high)
I think can float GPIO, NOT necessary manual pullups on both (GPIO 0 and GPIO 2) ?
As the circuit, I connect BASE of transistor to GPIO 2 via Resistor 47k, It make the GPIO 2 Almost float, The circuit works well after boot, The Problem is GPIO 2 automatic switch to HIGH a short time (1 second) while during boot
I was successful when Blink LED with control LOW state GPIO2 (set default a PIN of LED to VCC and control by active GPIO2 to LOW), but control Transistor with low is Difficult.
I will try add another NPN to current circut to control by LOW.
Thank for response.