RLYSHIELD

Relay Shield - Sample Setup
Relay Shield - Sample Code
intRELAY1=D3;
intRELAY2=D4;
intRELAY3=D5;
intRELAY4=D6;
voidsetup()
{
//Initilizetherelaycontrolpinsasoutput
pinMode(RELAY1,OUTPUT);
pinMode(RELAY2,OUTPUT);
pinMode(RELAY3,OUTPUT);
pinMode(RELAY4,OUTPUT);
//InitializeallrelaystoanOFFstate
digitalWrite(RELAY1,LOW);
digitalWrite(RELAY2,LOW);
digitalWrite(RELAY3,LOW);
digitalWrite(RELAY4,LOW);
//registertheParticlefunction
Particle.function("relay",relayControl);
}
voidloop()
{
//Thisloopsforever
}
//commandformatr1,HIGH
intrelayControl(Stringcommand)
{
intrelayState=0;
//parsetherelaynumber
intrelayNumber=command.charAt(1)‐'0';
//doasanitycheck
if(relayNumber<1||relayNumber>4)return‐1;
//findoutthestateoftherelay
if(command.substring(3,7)=="HIGH")relayState=1;
elseif(command.substring(3,6)=="LOW")relayState=0;
elsereturn‐1;
//writetotheappropriaterelay
digitalWrite(relayNumber+2,relayState);
return1;
}
An example API request to this function would look something like this:
POST/v1/devices/{DEVICE_ID}/relay
#EXAMPLEREQUEST
curlhttps://api.particle.io/v1/devices/0123456789abcdef/relay\
‐daccess_token=123412341234‐dparams=r1,HIGH
Relay Shield - Specifications (v3.x.x)
Operating voltage: 7 to 20V DC
Current consumption: 150mA min to 290mA max (at 9V DC)
Relay Max Voltage: 220V AC
Relay Max Current: 10Amp at 125V AC
Relay Part Number: JS1-5V-F
Dimensions: 6.0" x 1.7"
Weight: 80 gms
Drill Template > https://docs.particle.io/assets/images/shields/relay-shield/relay-shield-template.pdf
https://docs.particle.io/datasheets/particleshields/#relayshield101917

RLYSHIELD

Mfr. #:
Manufacturer:
Description:
Other Development Tools Relay Shield
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet