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

User avatar
By Barnabybear
#49987 Hi, with regard to opto-couplers, I have use both of these daily without any problems.

Mains switching.
G3MB-202P switches some lighting. 3.3V is below the must operate of 4V but it’s never failed for me. No series resistor needed.
http://www.mouser.com/ds/2/307/g3mb_0609-298620.pdf

Low Voltage switching.
ILD74 in parallel with the ‘manual open’ button on my electric gates (12V). Needs 100 ohms in series with the LED.
http://www.vishay.com/docs/83640/ild74.pdf

One of the advantages of opto-coupling is that as the diode has no ground connection it can be connected between GPIO & Ground or most usefull for use with the ESP8266-01 between 3.3V & GPIO (ideal for GPIO 0 & 2). You do get a flicker at power up or reset (250 mS), for my lights it wasn’t a problem, as I didn’t want the gates to open in this event, the diode was placed between GPIO 0 & GPIO 2 (anode on GPIO 2 if I remember correctly). Taking one GPIO high and the other low switches on the LED. If it’s just for lighting the you won’t this level of control.
User avatar
By Joe Job
#50883
Barnabybear wrote:Hi, if you just want to switch an AC light which you hadn't stated before. you might be as well using an opto coupled relay to save on extra components. I've used these without a problem. 3 + goes to 3.3V, 4 - goes to your GPIO and AC is switched on 1 & 2, nothing else needed other than a 6mm gap between high an low voltages. The output is inverted so you just have to reflect this in your code. Depending on which GPIOs you use the may flicker at startup or reset, in total you can have 4 on an ESP8266-01 if you set the Tx & Rx pins to function as GPIOs.
Link to post


Thanks for your help on this mate, the image in the post you linked to looks exactly what I want. Getting no where fast with the relays I have at the moment except for when using an ATMEGA as well but this still needs 2 power lines. I need to have the ESP-01 powered by the mains as well so I am guessing the mains goes in through the step down which is connected to the ESP or do you need a 3.3v regulator as well? What I am not seeing in that image is the relay switch.
User avatar
By icons
#50888 I have successfully used this relay and it works well. http://www.banggood.com/5V-1-Channel-Level-Trigger-Optocoupler-Relay-Module-For-Arduino-p-915614.html
Not sure if it will fit your project, but surely will eliminate alot of headaches. It even works well with 3.3 v from esp.