Warnings

The RELAYplate2 is designed to switch potentially lethal voltage levels. When handling the wires and loads that carry these voltages always keep this warning in mind:RC169-Danger-High-Voltage

Please read and remember the following warnings before using the RELAYplate2:

  1. Every RELAYplate2 has a small shield on the bottom that protects the user from potentially high voltages. This shield is held on by five screws. DO NOT REMOVE THIS SHIELD. Doing so will expose you, and the rest of your circuitry to potentially lethal voltage levels.
  2. The RELAYplate2 has been designed to keep both the user and the user's electronics safe from high voltages in the event of a single point failure. DO NOT ATTEMPT TO MODIFY ANY OF THE CIRCUITRY ON THE RELAYplate2. Doing so will expose you, and the rest of your circuitry to potentially lethal voltage levels.
  3. Whenever attaching wires and loads to the RELAYplate2 terminal blocks, ENSURE THAT ALL POWER IS OFF. Do not attempt to attach live wires to the RELAYplate2. Doing so will expose you, and the rest of your circuitry to potentially lethal voltage levels.
  4. When preparing a wire for use with a terminal block on the RELAYplate2:
    • Never use a wire gauge greater than 14 or less than 22. Exceeding these limits can expose you, and the rest of your circuitry to potentially lethal voltage levels.
    • Strip off no more than 6mm (1/4") of insulation off the end of the wire that will attach to the RELAYplate2.
    • When inserting wires into the terminal blocks on the REALYplate2, make sure that the insulation completely covers the wire and that no wire is exposed after insertion.
    • Before you apply power to your circuit, inspect your connections and ensure that no wire is exposed on the terminal blocks. Also make sure that the wires and terminals on your load are protected.
  5. Do not exceed an AC voltage of 250VAC or a current greater than 5 amps.
  6. Do not exceed a DC voltage of 30VDC or a current greater than 5 amps.
  7. Be smart and keep others away from your work area while setting up your RELAYplate2
  8. Be even smarter and post warnings about potentially hazardous voltages near your RELAYplate2 setup.

OK, we're done with the warnings, let's learn about how to use your new RELAYplate2.

Basic Features of the RELAYplate2

Shown below are the major features of the RELAYplate. The two most obvious sets of features are the seven relays and the seven screwless terminal blocks. There are also seven LEDs labeled K1 through K7 which indicate to the user which relays are in the "on" state.

Unique to the RELAYplate2 are a combination of features that were added for safety. These include:

  1. The slots in the board. These provide an isolation barrier between the low voltage side of the board and the high energy side of the board.
  2. A small power supply that provides isolated power for the relay coils
  3. The small "shield" on the bottom of the RELAYplate that prevents the user from accidentally coming into contact with potentially hazardous voltages.

Relay coils require a substantial amount of power and if you only have a single RELAYplate2 connected to your Raspberry Pi then there should be enough power available to drive your board. However, your RPi power supply may not have enough power to drive more than a single RELAYplate2. In the event that you need two or more RELAYplates on your stack of Pi-Plates, we STRONGLY RECOMMEND using our POWERplate with a 4 amp 5VDC supply.

Setting the Address

The RELAYplate2 has a six-pin header which is used for setting its address. This header is highlighted in the descriptive diagram above. When shipped, the address is set to zero as shown below. If you only plan to use a single RELAYplate2 on your stack then here is no need to change this setting. However, if you use two or more then you will need to provide each RELAYplate2 a unique address by arranging the headers as shown below:

Attaching a Load to the RELAYplate2

Think of a relay as a programmable switch. As you know, a switch is a device that controls the power reaching a load. The load can be something like a heater, a light bulb, a motor, or an alarm. The power can be the AC coming from your wall socket or DC from a lead acid battery. By convention, the "hot" wire is the side of the power connection that is usually switched. For AC the hot wire is referred to as "line" while for DC this would be the positive terminal of a battery or power supply. Traditionally, relays are designated with the letter K. This can be seen in how we labelled the terminal blocks associated with K1 through K8 in the image below:

Below is a simple schematic of a lightbulb connected to an AC plug through relay K6 on the RELAYplate2. Note that the line or "hot" wire is routed from the plug to one side of the terminal block for the K3 relay. Connecting loads this way reduces the exposure of potentially lethal voltages to the users.

Once you have made these connections and verified that the wires are securely and safely attached to the terminal blocks, plug the power connector into a wall socket and enter the following commands:

  1. In the first line we are launching the Python3 command line environment.
  2. After Python launches, we get the familiar triple chevron. The next step is to load the RELAYplate2 module and assign it the alias of RELAY2.
  3. Next we verify that there is a RELAYplate2 at address zero by requesting the ID string.
  4. Finally, we send the relayON command to K3.

Assuming everything is connected properly, the light bulb should turn on. To turn the light bulb off simply enter RELAY2.relayOFF(0,6). To cycle the power off and on with a single command enter RELAY2.relayTOGGLE(0,6).

These three commands will likely be the ones you use the most. However, see the instruction set below for additional commands to control your RELAYplate2.

The RELAYplate2 Command Set

A summary of the Python RELAYplate2 commands are shown below.

RELAY Control Functions

relayON(addr,relay) - turns on (closes) the specified relay

relayOFF(addr,relay) - turns off (opens) the specified relay

relayTOGGLE(addr,relay) - "toggles" state of specified relay. If relay is on, this command will turn it off. If relay is off, this command will turn it on. Use this command to blink a lamp off and on.

relayALL(addr,value) - used to control the state of all relays with a single command. "value" is an 8 bit number with each bit corresponding to a relay. Bit 0 is relay 1, bit 1 is relay 2, and so on. To turn all the relays on at once, use the number 255 for the value.

relaySTATE(addr) - Returns a 7-bit number with the current state of each relay. Bit 0 is relay 1, bit 1 is relay 2, and so on. A "1" in a bit position means that the relay is on and zero means that it's off.

LED Control Functions

setLED(addr) - turn on the LED

clrLED(addr) - turn off the LED

toggleLED(addr) - if LED is on, turn off. If LED is off, turn on.

System Level Functions

getID(addr) - returns Pi-Plate descriptor string

getFWrev(addr) - return FW revision in byte format

getHWrev(addr) - return HW revision in byte format

getPMrev() - returns revision of python module

getADDR(addr) - return address of Pi-Plate. Used for polling available boards at power up.

RESET(addr) - set RELAYplate2 to power-on state. Turns all relays off.

Definitions

addr: Address - RELAYplate2s have jumpers on the board that allow their address to be set to a value between 0 and 7.

relay: Each RELAYplate2 has seven individually addressable relays numbered 1 through 7.

value: some commands require or return a seven bit value that can range from 0 to 127.

Using Node-RED

The Pi-Plate palette includes support for the RELAYplate2 in the RELAY node. The screenshot below shows a very simple flow where we we feed ON, OFF, and TOGGLE inputs into each of the eight relays:

The compact code for this flow is:

[{"id":"3bd9e6939f83bb73","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"30339d76a2bf0479","type":"ppRelay","z":"3bd9e6939f83bb73","config_plate":"0ea7db15a73aa83b","name":"","relay":"1","x":780,"y":140,"wires":[[]]},{"id":"10ba40c475e58442","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":580,"y":100,"wires":[["30339d76a2bf0479"]]},{"id":"e352cdd9f021d42b","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":580,"y":140,"wires":[["30339d76a2bf0479"]]},{"id":"436c519dcfed13b4","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":580,"y":180,"wires":[["30339d76a2bf0479"]]},{"id":"deb531d96ad53202","type":"ppRelay","z":"3bd9e6939f83bb73","config_plate":"0ea7db15a73aa83b","name":"","relay":"2","x":960,"y":240,"wires":[[]]},{"id":"7c91bed44d05386b","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":760,"y":200,"wires":[["deb531d96ad53202"]]},{"id":"a475e8c95c8edb7d","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":760,"y":240,"wires":[["deb531d96ad53202"]]},{"id":"3e9ce1cba545c870","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":760,"y":280,"wires":[["deb531d96ad53202"]]},{"id":"3da1ef2223d5e5ae","type":"ppRelay","z":"3bd9e6939f83bb73","config_plate":"0ea7db15a73aa83b","name":"","relay":"3","x":780,"y":340,"wires":[[]]},{"id":"94e903d8cac671f7","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":580,"y":300,"wires":[["3da1ef2223d5e5ae"]]},{"id":"24edcdecd8981777","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":580,"y":340,"wires":[["3da1ef2223d5e5ae"]]},{"id":"0d4f95f4fc81279b","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":580,"y":380,"wires":[["3da1ef2223d5e5ae"]]},{"id":"4086889124ac1aee","type":"ppRelay","z":"3bd9e6939f83bb73","config_plate":"0ea7db15a73aa83b","name":"","relay":"4","x":950,"y":440,"wires":[[]]},{"id":"aeaeea2e9348f4c5","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":750,"y":400,"wires":[["4086889124ac1aee"]]},{"id":"2dbfefc5b5e77d6e","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":750,"y":440,"wires":[["4086889124ac1aee"]]},{"id":"38ee6b7d4bf0818b","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":750,"y":480,"wires":[["4086889124ac1aee"]]},{"id":"4c3e9026e005b4a5","type":"ppRelay","z":"3bd9e6939f83bb73","config_plate":"0ea7db15a73aa83b","name":"","relay":"5","x":780,"y":540,"wires":[[]]},{"id":"166552e19df37953","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":580,"y":500,"wires":[["4c3e9026e005b4a5"]]},{"id":"7515636ef6a26225","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":580,"y":540,"wires":[["4c3e9026e005b4a5"]]},{"id":"e90801e9a9cebe55","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":580,"y":580,"wires":[["4c3e9026e005b4a5"]]},{"id":"d59ab9aa8167074d","type":"ppRelay","z":"3bd9e6939f83bb73","config_plate":"0ea7db15a73aa83b","name":"","relay":"6","x":960,"y":640,"wires":[[]]},{"id":"1f61507394b3380f","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":760,"y":600,"wires":[["d59ab9aa8167074d"]]},{"id":"1bfce0560c4a4410","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":760,"y":640,"wires":[["d59ab9aa8167074d"]]},{"id":"300f0b32cc1c102d","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":760,"y":680,"wires":[["d59ab9aa8167074d"]]},{"id":"0ad8541f0e8ec9f7","type":"ppRelay","z":"3bd9e6939f83bb73","config_plate":"0ea7db15a73aa83b","name":"","relay":"7","x":780,"y":740,"wires":[[]]},{"id":"dfa6b9fba4f3535e","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":580,"y":700,"wires":[["0ad8541f0e8ec9f7"]]},{"id":"cb29a6f12e8068a4","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":580,"y":740,"wires":[["0ad8541f0e8ec9f7"]]},{"id":"0b84351b7d3205c3","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":580,"y":780,"wires":[["0ad8541f0e8ec9f7"]]},{"id":"cac580966b02b817","type":"ppRelay","z":"3bd9e6939f83bb73","config_plate":"0ea7db15a73aa83b","name":"","relay":"8","x":950,"y":840,"wires":[[]]},{"id":"46c1a2a3c878448d","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":750,"y":800,"wires":[["cac580966b02b817"]]},{"id":"f0e326af6e1606e1","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":750,"y":840,"wires":[["cac580966b02b817"]]},{"id":"d45c12227554f230","type":"inject","z":"3bd9e6939f83bb73","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":750,"y":880,"wires":[["cac580966b02b817"]]},{"id":"0ea7db15a73aa83b","type":"pi_plate","model":"RELAYplate2","address":"0"}]

Stacking the RELAYplate2

The coils in relays can be power hungry devices. For example, each of the relay coils on the RELAYplate2 pulls about 40mA. If we assume that the relay power supply is pretty efficient then, when all relays are in the ON state, about 300mA of current will be required for the coils. By default, the RELAYplate2 is set to receive power from the 5 volt supply of the Raspberry Pi. But, if you stack more than two RELAYplate2s and turn on all the relays, the RPi power supply will possibly be overloaded and it will start to "droop." The best case result of this will be a colorful square appearing on your screen. The worst case will be that your RPi resets (that's bad). Therefore we recommend the addition of our POWERplate ans a stiff, 5VDC power supply (>3amps) if you plan to use multiple RELAYplate2s on your stack.

A Quick Refresher on Relays

Simply put, a relay is an electromechanical device that allows a high power load to be controlled with a low power circuit. The images below show a cross section of a relay very similar to what is on the RELAYplate2. The first image shows the relay when the coil is deactivated. In this situation, the armature is pulled up by the spring placing the common terminal in contact with the normally closed terminal. Due to space constraints, the normally closed terminal is not used on the RELAYplate2.

NC RELAY

When a small voltage is applied to the coil, the current produces a magnetic field in the core which pulls down the armature. When this happens, the common terminal comes in contact with the normally open terminal.

NO RELAY

Below is a photograph that shows these components in an actual relay.

Relay_Parts