ESP8266 and single Relay

Could some help me with this question. It's driving me nuts as I am new to electronics.

I have a ESP8266 Wi-Fi board. I have connected it to a Single relay.

My question is, on my ESP board I have connected to pin 4 for the data and I have done this because I wanted to see the LED light up when I switch it on. This works! But, when I connect to pin 1 on the Relay, the LED on the relay is ON when the ESP pin4/LED4 is OFF and if I switch the state of pin 4, then the RELAY LED goes OFF but the ESP LED goes ON.

Is this correct? I was hoping for the Pin4 on the ESP to switch on and the Relay LED to also switch on at the same time. Then visa versa.

Thanks for your help in advance.

Mike

what relay module? some relay modules hold the coil if signal pin is LOW

Hi,

Thanks for your response. It is a tongling single relay.

My main question is, is it ok to have the ESP pin 4 high all the time unless the relay is on of which it would then go low.

Would this be bad practise or does it not matter what state the pin is in when left for a period of time?

Also, I cannot reset the ESP without first disconnecting the data pin cable. Is there a way around this as the ESP will need to be reset at some points.

Thanks again.

My main question is, is it ok to have the ESP pin 4 high all the time unless the relay is on of which it would then go low

Yes. Relay modules that are active LOW usually have an optoisolator. Inside of the optoisolator there is a LED. When the LED is on that activates a photo transistor in the optoisolator that then activates a driver transistor. The LED anode is wired to Vcc and the cathode to your pin 4 through a resistor. When your pin 4 is HIGH there is no voltage across the optoisolator LED so no current flows and the optoisolator LED is off. To turn the relay on the optoisolator LED cathode must be grounded by pin4 going LOW. As for the LED on pin 4, if you put a resistor from pin 4 to the cathode of the LED and the anode wired to Vcc the pin 4 LED will mimic the LED on the relay board

|500x205

Also, I cannot reset the ESP without first disconnecting the data pin cable. Is there a way around this as the ESP will need to be reset at some points.

Which ESP module do you have?