IoT is really taking off these days and options are seemingly endless. Raspberry Pi and Arduino is getting more press and uses by the minute.
.Net Micro Framework is also getting an update these days and it’s still a very nice rapid prototyping platform. Inspired by the resent surge in embedded development I started a small project using a few bits and pieces I got laying around. One of them was a Seeed Quad Relay for .Net Gadgeteer. Unfortunatly Seed have abandoned support for this unit.
I didn’t really want to buy a new relay so I started to look at how to port it to the newer frameworks. Due to a change in how digital output works in .netmf a direct recompile doesn’t work.
In order to compile a proper module you need WIX (Windows Installer XML Toolset). I had a few issues with this and since the source code for the module is dead simple I ended up just including it in the project. That means no visual connection to the mainboard. It was just so easy and fast to do that I couldn’t resist skipping the entire recompile module step.
public class Relay : Gadgeteer.Modules.Module { private DigitalOutput relay1; private DigitalOutput relay2; private DigitalOutput relay3; private DigitalOutput relay4; public Relay(int SocketNumber) { Gadgeteer.Socket socket = Gadgeteer.Socket.GetSocket(SocketNumber, true, this, null); this.relay1 = DigitalOutputFactory.Create(socket, Gadgeteer.Socket.Pin.Three, false, this); this.relay2 = DigitalOutputFactory.Create(socket, Gadgeteer.Socket.Pin.Four, false, this); this.relay3 = DigitalOutputFactory.Create(socket, Gadgeteer.Socket.Pin.Five, false, this); this.relay4 = DigitalOutputFactory.Create(socket, Gadgeteer.Socket.Pin.Six, false, this); } public bool Relay1 { get { return relay1.Read(); } set { relay1.Write(value); } } public bool Relay2 { get { return relay2.Read(); } set { relay2.Write(value); } } public bool Relay3 { get { return relay3.Read(); } set { relay3.Write(value); } } public bool Relay4 { get { return relay4.Read(); } set { relay4.Write(value); } } }