Most control applications require powering things. Refrigerators, heaters, LEDs, thermoelectrics, motors, and solenoids are all examples of things that require power that the Raspberry Pi cannot (or should not) supply.
Now, our philosophy with the CuPID is that it is a lightweight IO board. It’s not loaded with every power output, switch relay, and sensor that you could need. We wanted to keep it small and cheap, so we only added what we thought was really necessary. We may change our mind and isolate the GPIO with mosfets at some point, but the point is still the same: a flexible device that you add IO to as you need it. The other advantage to this approach is that you put power and sensors where you need them, not in the box with the Pi. Run Cat5 wherever you want (and over RF soon enough), and expand wherever you want, leaving your Pi in place. IO are daisy-chainable, so one run of cable can connect multiple devices in the same place!
What we’re building here is the basic powered control output. With a Cat5 cable from the CuPID, it can supply AC (wall power), DC (by swapping out the relay), or anything that will operate on 5V or less. It also accepts an auxiliary control voltage, so you can switch pretty much anything you want. It performs the switching with a 2n7000 mosfet, so whatever you’re switching won’t fry your Pi if it fails. It’s got two COM ports on it, so you can daisy chain several of these guys. Here is the EAGLE layout.
First, let’s start with the input. We’ll go ahead and reprint the CuPID IO here. COM2 and COM3 each have four GPIO on them. An internal DIP switch on the output board will allow you to select one of the GPIO to use. Alternatively, if you need to control multiple devices with one GPIO, just make the same DIP selection on each.
Shown are the ingredients. If you’re going to use the 5V on the com cable to do your switching, you will only need one screw terminal. If you are using a SSR as we are here, then the only reason you really need a current-limiting resistor is to diminish the fail if you manage to short the coil. Remember that a CuPID has an isolated 5V on the COM cable, so you won’t worry about frying your Pi.
- IO Board
- 2 x 8P8C Jacks
- 4 position DIP switch
- 2 x 3.5mm pitch screw terminals
- 2 x 2.54mm (0.1″) two-position jumpers
- Current-limiting resistor (47ohms here)
- 2N7000 NPN mosfet
- Pull-down resistor (10kohm here)
We’re not ones for glorifying soldering in pictorial fashion, so here’s what you get when you’re all done:
Alright. So now we need to get it into a box. What box you use of course depends on what you need to put into it. For this project, we’re going to use a pretty standard solid-state relay (SSR) to switch AC power. This works for a refrigerator, a heater, anything that you can power with single-phase power. Our relay is rated for 25A, but our cable is only 16awg, so you want to keep it under 13A to be safe. This is in line with most household circuits. Our relay and our board fit quite well into the case we use for the CuPID, so we use one of those. It’s a polycase WC23F, which we’ve raved about before. The top is clear, so we can see the nice little LED on the top of our relay. So we head over to the mill and put a couple holes in this thing and see how our board fits.
Even before filing out the cutouts a bit, the fit is pretty good.
Since we’ve got a good fit, now we’ll mount the relay to the bottom of the box. We want to attach this and get our cable entries in place before we mount the board, as it’s a bit of a pain to work around the board and connect to the screw terminals once it’s installed. In the picture below you can see our relay, and following that a multiframe of our cord grip installation process.
For those unfamiliar with cord grips (also cable glands, cable entries, strain relief, and a few more), they are watertight entry points that cinch down on a range of cable sizes. They resist pulling through, so even if you don’t need the weather-resistance, they’re great for keeping everything stationary and exactly where you put it. They’re offered in a variety of sizes and are <$1 for anything but very large sizes. Installation is easy. There are two parts (sometimes with a rubber washer), and you simply need a hole in the surface you are passing through. Check the spec sheet or take a measurement with some calipers of the threads, and put a hole in your surface with a spade bit. All done. The entry holes need not be perfect (and they won’t be with a spade bit and soft plastic), but you should take a quick round file to the edges to at least makes sure that burrs on the surface won’t prevent the flat side of the cord grip from pressing completely against the surface. This will diminish their security and weather resistance. After you have your holes, simple insert them and tighten them up. All done. Here we first drill and countersink two holes from the underside and insert a couple flathead screws, leaving a flush bottom for mounting. After, we slip our power cables through each side. We attach our hot side (we’re using AC here) to the relay contact, connect ground to ground and neutral to neutral with some solderless connectors, and secure the relay with a couple locknuts.
All we have left is to install our board and connect our control wiring to the coil of the relay. Piece of cake. We just connect our load high and low to our control board and to the relay, and reinstall our mounting screws. Short 4-40 screws self-tap into the PCB mounts quite nicely, and we’re done!
And here is what we like like all-together with our top on. We’ll show you some simple applications with this that we have around the house in just a bit.