nanoFramework.Iot.Device.Relay4 1.1.141

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Relay4 --version 1.1.141                
NuGet\Install-Package nanoFramework.Iot.Device.Relay4 -Version 1.1.141                
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="nanoFramework.Iot.Device.Relay4" Version="1.1.141" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nanoFramework.Iot.Device.Relay4 --version 1.1.141                
#r "nuget: nanoFramework.Iot.Device.Relay4, 1.1.141"                
#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.
// Install nanoFramework.Iot.Device.Relay4 as a Cake Addin
#addin nuget:?package=nanoFramework.Iot.Device.Relay4&version=1.1.141

// Install nanoFramework.Iot.Device.Relay4 as a Cake Tool
#tool nuget:?package=nanoFramework.Iot.Device.Relay4&version=1.1.141                

Module and Unit 4 Relay - I2C relay

Module and Unit 4 Relay are a realys that can be piloted thru I2C. They are available with M5Stack.

Documentation

  • The 4 Relay Module documentation can be found here
  • The 4 Relay Unit documentation can be found here

Usage

Important: make sure you properly setup the I2C pins especially for ESP32 before creating the I2cDevice, make sure you install the nanoFramework.Hardware.ESP32 nuget:

//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the I2C GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);

For other devices like STM32, please make sure you're using the preset pins for the SPI bus you want to use. The chip select can as well be pre setup.

using Iot.Device.Relay;
using System.Device.I2c;
using System.Threading;

Unit4Relay unit4Relay = new(new I2cDevice(new I2cConnectionSettings(1, Base4Relay.DefaultI2cAddress)));
// This will synchronize the led with the relay
unit4Relay.SynchronizedMode = true;
// Set relay 2, the led 2 should be on
unit4Relay.SetRelay(2, State.On);
// Set back the asyn modo
unit4Relay.SynchronizedMode = false;
// Set relay 1, the led 1 should be off while the relay on
unit4Relay.SetRelay(1, State.On);
// Set led 0 to on, the relay should be off
unit4Relay.SetLed(0, State.On);
Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.673 78 10/23/2024
1.1.631 114 8/28/2024
1.1.570 119 6/14/2024
1.1.436 268 11/10/2023
1.1.431 130 11/10/2023
1.1.329 173 5/26/2023
1.1.313 144 5/12/2023
1.1.297 154 5/3/2023
1.1.203 323 12/28/2022
1.1.141 398 10/25/2022
1.1.82 461 9/14/2022
1.0.102.2032 419 6/23/2022
1.0.2 425 4/19/2022
1.0.1.9945 405 7/8/2022