Trending

How to control high voltage devices with arduino using relay


The relay is a device to control high voltage devices (Like AC Devices). In other words, A relay is an electrically operated switch.It isolates low power devices (Like micro-controllers) to high power devices.



Types of Relays-



Electromagnetic Relays


These relays are constructed with electrical, mechanical and magnetic components, and have operating coil and mechanical contacts.

Therefore, when the coil gets activated by the power supply to a coil, these mechanical contacts gets opened or closed, which causes switching actions.


These relay make tick sound (or noise) when opened or closed.






Here NO and NC mean NORMALLY OPEN, NORMALLY CLOSED.



Solid State Relay-


Solid State uses solid-state components to perform the switching operation without moving any parts (means no noise).


How to use-

Connect AC device in series to NO and Common pin of a relay.

We use NO pin here because it normally open which means circuit it open when no voltage is applied to Relay.




BUT! Some microcontroller cannot supply enough power to activate a relay.

This can be resolved by using a transistor, but it will make the connection complex.
So use Relay Channel module, which makes it a lot easier to use with a microcontroller. 



WARNING :  Use 5v battery instead of 9v in the above circuit.



Code-


/* Made by Nishant Kr */
void setup() {
  pinMode(5, OUTPUT);  //digital pin as output mode.
  pinMode(4, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
}
void loop() {
  digitalWrite(5, LOW);   // Low voltage means Relay on
  delay(1000);                       // wait for a second
  digitalWrite(5, HIGH);    // High voltage means Relay off
  delay(1000);                      
  digitalWrite(4, LOW);   
  delay(1000);                     
  digitalWrite(4, HIGH);    
  delay(1000);                  
  digitalWrite(3, LOW);  
  delay(1000);                       
  digitalWrite(3, HIGH);   
  delay(1000);                     
  digitalWrite(2, LOW);   
  delay(1000);                      
  digitalWrite(2, HIGH);    
  delay(1000);                       
}


NOTE -


  1. It's better not to use PWM pin, as it may be required for other functions like fading etc.
  2. There are some special pins on board which must not be used with relay module as it may cause the board Booting problems, Check pin-outs before using.
  3. Special Pin on ESP8266 and NodeMCU are D8 (GPIO 15) and D3(GPIO 0)
  4. RX and TX pin should be avoided on both Arduino and ESP8266.

No comments