5V relay will work at 3.3V?
A 5V relay will work with a 3.3V input? TL;DR: yes!
Do you think a 5V relay will work with a 3.3 input? I just tried and I won!
This is my setup:
I connected the relay groung pin and Vin pin to the NodeMCU 3v3 and groung, and the data pin to the D4 pin. I used a code I found on internet and create a web-server on the NodeMCU MC to have two buttons to control the relay (two relay, actually). The code is pretty simple and you can find it right below:
status=0
pin=4
gpio.mode(pin,gpio.OUTPUT)
--gpio.write(pin,gpio.HIGH)
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,request)
local buf = "";
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
if(method == nil)then
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
end
local _GET = {}
if (vars ~= nil)then
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
_GET[k] = v
end
end
buf = buf.."<h1> ESP8266 Web Server</h1>";
buf = buf.."<p>GPIO0 <a href=\"?pin=ON1\"><button>ON</button></a> <a href=\"?pin=OFF1\"><button>OFF</button></a></p>";
buf = buf.."<p>GPIO2 <a href=\"?pin=ON2\"><button>ON</button></a> <a href=\"?pin=OFF2\"><button>OFF</button></a></p>";
local _on,_off = "",""
if(_GET.pin == "OFF1")then
gpio.write(pin, gpio.HIGH);
elseif(_GET.pin == "ON1")then
gpio.write(pin, gpio.LOW);
elseif(_GET.pin == "ON2")then
gpio.write(led2, gpio.HIGH);
elseif(_GET.pin == "OFF2")then
gpio.write(led2, gpio.LOW);
end
client:send(buf);
client:close();
collectgarbage();
end)
end)
Everything is stable, although I though it would be a bit fuzzy using 3.3V and not the nominal 5V. Enjoy it.
Written on May 30, 2016