GHI has a super useful high-power module to control 16 optically isolated relays, the Relay ISOx16.. The relays are Songle SRD-12VDC-SL-C relays.
This solution can be found on my Gadgeteer GitHub repository.
As usual, the setup to my FEZ Spider is easy.
I don’t have a background in electronics, but it only took a little reading to find out to wire the relay. Power goes to the middle pin. The left pin is normally on, and the right pin in normally off. When the switch is activated, the left pin is off, and the right is on. For orientation, look at the relay from the top with the pins on top.
For a simple switch, you only need two wire. Power to the middle pin, and an output wire to normally off pin.
The relay module requires 12V to power. I set my power supply to a 500mv limit. For a test, I’m using a breadboard to just turn on/off an LED.
The code to run the module is very similar to last weeks Load Module example. The completely undocumented feature was setting the pin. You must use the Relay enumeration and not an integer.
void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
{
if (!activateRelay)
{
relayISOx16.EnableRelay(RelayISOx16.Relay.Relay_9);
activateRelay = true;
}
else
{
relayISOx16.DisableRelay(RelayISOx16.Relay.Relay_9);
activateRelay = false;
}
}
Once you have the event wired to the button and the power setup. It’s a simple way to control any normal home applicance. I’m looking forward to doing some cool light sequencing for the holidays.