100% found this document useful (1 vote)
155 views18 pages

AZ-Delivery 8 Relays Module Guide

The document provides instructions for setting up and using an 8-channel relay module with either an Arduino or Raspberry Pi microcontroller board. It describes how relays work, the specifications of the 8-channel relay module, and includes wiring diagrams and code examples to control the relays through each microcontroller board. Connections are made between the relay module and Arduino/Raspberry Pi pins, with the module getting power from the board. Running the code will turn relays and attached devices on and off.

Uploaded by

wilsnico
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
155 views18 pages

AZ-Delivery 8 Relays Module Guide

The document provides instructions for setting up and using an 8-channel relay module with either an Arduino or Raspberry Pi microcontroller board. It describes how relays work, the specifications of the 8-channel relay module, and includes wiring diagrams and code examples to control the relays through each microcontroller board. Connections are made between the relay module and Arduino/Raspberry Pi pins, with the module getting power from the board. Running the code will turn relays and attached devices on and off.

Uploaded by

wilsnico
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Welcome!

Thank you for purchasing our AZ-Delivery 8 Relays Module. On the


following pages, we will introduce you to how to use and set-up this handy
device.

Have fun!
Relays are used to control AC circuits, switching them ON or OFF. The
relay is one of the most important control elements. It is an electrical switch
that responds to a signal received from the microcontroller (like in
Atmega328P or Raspberry Pi). Relays are widely used in remote control,
communications, mechatronics devices, power electronic devices, etc. They
also can be used to separate powerful voltage/current electronics (like AC
or DC motors, or any AC device, etc.), from microelectronics (like
microcontrollers, sensors, etc.).

Inside relay, there is one mechanical switch (three yellow metal rods, with
one in the middle that is bent to one side, and is movable), which is
controlled by the second element of the electromagnet (yellow cylinder), as
shown on the image below:

In the non active state, the switch is in the OFF state, NC pin is connected
with common pin, and NO is unconnected. When the power is being
connected to the electromagnet (via transistor and rectifier diode), this
moves the switch to the active state, thus connecting the common pin to NO
pin.
The 8 relays module consists of eight relays capable of handling up to 5A
50V AC and 5A 30V DC. For every relay, there are aslo a LED, two
resistors, a NPN transistor, a rectifier diode and optocoupler.

On the DC side of the board there are ten pins, eight input pins for eight
relays, one for power supply (VCC) and one for ground (GND). There is
also a three pin jumper for selecting power supply (external or VCC power
supply). On the AC side there is three pin screw terminal header, where
pins are labeled as: Normally Closed - NC pin, Common pin and Normally
Open - NO pin.

Specifications:
Maximum AC: 5A 50V
Maximum DC: 5A 30V
Contact Type: Both: Normally Closed – NC, Normally Opened - NO
Dimensions: 50 x 140mm [1.97 x 5.5in]
The pinout

External power supply jumper is used for selecting the power supply input. If
it is left unconnected, the relays will not be powered up at all, but the LEDs
on-board the module will still blink. If you connect the JD-VCC pin and VCC
pin together (with two pin jumper), the the module will be powered up from
the VCC pin.
If you want to use external power supply, remove two pin jumper, and
connect the positive side of external power supply to JD-VCC pin, and
ground pin of external power supply with ground pin of the module.

External power supply

Why is there a need for external power supply?

Firstly, it is needed because sometimes a voltage regulator on-board is not


powerful enough to drive the microcontroller board and the module.

Secondly, it is better for relays and microcontroller board power supplies to


be separated. Because relays are used to control the AC or powerful DC
devices, and having to control electronic and powerful electronic circuits
separated is a safety precautionary measure. One of the good sides of
using relays is to protect the microelectronic circuits from powerful
electronic circuits.
How to set-up the Arduino IDE

If you did not install Arduino IDE already, this is how to do it. Go to the link:
[Link] and download installation file for
your operating system platform.

For

Windows, double click on downloaded ".exe" file and follow instructions in


installation window.
For Linux, download file with extension ".[Link]", which then you need to
extract. When you extract it, go to the extracted directory, and open terminal
in that directory. You need to run two “.sh” scripts, first called "arduino-linux-
[Link]", and second called "[Link]".

To run first script in terminal, run the following command:


sh [Link] user_name
user_name - is the name of super user in the Linux operating system.
After this, you will be prompted to provide password for the super user. Wait
for a few minutes for script to complete everything.

After installation of the first script, run the second called "[Link]" script. In
terminal, run the following command:
sh [Link]

After the installation of these scripts, go to the All Apps to find the Arduino
IDE installed.
Next thing is to check if your PC can detect the microcontroller board. Open
freshly installed Arduino IDE, and go to:
Tools > Board > {your board name here}
{your board name here} should be the Arduino/Genuino Uno, as you can
see on the image below:
After this you need to select the port on which the microcontroller board is
connected. Go to: Tools > Port > {port name goes here}
If you connected the microcontroller board on the usb port, there should be
several port names. Because we are using Arduino IDE on Windows, port
names are like on image below.

For Linux users, port name is “/dev/ttyUSBx” for example, where “x”
represents integer number between 0 and 9, for instance.
Connecting the module with Atmega328P Board

Connect the 8 relays module with the microcontroller board with as shown
on the following connection diagram:

Module pin > Board pin


IN1 > D9 Green wire
IN2 > D8 Blue wire
IN3 > D7 Gray wire
IN4 > D6 Orange wire
IN5 > D5 Ochre wire
IN6 > D4 Cyan wire
IN7 > D3 Purple wire
IN8 > D2 Pink wire
GND > GND Black wire
VCC > 5V Red wire
NOTE: As you can see in the red rectangle on the connection diagram,
external power supply jumper is connected, connecting JD-VCC pin with
VCC pin. This means that the 8 relays module will be powered up from
microcontroller board via VCC pin.

Sketch example:

uint8_t relays[8] = {2, 3, 4, 5, 6, 7, 8, 9};


void setup() {
for (uint8_t i = 0; i < 8; i++) {
pinMode(relays[i], OUTPUT);
}
}

void loop() {
for (uint8_t i = 0; i < 8; i++) {
digitalWrite(relays[i], HIGH); // Turn ON
}
delay(1000);
for (uint8_t i = 0; i < 8; i++) {
digitalWrite(relays[i], LOW); // Turn OFF
}
delay(1000);
}
When you upload the sketch to the microcontroller board, you should hear
clicks from relays. When the relay changes state from active to rest and vice
versa, you can hear switching clicks.

All light bulbs connected to relays should blink every second.

We can change NO/NC pin states by these lines of the code:


digitalWrite(2, HIGH); - NC pin is not connected to the common
pin
NO pin is connected to the common pin

digitalWrite(2, LOW); - NC pin is connected to the common pin


NO pin is not connected to the common
pin
How to set-up Raspberry Pi and Python

First you have to install operating system on the Raspberry Pi, then to set it
up so that you can use it in the “headless” mode. Headless mode enables
you to remotely connect to the Raspberry Pi, without the need for PC
screen Monitor, mouse and keyboard. You can find detailed explanation in
the free eBook "Raspberry Pi Quick Startup Guide", which can be found on
our site:
[Link]

The Raspbian operating system comes with the Python preinstalled.


Connecting the module with Raspberry Pi

Connect the 8 relays module with Raspberry pi as shown on the following


connection diagram:

Module pin > Raspberry Pi pin


VCC > 5V ! [pin 2] Red wire
GND > GND [pin 6] Black wire
IN1 > GPIO14 [pin 8] Green wire
IN2 > GPIO15 [pin 10] Blue wire
IN3 > GPIO18 [pin 12] Gray wire
IN4 > GPIO23 [pin 16] Orange wire
IN5 > GPIO24 [pin 18] Ochre wire
IN6 > GPIO25 [pin 22] Cyan wire
IN7 > GPIO8 [pin 24] Purple wire
IN8 > GPIO7 [pin 26] Pink wire
NOTE 1: Connect VCC pin of the module to the 5V pin of the Raspberry Pi,
because the module can not work when there is less than 5V on the VCC
pin.

NOTE 2: As you can see in the red rectangle on the connection diagram,
external power supply jumper is connected, connecting JD-VCC pin with
VCC pin. This means that the 8 relays module will be powered up from
Raspberry Pi board via VCC pin.

Python script:
import [Link] as GPIO
from time import sleep
[Link]([Link])
[Link](False)
Relays = (14, 15, 18, 23, 24, 25, 8, 7)
for i in range(8):
[Link](Relays[i], [Link])
print('[press ctrl+c to end the script]')
try: # Main program loop
while True:
for i in range(8):
[Link](Relays[i], [Link])
print('Normally opened pin is HIGH')
sleep(1) # Waitmode for 1 second
for i in range(8):
[Link](Relays[i], [Link])
print('Normally opened pin is LOW')
sleep(1) # Waitmode for 1 second
# Scavenging work after the end of the program
except KeyboardInterrupt:
print('Script end!')
finally:
[Link]()
Save the script by the name "[Link]" into default script directory. To run
the script open terminal in the directory where you saved the script and run
the following command:
python3 [Link]

The output should look like the output on the image below:

To end the script press "CTRL + C".

The script is self explanatory.


You've done it!
Now you can use your module for various projects.
Now is the time to learn and make the Projects on your own. You can do
that with the help of many example scripts and other tutorials, which you
can find on the internet.

If you are looking for the high quality microelectronics and


accessories, AZ-Delivery Vertriebs GmbH is the right company to get
them from. You will be provided with numerous application examples,
full installation guides, eBooks, libraries and assistance from our
technical experts.

[Link]
Have Fun!
Impressum
[Link]

Common questions

Powered by AI

Arduino provides a robust platform for beginners with a seamless setup and a straightforward programming model, making it ideal for simple relay control projects. In contrast, Raspberry Pi's extensive capabilities, including native support for programming languages like Python, offer more computational power and flexibility, allowing for complex, data-driven applications. Each platform's benefits lie in their versatility; Arduino for ease and straightforward implementation, and Raspberry Pi for advanced automation tasks where computational power and network integration are essential .

The external power supply configuration ensures that the relay module receives sufficient power when the onboard voltage regulator cannot handle the load. By using an external supply, the power for the relays is separated from the microcontroller, preventing potential interference and ensuring the microcontroller's stable operation, thus enhancing overall system safety and efficiency .

Relays are used to control AC circuits by switching them ON or OFF and act as an interface between microcontrollers and higher voltage/current circuits. The critical function is to protect microelectronic circuits from the influence of high powered circuits by maintaining separation. This separation is a safety measure to prevent microelectronics from being damaged by high voltage or current surges, contributing to both the protection of devices and enhancing system reliability .

The 8 relays module's design allows it to integrate easily with various controllers via simple GPIO interfaces, making it straightforward to expand systems by adding additional modules or stacking additional microcontrollers for more complex operations. This modularity not only facilitates the current specifications but also supports future scalability, enabling the design of larger, more sophisticated control systems without delving into extensive redesign of the existing setup. Its ability to separate logic levels from power levels further supports this scalable expansion .

Using Python with Raspberry Pi in a headless setup allows remote control of the relay module without the need for physical peripherals, enhancing flexibility and efficiency in automation tasks. Python enables straightforward scripting to manage relay states, making it versatile for complex projects. Headless configurations save physical space and reduce the cost of system setup, showcasing an efficient and scalable solution for managing relay operations .

To set up the 8 relays module with an Atmega328P board, connect the input pins of the module (IN1-IN8) to digital pins (D9-D2) of the Atmega328P. Ensure the VCC and GND of the module are connected to the 5V and GND of the board, respectively. It's critical to connect the JD-VCC pin with the VCC pin using the jumper, so the module is powered from the microcontroller's VCC pin, making sure to handle each connection's electrical constraints safely .

The Arduino sketch controls each relay state by setting the digital pins connected to the module's IN pins (D2-D9) to HIGH or LOW, effectively toggling the relay to switch connected AC or DC devices ON or OFF. This operation results in modulating the state of connected devices: a HIGH signal connects the common pin to the NO pin, and a LOW signal connects it to the NC pin, causing devices to switch between active and inactive states .

The relay module's specifications, which include a maximum AC current of 5A at 50V and DC current of 5A at 30V, determine its suitability for relatively low-power switching applications. These ratings guide users to select applications like home automation or low-power industrial controls where electrical loads fall within these limits. Ensuring compliance prevents potential overload and overheating, thus safeguarding both the module and connected devices .

The optocoupler in the relay module serves as an interface that facilitates electrical isolation between the low-power microcontroller circuits and high-power relay circuits. It works by converting an electronic signal into light using an LED, which a phototransistor at the other end detects, ensuring that there is no direct electrical contact and that electrical noise does not propagate between sections of the circuit .

The separation of digital and power ground on the relay module helps prevent ground loops and interference between power-hungry and sensitive low-voltage digital circuits. This configuration minimizes noise pick-up by the digital circuits and reduces the risk of transient spikes from connected power devices adversely affecting the digital side, thus enhancing both protection and operational reliability of the entire system .

You might also like