Control All the Things in your house with a Circuit Playground Express and a Power Switch Relay. This little power supply is a toggle-able "Smart Plug" that you can use for all kinds of home automation applications.

This relay controller has one plug that's always on (for powering your Circuit Playground).

The other plugs are where it gets interesting. There are two plugs that are normally OFF and one that is normally ON. Activating the relay with the Circuit Playground turns the "on" plug to OFF, and the two "off" plugs to ON. Simple and elegant, yes?

Where it gets really interesting is when you combine this functionality with the inputs and triggers on with the Circuit Playground Express. You can toggle the switches so many ways: 

  • Move, tilt, or shake the Circuit Playground
  • Make a loud sound (like a DIY version of "The Clapper!")
  • A change in ambient light
  • A change in ambient temperature
  • Capacitive touch pads, and things attached to them
  • Circuit Playground's onboard buttons

You can also create timers or combinations of triggers to toggle the outlets. It's safe to use with higher voltage devices like lamps or heaters, too. The sky is the limit.

No soldering is required - and even if you've never programmed anything before, this is a super-easy guide to follow!

Parts

A Black woman's manicured hand holds a round microcontroller with lit up LEDs.
Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and...
$24.95
In Stock
Controllable Four Outlet Power Relay Module
Say goodbye to hazardous high voltage wiring and create the Internet of Things with safe, reliable power control....
$39.95
In Stock
5V 2.5A Switching Power Supply with 20AWG MicroUSB Cable
Our all-in-one 5V 2.5 Amp + MicroUSB cable power adapter is the perfect choice for powering single-board computers like Raspberry Pi, BeagleBone, or anything else that's...
Out of Stock
Close up angled shot of a LED strip attached and powered by a circuit playground.
You have a Circuit Playground Express, and want to connect some wires to it for adding LEDs or sensors or speakers? You can use our...
$1.50
In Stock

You'll Also Need

  • A small flat-head screwdriver
  • A small phillips-head screwdriver OR soldering iron (if you're not using the bolt-on kit)

A Note about On/Off Switched Devices

This power relay turns its outlets on and off -- that's all it does. We were trying this with various things around the house, and discovered that a lot of modern electronic devices don't come on automatically when their power plug is activated. If it's got an on/off switch, it often requires a button press to come to life, and this relay won't press the "on" button for you, it'll simply feed power. So keep that in mind when you're planning your project.

Power Switch Relay Features:

  • A single input signal to switch four outlets: 1 always on + 1 normally on + 2 normally off.
  • Universal control voltage 3-60VDC or 12-120VAC, or connect directly to a 12V, 48VDC, or even 120VAC circuit.
  • Optical isolation, relay, hysteresis and de-bounce protection for added safety.
  • A large MOV used to clamp surges for clean 90-140 AVC power.
  • Durable SPDT control relay rated at 30/40A. More than 400k operations at 12A or 2million+ at 5A.
  • A 12A thermal safety circuit breaker switch prevents overloads.
  • Standard 19" C13 detachable cord included.
  • Mounting tabs
  • This power relay is professionally built and tested.

You'll need a small flat-head screwdriver, and a small phillips head screwdriver (if you're using the bolt-on kit) or a soldering iron (if you're not).

On the side of the power strip is a small green wire connector. Pull that little guy out. Pliers can be your friend if it doesn't slide out easily.

Notice the markings on the box, above the connector. This little diagram tells you which wire is which.

Cut a white and a black wire to length. The length depends on your project -- if you're planning to mount the Circuit Playground someplace far away from the power switch, or use the motion triggers, you'll want to use pretty long wires. If you are planning to use a sound trigger, you can use shorter wires. I made mine the same length as my power cord (about a meter) so I'd have options.

Unscrew both of the little screws all the way. Stick the white wire into the + side and the black wire into the - side. (Labels are printed on the relay box, don't get them mixed up!). Tighten the screws down so the wires stay put.

Stick the connector back in, and double check you've got white on the left, and black on the right. Give the wires a tug so you're sure they're secure.

Strip a bit of shielding from the other end of the wires. Attach the white wire to pin A1 and the black wire to GND on the Circuit Playground. Secure the wires with the bolt-on kit, or solder them in place.

If you're using the bolt-on kit, it's best to thread the wire through the hole first and then insert the screw, rather than winding the wires around the screw head. The wires will stay attached better if you do it this way, rather than the "traditional" around-the-head method.

Note: Do not use pin A0. It is connected to the onboard speaker so it's not so good for switching things. The rest of the analog pins, including A1, work very well.

Finally, connect your USB power cord to the Circuit Playground's USB port and plug it into the unmarked outlet -- this one is always on so works great for powering your Circuit Playground.

Microsoft MakeCode for Adafruit is a web-based code editor for physical computing. It provides a block editor, similar to Scratch or Code.org, and also a JavaScript editor for more advanced users. 

This means you can drag and drop functionality that triggers the Circuit Playground Express' onboard inputs without ever writing a single line of code. 

We've provided three different sample projects: one using the light sensor to turn a light on at dusk, one using the motion sensor to activate a light and then turn it off a few seconds later, and the sound sensor to make a "clapper" style toggle switch.

Once you decide what you'd like your project to do, you can edit the code to customize it with your own lights, sounds, and sensitivities. Then, click the Download button on the MakeCode site to download your customized code.

Plug the Circuit Playground into your computer and drag the downloaded file onto the CPLAYBOOT drive that appears to make the Circuit Playground run the code. 

Here's a code sample that triggers the relay when the ambient light in the room changes. You can set a threshold for how dark or bright you want it to get, so it's easy to customize for a lot of different applications.

The one gotcha with using light sensors to turn lights on and off is that when it's dark enough to trigger the sensor, and you use the sensor to turn on a light, then it's no longer dark.. and so the light turns off again. It's sort of a chicken-and-egg problem. So in practice, you may want to use the light trigger for turning lights ON, then use a different trigger for turning them OFF.

How it Works

The magic happens with the digital write pin A0 to low block, located under ADVANCED > PINS

What it's doing is sending a signal through the white wire you hooked up to pin A1 and either connecting or disconnecting it to GND. The power switch relay can read the difference, and that's how it knows to switch the outlets on or off.

Once you've customized your code, click the Download button at the bottom of the screen. Plug your Circuit Playground into your computer via the USB port. The lights on the face will turn green (if they don't, click the tiny "reset" button in the center of the board) and a drive will appear on your computer called CPLAYBOOT

To program your Circuit Playground, drag the file you downloaded onto this drive and the code will start running.

If you're having trouble, head over to the MakeCode Beginner Guide for more tips and troubleshooting.

This code sample toggles the switch on or off whenever a loud sound is heard. It also lights up the Circuit Playground's onboard lights for just a moment, to give more feedback when the switch is triggered.

This is a great example of using MakeCode to create a toggle on/off switch with just a few blocks and an if/then statement. We've created a variable called switchOn which allows the Circuit Playground to "remember" whether the light is on or off, and toggle the power outlets accordingly.

Once you've customized your code, click the Download button at the bottom of the screen. Plug your Circuit Playground into your computer via the USB port. The lights on the face will turn green (if they don't, click the tiny "reset" button in the center of the board) and a drive will appear on your computer called CPLAYBOOT

To program your Circuit Playground, drag the file you downloaded onto this drive and the code will start running.

If you're having trouble, head over to the MakeCode Beginner Guide for more tips and troubleshooting.

This code turns the power relay ON when the Circuit Playground is moved or shaken. It then starts a countdown timer, and when the time runs out, it switches the power relay to OFF again.

We used this as a closet light. The Circuit Playground is mounted to the door, and when the door is opened the light in the closet comes on, then turns itself off a few seconds later.

The timer code is based on the Game Clock code, so if you want to delve into how it works, check that guide out here

You can change the duration of the countdown timer by changing the timer variable.  And you can change the countdown light color by choosing your favorite in the set pixel color block.

If you want to change the sensitivity or the type of motion being sensed, there are lots of options available in the input block. Test a few out and see what works best for you.

Once you've customized your code, click the Download button at the bottom of the screen. Plug your Circuit Playground into your computer via the USB port. The lights on the face will turn green (if they don't, click the tiny "reset" button in the center of the board) and a drive will appear on your computer called CPLAYBOOT

To program your Circuit Playground, drag the file you downloaded onto this drive and the code will start running.

If you're having trouble, head over to the MakeCode Beginner Guide for more tips and troubleshooting.

This guide was first published on Apr 21, 2020. It was last updated on Mar 08, 2024.