.NET implementations that help for better interaction with various IoT devices (LED, displays, keyboards, sensors, etc).
- Platform: netstandard2.0;
- Distributed via NuGet (check out Menaver.IoT.Devices)
- This repository leverages Github Actions (GHA);
- 💡 Light-emitting diode (LED)
- ⌨️ Matrix Keyboard M×N
- 📟 Liquid-crystal display (LCD): PCF8574, PCF8575, PCA8574, PCA8575
- 🌡️ Humidity & Temperature Sensor (DHT): DHT11, DHT12, DHT21, DHT22
More examples of using the IoT devices can be found in the test project Menaver.IoT.Devices.Tests.
![](https://private-user-images.githubusercontent.com/12029392/335632798-b9fb32cd-c463-416d-9a9c-fa478ae991c9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYwMDE1MzQsIm5iZiI6MTcyNjAwMTIzNCwicGF0aCI6Ii8xMjAyOTM5Mi8zMzU2MzI3OTgtYjlmYjMyY2QtYzQ2My00MTZkLTlhOWMtZmE0NzhhZTk5MWM5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEwVDIwNDcxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYwYjc5ZTkxMjA2YjU3MzRlMTBlYzMzNzczM2Y2NDE0ZGNlN2I3MDE4ZTM4NDNjYTFmMGJlOTFlODcxY2QxZWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.djHPtelNgrr4yVhhOlKwV9ZzHF-1GOIFy-XTQt-ShrY)
List<Led> leds = new()
{
new Led(4, Color.Red, false),
};
using var ledPanel = new LedPanel(leds);
ledPanel.SetAll(Color.Red);
await Task.Delay(300);
ledPanel.ResetAll();
await Task.Delay(300);
ledPanel.Toggle(4);
![](https://private-user-images.githubusercontent.com/12029392/335629913-a48ca152-fc2d-48aa-86bc-21ef291892e0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYwMDE1MzQsIm5iZiI6MTcyNjAwMTIzNCwicGF0aCI6Ii8xMjAyOTM5Mi8zMzU2Mjk5MTMtYTQ4Y2ExNTItZmMyZC00OGFhLTg2YmMtMjFlZjI5MTg5MmUwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEwVDIwNDcxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRhOGE0YjQzMzU4NDIxMjRlOTFjZDcyYzc1Y2ZiOGVjMjYyOTdiZGJiODQ5OWZkNGMyZTlkZjk0MDg3MjEzN2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Qkjh7KWBqqhOci9KkFyqQbyNYjpORpavXaAyWu3Teno)
using var dht = new Dht(dataPin: 4, DhtDevice.Dht22);
Console.WriteLine("Waiting for the sensor to response...");
while (true)
{
var temperature = await dht.GetTemperatureAsync(TemperatureUnit.Celsius, CancellationToken.None);
Console.WriteLine($"Temperature: {temperature:F1}\u00B0C");
var humidity = await dht.GetHumidityAsync(CancellationToken.None);
Console.WriteLine($"Humidity: {humidity:F1}%");
await Task.Delay(1000);
}
![](https://private-user-images.githubusercontent.com/12029392/335634686-87dc0a3f-4be9-48f5-8357-aa5fd436e628.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYwMDE1MzQsIm5iZiI6MTcyNjAwMTIzNCwicGF0aCI6Ii8xMjAyOTM5Mi8zMzU2MzQ2ODYtODdkYzBhM2YtNGJlOS00OGY1LTgzNTctYWE1ZmQ0MzZlNjI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEwVDIwNDcxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIzZDJkMmNhYTcyOTRhYWIzNjk3YWUzNjIwMWY0OGRlYjkwNmMwMjgwNTkwMTNkOTdiMGQ4YzY5Nzg1YzBhNGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Waa_afOtSIAZ6pBH5zVO1OlnromxpEYAxzcyAC8i2NA)
private static readonly int[] _inputs = { 18, 23, 24, 25 };
private static readonly int[] _outputs = { 10, 22, 27, 17 };
private static readonly char[,] _keyMap =
{
{ '1', '2', '3', 'A' },
{ '4', '5', '6', 'B' },
{ '7', '8', '9', 'C' },
{ '*', '0', '#', 'D' }
};
public static async Task<int> RunAsync()
{
using var keypad4x4 = new MatrixKeyboard(_inputs, _outputs, _keyMap);
while (true)
{
var key = await keypad4x4.ReadKeyAsync();
Console.WriteLine($"Key pressed: {key}");
}
}