As the title says, i am working on a small project for my fish-tank which intends to provide and automate cooling during the summer months. Basically the concept is that if the temperature raises above a certain value the fan will turn on and again, if it falls below a certain value it will stop. In this post, i would like to show you where i am and ask for support from someone more experienced than i am in the wiring. So, before i reach to the wiring, let me give you a part list:
Hardware:
NodeMCU, ESP8266 is the brains of the operation.
DS18B20 Underwater temperature sensor
12V DC, IP68 Fan
LM2596 Stepdown converter
SRD-05VDC-SL-C Relay
For the software i am going to use ESPHome. The logic of the project is, that the NodeMCU will be powered by the 12V AC-DC 2A adapter using the stepdown converter. The rest of the parts will be powered directly from the NodeMCU except of course for the 12V fan that is connected on the relay. Since this this the first time i try to build such a thing i would like a confirmation that i do everything correctly on the wiring.
Wiring:
To Power the NodeMCU have pinned the jack to the upper power rails of the breadboard providing 12V power to all pins. From the left side of the rail, i feed 12V the step-down converter in the in+ and in- and i have adjusted the output to 5V (is this correct). Then the output of the step-down converted will be connected to VIN and G pin on the NodeMCU (currently is not yet connected). I hope that with this connection i will be able to power the NodeMCU and all the parts connected to it. In case my logic here is not correct please let me know.
The DS18B20 is connected to one of the 3v3 pins, to a ground, and for data i use pin D7, also programmed in the code. This is tested with USB power and it works.
The relay is connected with the NodeMCU as such:
VCC to 3v3
Ground to Ground
In to D6 also programmed in the code
The 12V fan is a 2 pin fan and i connected it to the relay as follows:
Power from the rail + goes to the COM of the relay (red wire)
Power from the NO of the relay goes to the fan (red wire)
Black wire from the fan is directly connected to the negative rail of the breadboard.
This way, i believe that the relay closes the circuit of the red wires and the fan should spin.
So to sum up my questions:
Is the 5V output of the step-down converter correct? Will it be enough to power the NodeMCU?
Is the wiring logic correct or as soon as i am gonna plug it in itâs gonna blow up?
Thanks very much for support here. Wiring is not my forte!!
Sounds about right, but the relay may expect 5V, not 3v3, so you might want to confirm that (its name suggests that it wants 5), and connect its Vcc to the Vin line (same place you get power from the step-down).
FWIW, the above is based on the notion that the 3v3 line on the NodeMCU is provided by the NodeMCUâs onboard 5v-3v regulator, but the relay may draw more current than that regulator can supply (which would be in addition to the current itâs already supplying for the 3v3 on which the ESP runs).
Yes you are correct. The Relay is a 5V relay⌠I missed that, because i was following the below schematic:
It has the exact same relay (part number is the same) and connects this to the first 3v3 pin. The only difference is that on the above picture the NodeMCU is powered by a USB.
Currently i have the relay connected and the entity is exposed to home assistant and i can switch it on and off.
Do you think it is safe to pin it on the VIN and Ground that the NodeMCU will get power?
Sorry for the newbie questions, we all start like this!!!
The blue box is the actual relay, which is lasbeled SRD-05VDC-SL-C.
The circuit board on which itâs mounted will have its own name/model, and is importand to know since it will have its own signal levels, input voltage/current requirements.
Can you provide that model #? It will let me confirm what its proper input voltage is.
Unfortunately it doesnât have anything written on the PCB neither under it. If it helps, i bought it from this link: https://techfun.sk/produkt/rele-modul-1-kanal-5v/. Sorry it is in slovak but even on the title it says 5V.
I will try it with 3V first and if it doesnât work i will switch it to 5v
I should rephrase my recommendation:
If its datasheet says it expects 5V, you should supply that, not 3v3.
It will probably appear to work if supplied 3v3, but that might be right at the edge of not being enough, and one day it wonât move the relay contact. Using 3v3 from the ESPâs board also puts additional strain on the onboard regulator, meaning that your ESP may also not get enough current to operate reliably.
You donât want to risk either of those things happening, and you donât want to overload/damage the onboard 3v3 regulator.
Thus Iâd power the relay module from the 5V converter, not the 3v3 from the ESP.
I also noticed on the webpage that they offer a 3V version, further supporting the reason for supplying this on with 5.
As an aside: The control pin will still get only a 3v3 signal from the ESPâs GPIO, but that should be high enough to satisfy the logic on the relay board and activate it reliably. The relayâs support circuit will act on the 3v3 signal, and then draws power from its 5V Vcc line to move the relay armature.
At first, i had it on the 3v3 and it was working normally. I moved it to the output of the converter (5V) and now when i switch it on or off it doesnât make any difference⌠The relay outputs 12.10V regardless if i turn it on or off⌠Should i switch it back to 3v3?
I disconnected it from power until we figure it out
The only thing to put on 5v is the relayâs Vcc line.
If thatâs what you did, then it may be that the 3v3 logic signal isnât high enough to trigger it when Vcc is at 5. So, if the above is what you did, and it only works at 3v3, just go with that.
Yeah returning back to the 3V3 makes it operational again⌠I am thinking to buy the 3v version of the relay on my next purchase from that store⌠For now I will switch it on 3 volts
Thanks very much⌠Itâs a simple project but if you are not familiar with these things it can be stressful
Youâre welcome!
As you said, we all start out as new. Itâs all about questions, answers, learning, sharing and helping each other.
Hope it does what you want it to and the fish stay happy!
The part number of the relay is: SRD-05VDC-SL-C. I am pretty sure that it is 5v relay⌠My problem is that when connecting it to 5V on VCC the relay doesnât close the circuit by providing 3v on the âINâ.
The likely reason for that has nothing to do with the [blue] relay itself, but with the logic circuit thatâs on the board holding the relay.
A bare relayâs coil needs more current than the GPIO signal can provide, so most hobbyist relays now come with a driver board attached, which accepts logic-level control signals (e.g. from GPIO) to control the full-current Vcc source through the relayâs coil.
Some control logic will, if powered at 5v, still accept 3.3v as a logical âonâ or âhighâ signal.
But, some require the input signal to be closer to the Vcc voltage before considering it to indicate âonâ.
This device seems to behave in the latter manner.
Exactly that, as the esp pin is only outputting 3.3v when pulled high, thatâs why I requested the exact part number, the link provided in the OP shows two different relay boards.
You can also try using 5v but set the esp to trigger pin to pull low.
Where you define the âoutputâ, you can add âinverted: trueâ to that block. It makes the GPIO signal go low for âonâ and high for âoffâ.
Initially i did not have the âinverted: trueâ in the code but what was happening was that the polarity of the switch was opposite. When the switch was on in Home Assistant i was measuring 0.06v on the pins of the fan. When i âturned it offâ i was measuring 12.46v on the pins. So i added the âinverted: trueâ which fixed this problem. That made me believe that the inverted: true defines the polarity and not the voltage of the D6 Pin.
Today with your help, i connected again the relay to 5V and i tried both with âinverted: trueâ or without and unfortunately the relay stays on all the time, giving 12v on the fan pins.
I moved it back to the 3v3 and for now i will keep it there as nothing makes senseâŚ
Thank you very much both for your help, i wouldnât be able to reach to the stage that i am now without your support.