Windows 10 IoT Core
Prerequisites
To get maximum performance from your hardware, please make sure you'll meet the following requirements.
Operating System
We recommend using the latest version of Windows 10 IoT Core. Download the latest version using Windows 10 IoT Core Dashboard.
Development Environment
We recommend keeping Microsoft Visual Studio up to date.
Windows 10 IoT Core Library
You can download the library from NuGet. To do that, go to Visual Studio Solution Explorer, and then right-click to the References. Select Manage NuGet packages. Type "Turta.RelayHAT.RelayDriver" and then install the latest stable version.
You can download the library source code from https://github.com/Turta-io/RelayHAT/tree/master/DriverSource/Windows10IoTCore address.
To use the library, add the following using statement to the top of your C# code.
Then, create an instance of the RelayController class.
Now you're ready to access the library by calling the relayController instance.
Initialization
The library automatically initializes the required components when its instance is being created, so there is no need to do a manual initialization.
Basic Members
Set Relay
Turns the desired relay on or off.
Parameters
Int ch: Relay channel. 1 to 4.
Bool state: Relay state. True or False.
Returns
None
Read Relay State
Reads the desired relay state.
Parameters
Int ch: Relay channel. 1 to 4.
Returns
Bool: Relay state. True or False.
Disposal
To clean up the resources used by the class, call the Dispose() method it when the application is closing.
This method turns all the relays off and then releases the used resources.
Samples
You can copy the example code from https://github.com/Turta-io/RelayHAT/tree/master/Samples/Windows10IoTCore address. There is one example of this sensor.
Relay Controller Sample App
This application demonstrates relay functions. It turns relays on and off in a loop.
To run the example:
Open the sample project you downloaded.
Make sure "ARM" is selected from the solution platforms selection.
Deploy the sample to the Raspberry Pi using the "F5" key.
Sample Code
Result
When you run the sample, the relays turn on one after another and then turn off in the same order.
To stop the application, use the "Stop" button on the Visual Studio.
Last updated