Sei sulla pagina 1di 8

Home

Beginners
Projects
Tutorials
Articles
Reviews
Software
Search...

Target Amount: $93 / $2000
Amount Raised will be updated once daily.
Thanks J.P. for your $10 Donation!
Starting Electronics Fund Raiser
It is that time of the year again when our annual web hosting subscription must be paid.
We also need to upgrade our lab equipment which is outdated (including test equipment).
Please consider giving a donation to Starting Electronics and help to fund this site.
Facebook
YouTube
Blog
Twitter
Donate
Shop for Electronics - Our Amazon aStore
Home Projects Arduino Projects Arduino Tiny Relay Shield
Projects Menu
Projects
Arduino Projects
4 Channel Voltmeter
Tiny Stripboard Shield
Temperature Stripboard Shield
Relay Stripboard Shield
Arduino Tiny Relay Shield Project
Created on: 31 October 2012
In this Arduino project, you will build a small relay shield from stripboard. The shield can have one or two relays
fitted to it.
Connect the Arduino and relay shield to your PC via a USB cable. Download the PC software and use it to switch
anything on and off that is attached to the relays.
The shield is based on the Tiny Stripboard Shield for Arduino project.
This video shows the Arduino shield project and software.
Can't see the video? View on YouTube
Circuit Diagram
Arduino Tiny Stripboard Relay Shield Circuit Diagram - click for a bigger image
The relay used in the circuit is a 5V relay with part number JRC-23F (JRC-23FHS1DC5V). The bottom view of
the wiring diagram for this relay is shown here:
Bottom View of the JRC-23F Relay
Components
You will need an Arduino board such as the Arduino Uno, as well as a Tiny Stripboard Shield and the components
listed in the table below.
Qty Part Designator Notes Type
2 2k2 resistor R1, R2
1/4W, 5% Resistors
2 470 ohm resistor R3, R4
2 3mm LED D1, D2 For indicating which relay is on
Semiconductors
2 1N4148 D2, D3 Diodes
2
PN2222, KSP2222 or
similar
Q1, Q2 PNP transistors
2 5V relays
RLA1,
RLA2
E.g. JRC-23F 5V miniature PCB relay or
similar
Relays
2 3 pole screw terminals J1, J2 2.54mm pin spacing Connectors
If you can't get hold of the same relay or a pin compatible part, then you will need to modify the stripboard circuit
layout to suit your relay. Make sure that it is a 5V relay.
The relay is a miniature relay that can switch 1A of current at 30V d.c. Don't try to switch anything that is mains
powered with this relay.
This photo shows the parts used in the Arduino relay shield project:
Components Used in the Arduino Tiny Relay Stripboard Shield Project
Construction
A number of wire links will be needed to connect all of the relay contacts to the screw terminal connectors. This is
the most tricky part of building the circuit. Beginners should rather stick to connecting a single relay.
To simplify the wiring further, use only the normally-open contacts and a two pole screw terminal.
These images show the top and bottom views of the completed stripboard relay shield.
Top View of the Relay Shield
Bottom View of the Relay Shield
Software
Arduino Sketch
After building the relay shield, plug it into the Arduino and load this sketch:
/*--------------------------------------------------------------
Program: relay_shield
Description: Monitors the USB serial port. If the character
'1' is received, relay 1 is switched on. If the
character '3' is received, relay 1 is switched
off.

'2' switches relay 2 on and '4' switches it off.

Hardware: Written for the Tiny Stripboard Relay Shield
with relay 1 connected to Arduino pin 2 and
relay 2 connected to Arduino pin 3.
Date: 31 October 2012

Author: W.A. Smith, http://startingelectronics.com
--------------------------------------------------------------*/
// relay pin numbers
int rel1 = 2;
int rel2 = 3;
void setup()
{
Serial.begin(9600);
pinMode(rel1, OUTPUT); // relay pins
pinMode(rel2, OUTPUT);
digitalWrite(rel1, LOW); // switch relays off
digitalWrite(rel2, LOW);
}
void loop()
{
char rx_byte;

if (Serial.available() > 0) { // byte received from USB?
rx_byte = Serial.read(); // get byte from USB serial port
if (rx_byte == '1') {
digitalWrite(rel1, HIGH); // switch relay 1 on
}
else if (rx_byte == '2') {
digitalWrite(rel2, HIGH); // switch relay 2 on
}
else if (rx_byte == '3') {
digitalWrite(rel1, LOW); // switch relay 1 off
}
else if (rx_byte == '4') {
digitalWrite(rel2, LOW); // switch relay 2 off
}
}
}
Test the shield by starting the Arduino Serial Monitor and sending '1' to switch the first relay on, '2' to switch the
second relay on, '3' to switch the first relay off and '4' to switch the second relay off.
Processing Sketch
Download the relay_shield_pc Processing sketch. This software runs on the PC and allows you to switch the
Arduino relays on and off.
Load the relay_shield_pc sketch to the Processing IDE. Make sure that the Arduino is plugged into the PC and
running the above Arduino sketch. Run the Processing sketch from the Processing IDE and see which port
numbers are displayed in the bottom pane of the IDE. If necessary modify the code to select the correct port that
the Arduino is attached to. Go to the bottom of temperature shield software page for more details and a video on
how to do this.
When the PC application starts, click the buttons in the application to switch the relays on or off.
To comment on this article or ask questions, go to the blog entry for this article. Use the comment box at the
bottom of the blog entry.
Beginners
About Electronics
Start Electronics Now
Tools for Beginners
Soldering
Projects
Arduino Projects
Tiny Stripboard Shield
Temperature Shield
CPLD Board
Tutorials
Arduino
AT91SAM7S Micros
AVR 8-bit Micros
STM32 Micros
Articles
Arduino Articles
AT91SAM7S Micros
STM32 Micros
More articles...
Reviews
Tools Reviews
Evaluation Boards
Book Reviews
More reviews...
Software
VHDL Course
Arduino Software
Processing Language
Xilinx Software
About
Contact
Donate
Privacy Policy
2012 2014, Starting Electronics

Potrebbero piacerti anche