For the second one (the first link is dead) you have to supply +5V and - (negative) to the relay and the IN and - (negative) to the ESP On the other hand you may use a solid state relay, you may connect it directly between the negative and the port of the ESP (or inversed)
I've just checked and both links I posted are viable.
And yes, I am supplying 5V and ground(-) to the relay, and IN and ground(-) to the ESP but it can't drive the relay - that's why I used this schematic with the PN2222 transistor.
Nevertheless, thanks for the suggestion using a solid state relay - I'll give it a try.
If I could avoid using a transistor it would be better/simpler.
That's our difference of view, the ESP should not drive the relais at all, only the optocoupler who's asking less than 1mA.
Perhaps you have to cut a wire, on the two and four relays boards you will find a jumper to do so.
I have a ESP running with a four relayboard attached to it without any problem.
There should be another issue there, the resistor between 5V and 3v3 !
When the ESP have to deliver current to the opto the 3V3 could be lowered. My advise is to add a voltage regulator.
I got your point.Feeding the optocoupler through the ESP and the relay coil from the power source itself. I can do that with the 30A relay - if you take a look at the relay boards there is a jumper for providing different power source to the relay coil, than the one for the optocoupler.
But this is only for the 30A relay, 10A relay doesn't have such jumper - the relay coil and the optocoupler are sharing the same power supply. (I am using only 1-relay boards).
For the purpose of explanation, here's my breadboard (sorry about the pictures' quality - 5M camera on the phone):
I am using a
voltage regulator
which is about 1A - it powers the ESP. I feed the relay board before the regulator with 5V directly from the power supply - 1A. The relay board, ESP and the power supply (voltage regulator) are sharing common ground. The rest is as it is on the initial schematic I posted.
You've got it, I know most of the single relays do have common power, you may change the board but for that price you may use a 30A instead. Also handy is the solid state, more reliable but a little bit bigger. There is a 25A and a 40A. The advantage is that you don't need the 5V. anymore.
i m trying to make a wifi enabled relayswitch with help of iotcloud, following this tutorial :
iot-playground.com/blog/2-uncategorised/..._cloud_configuration
the problem that i m facing is :
while pasting the arduino code in my arduino ide and compling it, it is giving me multiple errors, even though i have successfully downloaded and added the library required for esp8266, mqqt and eeprom
link from where i have downloaded the mqtt library :
github.com/iot-playground/EasyIoT-Cloud/...r/libraries/esp-mqtt
the errors are :
sketch_feb15b:64: error: 'loadConfig' was not declared in this scope
loadConfig();
^
sketch_feb15b:95: error: 'macToStr' was not declared in this scope
clientName += macToStr(mac);
^
sketch_feb15b:105: error: 'myConnectedCb' was not declared in this scope
myMqtt.onConnected(myConnectedCb);
^
sketch_feb15b:106: error: 'myDisconnectedCb' was not declared in this scope
myMqtt.onDisconnected(myDisconnectedCb);
^
sketch_feb15b:107: error: 'myPublishedCb' was not declared in this scope
myMqtt.onPublished(myPublishedCb);
^
sketch_feb15b:108: error: 'myDataCb' was not declared in this scope
myMqtt.onData(myDataCb);
^
sketch_feb15b:120: error: 'waitOk' was not declared in this scope
waitOk();
^
sketch_feb15b:154: error: 'saveConfig' was not declared in this scope
saveConfig();
^
C:\Users\Manan Mehta\Documents\Arduino\sketch_feb15b\sketch_feb15b.ino: In function 'void loop()':
sketch_feb15b:211: error: 'saveConfig' was not declared in this scope
saveConfig();
^
exit status 1
'loadConfig' was not declared in this scope