📦 nanoFramework 1-Wire Class Library
Перейти к файлу
josesimoes 53bca2bafd Remove private feed from nuget config
***NO_CI***
2024-08-01 11:57:30 +01:00
.github/workflows Work CI-CD 2022-12-27 16:39:57 +00:00
assets Rename to nanoFramework.Device from Devices (#83) 2022-02-25 10:35:19 +00:00
config Rename to nanoFramework.Device from Devices (#83) 2022-02-25 10:35:19 +00:00
nanoFramework.Device.OneWire Update 1 NuGet dependencies 2024-06-06 01:04:06 +01:00
.github_changelog_generator Rename to nanoFramework.Device from Devices (#83) 2022-02-25 10:35:19 +00:00
.gitignore Rework 1-Wire implementation (#84) 2022-02-25 13:51:36 +00:00
CHANGELOG.md Update CHANGELOG for v1.4.14 2023-11-09 12:35:21 +00:00
LICENSE.md Work CI-CD 2021-11-24 15:59:06 +00:00
NuGet.Config Remove private feed from nuget config 2024-08-01 11:57:30 +01:00
README.md Work CI-CD (#90) 2022-10-24 13:09:37 +01:00
azure-pipelines.yml Work CI-CD 2024-01-20 21:54:25 +00:00
nanoFramework.Device.OneWire.DELIVERABLES.nuspec Rename to nanoFramework.Device from Devices (#83) 2022-02-25 10:35:19 +00:00
nanoFramework.Device.OneWire.nuspec Update 1 NuGet dependencies 2023-11-09 12:20:52 +00:00
nanoFramework.Device.OneWire.sln Rename to nanoFramework.Device from Devices (#83) 2022-02-25 10:35:19 +00:00
template.vssettings Initial commit 2018-11-07 17:06:52 +00:00
version.json Work CI-CD 2022-12-22 13:42:45 +00:00

README.md

Quality Gate Status Reliability Rating NuGet #yourfirstpr Discord

nanoFramework logo


Welcome to the .NET nanoFramework 1-Wire® Class Library repository

Build status

Component Build Status NuGet Package
nanoFramework.Device.OneWire Build Status NuGet

1-Wire® bus

1-Wire® it's a communication protocol, property of Maxim Semiconductor. You can read the technical details about it on this guide.

.NET nanoFramework implementation

Our low level implementation of the 1-Wire communication uses an UART to achieve precise timing with the less possible burden on the MCU. For that reason it requires an UART and shunting together it's RX and TX pins. Depending on the bus length and impedance it may be required connecting an external pull-up resistor to provide the necessary signalling for 1-Wire communication.

Important: If you're using an ESP32 device it's mandatory to configure the UART2 pins before creating the OneWireHost. To do that, you have to add a reference to nanoFramework.Hardware.ESP32. In the code snippet below we're assigning GPIOs 21 and 22 to UART2. Also note that UART2 it's referred as COM3 in C#.

////////////////////////////////////////////////////////////////////////
// Configure pins 21 and 22 to be used in UART2 (that's refered as COM3)
Configuration.SetPinFunction(21, DeviceFunction.COM3_RX);
Configuration.SetPinFunction(22, DeviceFunction.COM3_TX);

Take note, on some ESP32 development kits, the pins you're planning on using for UART2 could be used for internal purposes. For example, development kits based on either ESP32-WROOM-32 or ESP32-WROVER-E can have the same pinouts and silkscreen. If the kit is based on ESP32-WROVER-E the GPIOs 17 and 16 are used to address its extended memory (PSRAM), and cannot be used for other purposes, event though they are present as external pins. You can use any other GPIO pins that's free for UART2 pins using Configuration.SetPinFunction.

For other devices, like STM32 ones, there is no need to configure the GPIO pins. You have to find in the respective device documentation what are the UART pins used for 1-Wire.

Usage examples

To connect to a 1-Wire bus and perform operations with the connected devices, one has to first instantiate the OneWireHost.

OneWireHost _OneWireHost = new OneWireHost();

To find the first device connected to the 1-Wire bus, and perform a reset on the bus before performing the search, the following call should be made:

_OneWireHost.FindFirstDevice(true, false);

To write a byte with the value 0x44 to the connected device:

_OneWireHost.WriteByte(0x44);

To get a list with the serial number of all the 1-Wire devices connected to the bus:

var deviceList = _OneWireHost.FindAllDevices();

foreach(byte[] device in deviceList)
{
    string serial = "";

    foreach (byte b in device)
    {
        serial += b.ToString("X2");
    }

    Console.WriteLine($"{serial}");
}

Feedback and documentation

For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.

Join our Discord community here.

Credits

The list of contributors to this project can be found at CONTRIBUTORS.

License

The nanoFramework Class Libraries are licensed under the MIT license.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.