procsys.waveshare8ch 0.1.4

dotnet add package procsys.waveshare8ch --version 0.1.4
                    
NuGet\Install-Package procsys.waveshare8ch -Version 0.1.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="procsys.waveshare8ch" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="procsys.waveshare8ch" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="procsys.waveshare8ch" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add procsys.waveshare8ch --version 0.1.4
                    
#r "nuget: procsys.waveshare8ch, 0.1.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=procsys.waveshare8ch&version=0.1.4
                    
Install procsys.waveshare8ch as a Cake Addin
#tool nuget:?package=procsys.waveshare8ch&version=0.1.4
                    
Install procsys.waveshare8ch as a Cake Tool

Waveshare 8-Channel Relay Examples in C#

This repository contains example code for controlling the Waveshare 8-Channel Relay module using C#. The goal of this project is to provide a simple and clear starting point for developers who want to integrate the relay module into their .NET applications.

Goals

  • Demonstrate how to interface with the Waveshare 8-Channel Relay module using C#.
  • Provide reusable and well-documented code for relay control.
  • Help developers understand the basics of GPIO communication in .NET.

Features

  • Turn individual relays on or off.
  • Control multiple relays simultaneously.
  • Example code for common use cases.

Prerequisites

  • A Waveshare 8-Channel Relay module.
  • A device with GPIO support (e.g., Raspberry Pi).
  • .NET 8.0 or later installed on your system.

Getting Started

These steps must be performed on your raspberry Pi.

  1. Clone this repository: (optional)

    git clone https://github.com/simoncahill/waveshare_8ch_relay_examples.git
    cd waveshare_8ch_relay_examples/cpp
    
  2. Ensure you have the tools required for building C++ libraries, or download a precompiled version from GitHub.

  3. Compile the library for your Raspberry Pi model:

    mkdir build && cd build
    cmake .. -Dchannelselect_BUILD_LIBRARY=ON -Dchannelselect_RASPI5=ON
    make
    
  4. Install the library to your Raspberry Pi:

    sudo make install
    # or extract the library and copy it to your binary's install location
    
  5. Download the NuGet package

    dotnet add package procsys.waveshare8ch
    

Basic Usage

The example code demonstrates how to initialize the relay module and control individual relays. Below is a brief overview:

  • Initialize the Relay Module: Use the provided RelayController class to set up communication with the relay module.
  • Control Relays: Call methods like TurnOnRelay(int relayNumber) or TurnOffRelay(int relayNumber) to control specific relays.

Example Code Snippet

using ChannelSelect;

class Program {

    static void Main() {

        Console.WriteLine($"Channel states: { ChannelSelect.GetChannelStates() }");

    }

}

Tips

  • Ensure the GPIO pins are correctly configured and match the relay module's requirements.
  • Run the application with appropriate permissions to access GPIO (e.g., sudo on Linux).
  • Refer to the Waveshare 8-Channel Relay documentation for hardware setup details.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve the examples.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

[EXPERIMENTAL]
     This is a wrapper around the C++ library for the Waveshare 8 channel relay board.

     This release, v0.1.4, contains internal API changes.