-->
Page 1 of 1

Problem with relay control

PostPosted: Mon May 16, 2022 4:00 pm
by David4875
I’m running NodeMCU 8266 with the Cloud4rpi MQTT web service. I have a Cloud4rpi switch control that when set to True switches on an external LED on GPIO12.

BUT I want this to switch a relay too, and True on GPIO12 is 0V not 3.3 (measured on a voltmeter). This means the relay switches on when the switch is set to False, and off when it’s True - so the opposite of the LED.

Any ideas how to fix this so the LED is On and the relay is powered at the same time?

Re: Problem with relay control

PostPosted: Wed May 18, 2022 3:39 am
by David4875
Great thanks! :D

Re: Problem with relay control

PostPosted: Wed May 25, 2022 5:32 pm
by davydnorris
I also did it with a transistor - benefit of this is that it's cheaper and easier to build, and your transistor can be selected to drive higher current for the relay

See https://en.wikipedia.org/wiki/Inverter_(logic_gate)

Re: Problem with relay control

PostPosted: Thu May 26, 2022 10:40 am
by Luc Volders
If it is a NodeMCU you have plenty of pins free.
Why use GPIO12 ?
Have a led on another pin and at the same time the relay on yet another pin and have them switch at the same time.