ESP8266 WiFi relay switch (Arduino IDE)

9 years 3 months ago - 8 years 4 months ago #1990 by sueche
Hello,

I am trying to reproduce the schematics of the ESP8266 WiFi relay switch (Arduino IDE) example here:

The only difference is that I have esp-201 instead of esp-01.
When I power up the board the logic is reversed: '1' means OFF and '0' means ON.
The other thing that bothers me is that on initial power up there is a fast ON/OFF/ON cycle with the relay.
Any idea how to avoid ths ?
By the way, I assume that there is no direct connection between BASE of the transmitter and GND (that's not clear on the schematics).

Edit: A simple push-up resistor of 10K on GPIO2 fixed the issue (due to the special functions of GPIO2 - same goes with GPIO0 if used).
The following user(s) said Thank You: pablo

Please Log in or Create an account to join the conversation.

9 years 3 months ago #2036 by medyk8ns
You can try using different GPIO(RX-GPIO1 or TX-GPIO3). Probably using pnp transistor or MOSFET can help.
I was trying to recreate this schematics, changing resistor values and so on with no luck.
Using GPIO0 and GPIO2 is troublesome due to boot up process of ESP8266. Finally I've used GPIO1 connected via resistor to 2n2222 and then to relay and 1N400x diode in parallel. So no relay module. Then it worked without problems during booting.
There is no connection between base and GND.

Please Log in or Create an account to join the conversation.

9 years 3 months ago - 9 years 3 months ago #2038 by sueche
Hello, I am glad someone replied to my post at last. Would you care to send the schematics of what you have tested because I can't figure it out how to introduce the 1N400x diode in the diagram I'm using ?
Also by using GPIO1 you mean to change the code from
digitalWrite(2, 0);
to
digitalWrite(1, 0);
(I am using Arduino IDE for ESP-201 programming) ?
What about GPIO5, I beleive it's feasable as well ?

Please Log in or Create an account to join the conversation.

9 years 3 months ago #2040 by medyk8ns
For connection just type '2N2222 relay' in google. First result is from instructables.com and it explains everything.
GPIO5 should be ok(but I haven't worked with esp-12). Have you tired using other GPIOs(12,13,14,16)?

Remember to set pinmode in setup function:
int outPin = 5;
void setup()
{
     pinMode(outPin, OUTPUT);
}
void loop()
{
     digitalWrite(outPin, HIGH);
     delay(10000);
     digitalWrite(outPin, LOW);
     delay(10000);
}

More about:
- relay modules modification: instructables.com ,
- boot process: github.com ,
- 3,3V to 5V level shifting: forum.arduino.cc or electronics.stackexchange.com/ .

You can also build your own level shifter with 2N7000 MOSFET see here .
And with ESP always remember to use good power supply(1 amp at least).
The following user(s) said Thank You: sueche

Please Log in or Create an account to join the conversation.

9 years 3 months ago #2044 by sueche
Thanks for the comprehensive answer. I am using esp-201 but not esp-12.
Obviouslly I just have to use diffrenet GPIO than 2 and the easiest way to reverse the relay logic is with the program code.

Please Log in or Create an account to join the conversation.

9 years 3 months ago #2047 by asm7100
How about a MCP23017 (I2C bus) Then you have a lot of outputs, and run it at 3v3 then you can use 5v as input to the MCP23017 :-)

MCP23017 hase 3 add pins so you can make a lot of in / out with only 2 pins.
MCP23017 has to port's A and B, eatch has a IRQ pin out, so is you use then to read from outsite, you can connect the IRQ pins to otheer pins of the ESP modul and see if there is any inputs waiting :-)

//
Allan

Please Log in or Create an account to join the conversation.

Time to create page: 0.588 seconds

Forum latest

  • No posts to display.