Controlling relay using esp2866

Hi everyone I need some guide regarding on my ongoing project currently I'm building home automation.


I'm using 12v power supply since my FAN max voltage is 12v only (for testing) is it enough to make it on?
besides the relay is working using my mobile app that I created
and also I'm using charger to power up my esp2866 using 5v charger

any advice?

also... can I use direct plug to make my FAN work? but it says in FAN that the limit is only 12v

What is a direct plug? If it connects to the mains you will probably fry the fan or worse. You could conceivably take out all of your electronics. What is your question? You could make a block diagram showing how this goes together but a schematic, not a frizzy thing showing all connections would be the best.

Here is the schematic diagram that I am imitating it. My question is my why FAN doesn't turn ON when red lights relay indicator lights up?

Let’s say your fan is on the IN1 relay circuit.

What happens if you take the IN1 wire off of the Arduino pin and touch that end to GND.

That is a picture that my tired eyes cannot read, not a schematic. Is your relay board compatible with 3.3V inputs, I cannot see the technical information on it.

Since you are powering the relay board with 5v and the Arduino output goes from 0v to 3.3V the relay INX inputs still have 1.7v applied to them.
This may still be considered as ON.

You need to level shift the Arduino outputs to 0 to 5v levels.

Can you post a picture of the relay?
Does the blue block label say 5 or 12 volts?

The relay module has TWO power requirements.
First is the RELAY COIL power.
Minimum is 100mA per blue block.
The other requirement is SIGNAL
Less than 10mA per blue block.

There is a jumper to isloate the relays power from the signal power.

Since the opto is current driven the voltage output of the ESP should be able to drive the SIGNAL pins.

You CANNOT provide power from the ESP for the relays. The voltage regulator on the board cannot deliver the sufficient power.

Assuming that you have connected the fan properly (just assuming that of course)
The LED simply indicates that there is power on 1 side of the Opto-coupler, but can you hear the relay 'click' ?
If not, then it must be a power issue of some kind. The nodeMCU draws a fair bit, and the relays do so as well. How much power does your power supply provide ?

It's not an Arduino!

Not with a green LED in series with the optocoupler LED.

So you do not need to. But in fact, you do need 5 V on the "Vcc" to reliably operate the relay.

Very blurred, but pretty sure it is "SRD-05VDC" :grin:

You assume LEDs have a snap action and are either on or off.

This is not the case with LEDs, they are not a zener they are not a voltage comparator.

They can emit light when the so called LED forward voltage is not met.

Did you read β€œ This may still be considered as ON.” ?

Who is saying otherwise ?

Anyone notice the photos show the red wire is not connected Vin ?

https://europe1.discourse-cdn.com/arduino/original/4X/c/c/b/ccbcd829bac614bf03ae10f8aa0fb415830a689c.webp

Nice catch, it is connected to 3.3v . I think, actually it should be. The jumper should be removed, and the relays should take actual 5v.
Now while i was looking for the 5v power input i studied the picture even more. The orange wires which i suspect is the connection to the fan is connected to 2 different relays !!
it is 3 connections per relay. 4x is 12 connections in totale. these wires are connected to one end of 1 relay and 1 of the one next to it.

And in the picture (this is the diagram)

The only LEDs that I have encountered that conduct (prerequisite for emitting light, by the way) below a given threshold voltage were a batch of super-cheap (white) "reject" ones. Most references I have seen and my experience is that they do exhibit a threshold voltage but have a very round "knee", so they are not very useful as a tight reference, but just fine if you only need an approximation.

Not with the series connection of a green LED and an IR LED. :roll_eyes:

Part of the confusion with calling it an "Arduino". :astonished:

Relays coil power is required to be the relay voltage.
Since the photos are blurry and the fritzrig is not how this is wired it does beg some answers.

If the ESP is powered from the same power supply as the relay coils, there is no need to remove the jumper.
The ESP8266 is 5v tolerant on the pins.

First step is move the red wire to 5v and see if that provides enough power to operate ONE relay.

Correct approach is to connect the coil voltage to a power supply.

That is just not true, particularly not on GPIO pins that are in output state and HIGH. Reverse voltage is actually a weakness. Still the LED and the Opto-coupler should probably bring it down below the safe 3.6v level.

[ EDIT : after searching for ANYTHING in writing from Expressif, I could not substantiate the following claim. Therefore, I would believe it to be FALSE ]

Espressif CEO Mr Teo Swee Ann commented that " i can reply officially here: it is 5V tolerant at the IO. while the supply voltage is at 3.3V...

There is a letter on the expressif pages documenting this.

[ EDIT : warning, this letter could not be found and searching shows the data sheet removed even mild references to this so the above is NOT substantiated and should be considered FALSE ]

I have NEVER seen Anything about the Analog pin except NEVER exceed the 1.o volts on the input.

If i was saying that 'in my experiance....' and the OP blew up his board, i would feel obliged to replace it.

Watching the forum, about 80% of the problems with relay modules is power supply related.
I advocate TESTING with 2 power supplies. Get it to work on the bench.

Every time they do, they find the problem and resolve it. It seems they wouldn't be here if they figured out easily.

People have stated that, but have not provided the link. Also i have heard that this information has been removed. As a rule, 'we know for sure it is 3.3v tolerant' and out of my personal experience 'it isn't 5v tolerant'
The discussion has been here before, and i think this is the information we should give.

The OP isn't using it, but that is sound advice. It has a 10-bit input resolution, that much i know as well.

Of course ! Many people try to power them through USB or the 5v pin of an Arduino, and that usually is not sufficient power.

1 Like

Somewhat confusing statement.

If you power through USB, you can draw something like 500 mA from the "5V" pin. It is not a sensible way to use it but it will generally work. 500 mA will power at least four of the common "Songle" 5 V relays with a 90 mA current draw each.

What you cannot do with any reliability, is to power the Arduino via "Vin" or the "barrel jack" and connect things such as relay modules to the "5V" pin.