Loading... Please wait...

Relay Module

Relay Module

This example shows how to use a relay module. If you are not familiar with mains wiring and the danger associated we recommend you use this relay to drive low-voltage, low-power circuits.

Hardware Required

  • Arduino Board
  • Relay Module
  • Item to be powered through the relay

Circuit

To switch on a device when it is normally off we will use the common terminal and the normally open terminal to connect the device as shown below. If we wanted to be able to actively switch off a device that was normally left on by default then we would use the common terminal and the normally closed terminals.

 

relayusage1.png

 

This diagram illustrates the current flows in three states. Firstly it shows that when there is no coil current (relay is off), then there is a circuit between the NC terminal and COM. Then when current flows there NC & COM circuit is broken and the COM and NO circuit is made. Once the current stops the coil is not energized and the NC and COM circuit is made and the COM / NO circuit is broken.

 

 

relayterminology.jpg
 
This is an image of a relay module showing markings used instead of COM/NO/NC. The COM position is the center terminal and points to the NC terminal. The other terminal is the NO terminal.
 
To use the relay module connect up the device as discussed above. Then connect:
 
  • +5V to +5V
  • GND to GND
  • IN to digital pin 2
 

 1-channel-font-b-relay-b-font-modules-font-b-opto-b-font-isolation-module-low.jpg

Code

 

/* sketch
turn on a device using a relay

 

Connect relay module as follows:

 

+5V to +5V
GND to GND
IN to digital pin 2

*/

 

int relay = 2;

 

void setup() {
  pinMode(relay, OUTPUT);
  digitalWrite(relay, HIGH);
}

 

void loop() {
}

 

 

 

What's News

newsletter

Copyright 2017 oddWires. All Rights Reserved.
 Sitemap | oddWires