Welcome, Guest
Username: Password: Remember me

TOPIC: ESP8266 WiFi relay switch (Arduino IDE)

ESP8266 WiFi relay switch (Arduino IDE) 1 year 7 months ago #1990

  • sueche
  • sueche's Avatar
  • Offline
  • New Member
  • Posts: 9
  • Thank you received: 1
  • Karma: 0
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).
Last Edit: 8 months 4 days ago by sueche.
The administrator has disabled public write access.
The following user(s) said Thank You: pablo

ESP8266 WiFi relay switch (Arduino IDE) 1 year 6 months ago #2036

  • medyk8ns
  • medyk8ns's Avatar
  • Offline
  • Junior Member
  • Posts: 25
  • Thank you received: 5
  • Karma: 0
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.
The administrator has disabled public write access.

ESP8266 WiFi relay switch (Arduino IDE) 1 year 6 months ago #2038

  • sueche
  • sueche's Avatar
  • Offline
  • New Member
  • Posts: 9
  • Thank you received: 1
  • Karma: 0
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 ?
Last Edit: 1 year 6 months ago by sueche.
The administrator has disabled public write access.

ESP8266 WiFi relay switch (Arduino IDE) 1 year 6 months ago #2040

  • medyk8ns
  • medyk8ns's Avatar
  • Offline
  • Junior Member
  • Posts: 25
  • Thank you received: 5
  • Karma: 0
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 administrator has disabled public write access.
The following user(s) said Thank You: sueche

ESP8266 WiFi relay switch (Arduino IDE) 1 year 6 months ago #2044

  • sueche
  • sueche's Avatar
  • Offline
  • New Member
  • Posts: 9
  • Thank you received: 1
  • Karma: 0
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.
The administrator has disabled public write access.

ESP8266 WiFi relay switch (Arduino IDE) 1 year 6 months ago #2047

  • asm7100
  • asm7100's Avatar
  • Offline
  • Premium Member
  • Posts: 99
  • Thank you received: 7
  • Karma: 1
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
The administrator has disabled public write access.
Time to create page: 0.215 seconds
Powered by Kunena Forum