Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Tinamore
#21472
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.
User avatar
By AcmeUK
#21493 Hi

Not a solution to the GPIO 2 issue, but be aware that you can get 3v relay modules that should remove the need for the interface circuit.
For info see http://www.ebay.co.uk/itm/3V-Relay-High-Level-Driver-Relay-Module-for-Arduino-Optocoupler-u-/231535394504?pt=LH_DefaultDomain_3&hash=item35e895bec8
or search for '3v relay module'
User avatar
By Tinamore
#21583 I solved the problem.

I Change connect the Base of the transistor from GPIO 2 to GPIO 4.
GPIO 4 no present in ESP-01, however you can solder it directly into the GPIO4 of the SOC of ESP-01 according to the diagram:
Image
I've tried the other GPIO, seems not working, only GPIO 04 working.
:D
User avatar
By martinayotte
#21672
tytower wrote:
martinayotte wrote:GPIO2 (or GPIO0) need to be HIGH at Reset because of the Boot process :
https://github.com/esp8266/esp8266-wiki ... ot-Process


I don''t believe this is right see wiki/doku.php?id=getting-started-with-the-esp8266 where GPIO2 is left floating.

I'll start a separate thread on this conflict so please report back what works for you
and hopefully this will help others starting out .


I prefer trusting a spec sheet than people testimonies. the Boot process table shown in the link I've mentioned is proably a copy/paste from Espressif specs. Been in electronic engineering for decades, the four different possible connections for an input : L, H, X and NC. BTW, X doesn't mean floating, it means "irrelevant". Not connecting a X input can still be troublesome, since EMI/RFI can disturb the input, and even destroy it if EMI/RFI is too high. We should never leaving inputs floating, except if specs says NC.

Additionnally, if the table says to put it to HIGH, even if there is currently no mode in the table that use it with LOW, it doesn't mean Espressif can decide in a future to use that for an additionnal mode of boot process, let's says for example thru an I2C bus. So, to respect backward compatibilty, we should follow the specs to the "letter".

EDIT : BTW, and I've just try it out : if GPIO2 had a X instead of H, then that would mean that we can place to LOW, but right now, in such case it does NOT boot any more ! If leaving it floating works, it is simply that, like in the old days of TTL, floating is quite the same as HIGH (except about EMI potential issue). Right now, it is confirmed : Espressif really spec it that a HIGH level is REALLY required on GPIO2 !