Use a Relay and Motion Detector with CueServer

CueServer 2 provides up to eight low-voltage contact-closure inputs and up to eight low-voltage digital outputs. While these two arrays of ports can be used for many things, in this article we're going to cover how to use them with a relay and motion detector.

For this example, we will be using a simple 5v Relay and a Normally-Closed motion detector.

You can also learn more about Contact Closures here or Digital Outputs here.

The Scenario

You use CueServer to control the house and event lighting in your building. You also have a hallway in this building that uses standard AC (non-DMX) lighting and you'd like to be able to control them with CueServer as well. Ideally, you want to be able to control these lights, but also, you would like to use a motion detector to turn on the lights whenever motion is detected. It's important that the lights don't immediately turn off once the motion stops. There should be about 30 seconds in which the lights remain on without motion before turning off.

The Breakdown

To set up our Relay and Motion detector with CueServer, we will need to program rules for our contact closure to turn on our output whenever contact 1 is opened (motion is detected) as well as perform a script to ensure our lights don’t turn off immediately after motion is no longer detected. We will also need to add rules for when contact 1 is closed to wait 30 seconds and then turn off output one.

Next, we will need to connect our motion detector to contact 1 and our relay to output 1. You can skip ahead to the hardware setup here.

We'll cover this a bit more in-depth below.

The Walkthrough

In order to tell CueServer to take any action upon a contact state-change, we must create a rule. Given we're using a normally-closed motion detector, our first rule will be to set Output 1 to ON whenever the contact is opened.

In effect, whenever motion is detected by the detector, the circuit will be opened. When CueServer detects the opened state of the contact, this rule will automatically act to short output 1 to ground, turning it on. In this case, the relay will be energized and turn on our hallway lights.




Now that our output is set to automatically turn on when the contact is closed, we need to add an additional action to our Is Opened condition by hovering to the right of our last condition and clicking on +THEN.

Next, we add our second condition to Perform Script. This tells the CueServer to turn on Output 1 and perform this script whenever Contact 1 changes to a closed state.

For our script, we will add wait clear. We need to add this command to clear the wait we will initiate in a later step. If we didn't clear the wait, the lights could be turned off even while motion is detected. More on this later.





We've finished setting up our rules for the Is Opened condition. We now need the rules for the Is Closed condition. With this condition, we will use Perform Script once again, however this time, we will input wait 30 output 1 off.

Since we don't want the lights to go off (relay to open) immediately after motion stops being detected, we are using the wait command to tell CueServer to turn off Output one, but only after 30 seconds has passed.

Earlier, we added the command wait clear. The reason we needed to add this was because in the event motion stops being detected, then, within 30 seconds motion is detected once again, we must tell CueServer to cancel the pending action of turning off Output 1 after 30 seconds.


The Hardware Setup


To set up our Motion detector (Normally-Closed), we need to connect the leads. One of the leads will go to the CueServer Ground input, the second lead will go to the CueServer Contact Closure input.

Once connected (see schematic), whenever motion is detected, the path from Ground to the Contact will be broken, in turn, opening the contact.


Next, to connect our Relay, we need to wire our +5V output from CueServer to one input of the relay.

The other input from the relay will be wired directly to our Digital Output.

Once the relay is connected (see schematic), given the rules we programmed earlier, whenever the motion detector breaks the circuit (motion is detected), the Ground will be isolated from the Contact which will open the contact closure and turn on output 1, turning on the relay (and hallway lights).


The full schematic for hardware setup



Have a Tip or Trick you would like to see? Let us know!

The rules we established for contact one will direct CueServer to turn on Digital Output one whenever contact one is opened (motion is detected).

The connection we made with our motion detector will block the transfer of the floating ~3v output to the contact closure whenever motion is detected, opening the contact.

When output one is turned on, the output will short the connection from our cathode to ground, allowing current to flow from our +5V output to the resistor coil, closing the switch, turning on our hallway lights.

The wait time we added will ensure the lights do no abruptly turn off after motion is no longer detected and the wait clear will ensure the lighting corresponds to motion correctly.

If you're interested in connecting a push-button or LED to CueServer, check out our article on Contact Closures and Digital Outputs.