Grove - Relay
Introduction
The Grove-Relay module is a digital normally-open switch. Through it, you can control circuit of high voltage with low voltage, say 5V on the controller. There is an indicator LED on the board, which will light up when the controlled terminals get closed.
Specifications
Parameter | V1.1 | V1.2 |
---|---|---|
Product Release Date | 27th Jan 2013 | 9th June 2014 |
Operating Voltage | 5V | 3.3V~5V |
Operating Current | 60mA | 100mA |
Relay Life | 100,000 Cycle | 100,000 Cycle |
Max Switching Voltage | 250VAC/30VDC | 250VAC/30VDC |
Max Switching Current | 5A | 5A |
Tip
More details about Grove modules please refer to Grove System
Platforms Supported
Getting Started
With Arduino
Connection
Here we will show you how this Grove - Relay works via a simple demo. First of all, you need to prepare the below stuffs:
Seeeduino V4 | Grove - RTC | Grove - RTC | Base Shield |
---|---|---|---|
Get ONE Now | Get ONE Now | Get ONE Now | Get ONE Now |
- Connect Grove-Relay module to the Digital 4 port of Grove- Base Shield.
- Connect Grove-Button module to the Digital 2 & 3 ports of Grove- Base Shield.
- Plug Grove- Base Shield into Arduino.
- Connect Arduino to PC via a USB cable.
Note
If we don’t have the base shield, we also can directly connect the Grove-Relay and Grove-Button to Arduino board. Please follow below connection.
Grove-Relay | Arduino |
---|---|
GND | GND |
VCC | 5V |
SIG | D4 |
Grove-Button#1 | Arduino |
---|---|
GND | GND |
VCC | 5V |
SIG | D2 |
Grove-Button#2 | Arduino |
---|---|
GND | GND |
VCC | 5V |
SIG | D3 |
Software
Below is a demo that shows you how to control a Grove - Relay with a Grove - Button. When one button gets pressed, the relay will close. When the other button gets pressed, the relay will open.
// Relay Control
void setup()
{
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, OUTPUT);
}
void loop()
{
if (digitalRead(2)==HIGH)
{
digitalWrite(4, HIGH);
delay(100);
}
if (digitalRead(3)==HIGH)
{
digitalWrite(4, LOW);
}
}
With TI LaunchPad
Controlling other electronics (Relay)
This example shows how to use the Grove-relay module to control larger load, i.e. a desk lamp light. A 3V voltage signal can cause the relay to switch on, allowing current to flow through the connected appliance.
/*
Relay
The basic Energia example.
This example code is in the public domain.
*/
#define RELAY_PIN 39
// the setup routine runs once when you press reset:
void setup() {
pinMode(RELAY_PIN, OUTPUT); // initialize the digital pin as an output.
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(RELAY_PIN, HIGH); // turn the relay on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(RELAY_PIN, LOW); // turn the relay o by making the voltage LOW
delay(1000); // wait for a second
}
With Raspberry Pi
Connection
- First, We need to prepare the below stuffs:
Raspberry pi | Grove - Relay | Grove - Button |
---|---|---|
Get ONE Now | Get ONE Now | Get ONE Now |
- Follow instruction to configure the development environment.
- Plug Grove-Button to D3 port of Grovepi+.
- Plug Grove-Relay to D4 port of Grovepi+.
Software
This demo shows you how to use Grove - Relay by Raspberry Pi .
# Raspberry Pi + Grove Switch + Grove Relay
import time
import grovepi
# Connect the Grove Switch to digital port D3
# SIG,NC,VCC,GND
switch = 3
# Connect the Grove Relay to digital port D4
# SIG,NC,VCC,GND
relay = 4
grovepi.pinMode(switch,"INPUT")
grovepi.pinMode(relay,"OUTPUT")
while True:
try:
if grovepi.digitalRead(switch):
grovepi.digitalWrite(relay,1)
else:
grovepi.digitalWrite(relay,0)
time.sleep(.05)
except KeyboardInterrupt:
grovepi.digitalWrite(relay,0)
break
except IOError:
print "Error"
- Find the path to the file(According to your own path)
cd GrovePi/Software/Python/
- Run the Program
sudo python grove_switch_relay.py
Resources
- [Eagle] Grove - Relay Schematic and PCB in Eagle format
- [PDF] Grove - Relay PCB in PDF format
- [PDF] Grove - Relay Schematic in PDF format
- [Datasheet] HLS8-T73 Series Relay Datasheet
Arduino | Wio | BeagleBone | Raspberry Pi | LinkIt ONE |
---|---|---|---|---|
Caution
The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.
Techsupport
For any technical issue, you are most welcome to contact techsupport@seeed.cc, our techsupport engineers will help you. Thank you!
Help us make it better
Welcome to the new documentation system of Seeed Studio. We have made a lot of progress comparing to the old wiki system and will continue to improve it to make it more user friendly and helpful. The improvement can't be done without your kindly feedback. If you have any suggestions or findings, you are most welcome to submit the amended version as our contributor via Github or give us suggestions in the survey below, it would be more appreciated if you could leave your email so that we can reply to you. Happy Hacking!