A relay is an electromechanical switch used mainly for switching application either high voltage or low voltage switching, and they can be also used with microcontrollers like the Arduino for controlling high voltage devices
The aim of writing this is to serve as a guide while to interface the relay and the Arduino or the ESP 32
We'll be using the Arduino, Relay Module, Wires, LED (green) and a 220-ohm resistor
The relay pinout is as follows;
On the Input sidePositive ---- "5v or External 5v Power Supply"
Control/Signal pin ----- "digital Write pins on the Arduino "
Negative ---- "Ground"
On the Output SideNormally Closed ---- "preferably Empty"
Ground ----- "Ground"
Normally Open ---- "Negative Terminal of the Load "
We will use the schematic below to connect our various component
If you wanted to test the relay to make sure it's working copy and run the Relay tester code file on my GitHub then remove the signal pin (that's pin 8 on my end) and insert it back at quick intervals; Ensure you are hearing the clicking sounds of the relay; That shows your relay is functional.
Another side point, Often manufacturers might make mistakes in labelling the input pins; Most relay modules come with inbuilt LED indicators that displays when they've been powered ON, So try to power the positive and negative terminal of your relay then the last vacant pin is your control/signal pin.
To interface the relay, it's best to use the negative side of the load and connect it to the relay "Normally Open" pin in "series"... Then the "common ground" of the relay is then connected to the ground line of your connection
When connecting your load to the relay output terminals it is better to keep it at the "Normally Open" pin, because that is where the relay is switching to, although keeping it at the normally closed will perform the same function
Things to note when working with your Relay* The relay is not an ideal switch...meaning don't use your relay for basic switching purpose like turning on/off LED...it will wear off the mechanical parts faster...this example was just for demonstration
* They are not good for fast switch application
* Relays are more suitable for high voltage application or relatively slow switching like controlling servos.
Thanks a lot for your time and if you have any feedback or want to reach me find me on Twitter @_carlos_dev, for any comments feel free to leave it below; Thanks
Comments