Professional Documents
Culture Documents
Arduino Arduino Arduino Arduino 2 2 2 2 Channel Channel Channel Channel Relay Relay Relay Relay Shield Shield Shield Shield
Arduino Arduino Arduino Arduino 2 2 2 2 Channel Channel Channel Channel Relay Relay Relay Relay Shield Shield Shield Shield
Introduction::
Introduction
The Relay shield is capable of controlling 2 relays. The max switching power could be
10A/250VAC or 10A/30VDC. It could be directly controlled by Arduino through digital IOs with
external 9v supply. With building xbee/BTBee type socket, it can be wirelessly controlled via
Xbee/BTBee(HC-06). Make it an ideal solution for home automation and robotics purpose.
Feature::
Feature
1、2 channel Relay
2、With XBBee/BTBee, CC1101 and nRF24L01 wireless interface
3、With 6 sensor and 3 servo interface
4、Native Arduino compatibility
5、Equipped with screw holes for easy installation
Ideas::
Application Ideas
Make it an ideal solution for home automation and robotics purpose
Cautions::
Cautions
Note: The Relay shield just compatible Bluetooth Bee(HC-06), but Bluetooth Bee(HC-05).
If you want to use Bluetooth on, Please make sure the IO is 3.3v on your main board.
Specification::
Specification
Contact Rating 10A AC 250V / DC 30V
Weight 55g
Working temperature -30℃ to +85℃
Rating::
Pin definition and Rating
Dimensions::
Mechanic Dimensions
Usage
With Arduino
Programming
The demo code is test the module RF, BTBee and Relay part. And the code base on the nRF24L01
library, you need change the pin define as below. If you test the Bluetooth Bee interface, you need
used other Bluetooth device paired with BTBee. Here we used a Android phone with our APP as
client to paired with BTbee(HC-o6), more about paired here.
#include "API.h"
//---------------------------------------------
#define TX_ADR_WIDTH 5
// 5 unsigned chars TX(RX) address width
#define TX_PLOAD_WIDTH 1
// 20 unsigned chars TX payload
//---------------------------------------------
#define CE 9
// CE_BIT: Digital Input Chip Enable Activates RX or TX mode
#define CSN 10
// CSN BIT: Digital Input SPI Chip Select
#define SCK 13
// SCK BIT: Digital Input SPI Clock
#define MOSI 11
// MOSI BIT: Digital Input SPI Slave Data Input
#define MISO 12
// MISO BIT: Digital Output SPI Slave Data Output, with tri-state option
#define IRQ 8
// IRQ BIT: Digital Output Maskable interrupt pin
//*********************************************
#endif
First, you need enter AT mode in accordance with the above method. Then, there are three ways
through which we use Serial port send command to Bluetooth Shield.
Case1. Direct connect to Arduino main board Serial port, DIN to RX_H(D0) , DOUT to TX_H(D1)
but it need you remove the MCU chip.
Case2. Setting the Bluetooth shield’s jumper connect: DIN to TX_H(D1) , DOUT to RX_H(D0).
So this way just for you has perfect code and don’t need monitor from serial port, because you
can’t see anything from serial port tool.
Case3. Use Software Serial library to define D2 and D3 as a virtual serial port TX and RX. By this
way, you can use Arduino’s Serial Monitor to Monitor operation of the code.
#define rxPin 2
#define txPin 3
void Callback()
{
Serial.println("-------> Callback Send AT");
mySerial.print("AT");
}
void setup()
{
// define pin modes for tx, rx, led pins:
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(9600);
Serial.begin(9600);
void loop()
{
int i = 0;
char someChar[32] = {0};
// when characters arrive over the serial port...
if(Serial.available()) {
Serial.println();
Serial.print("-------> ");
do{
someChar[i++] = Serial.read(); // Note HC-06 end not '/r/n', direct input "AT"
command from Serial port
}while (Serial.available() > 0);
mySerial.print(someChar);
Serial.println(someChar);
}
while(mySerial.available())
Serial.println((char)mySerial.read());
}
If you used Arduino Mage1280/2560 there are some different.Please note the NewSoftSerial
library about Mage2560 explanation in SoftwareSerial.cpp :
// Specifically for the Arduino Mega 2560 (or 1280 on the original Arduino Mega)
// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive
pins)
// Only pins available for RECEIVE (TRANSMIT can be on any pin):
// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me)
// Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
That's mean the library do not support D0-D7 as receive pins, just could use pins:10, 11, 12, 13,
50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 for receive. So there are two way to resolve it, but all
need external jumper wires.
First method: Change the define of rxPin and txPin. Jumper wires connect DOUT-D10, DIN-D11.
#define rxPin 10
#define txPin 11
Second method: Use the others Hardware Serialport because of Mage there are 4 hardware
serialport. Jumper wires connect DOUT-RX1(D19) DIN-TX1(D18)
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
}
void loop()
{
int i = 0;
char someChar[32] = {0};
// when characters arrive over the serial port...
if(Serial.available()) {
Serial.print("-------> ");
do{
someChar[i++] = Serial.read();
}while (Serial.available() > 0);
Serial1.println(someChar);
Serial.println(someChar);
}
while(Serial1.available())
Serial.print((char)Serial1.read());
}