nanoFramework.Device.OneWire 1.3.4-preview.15

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

// Install nanoFramework.Device.OneWire as a Cake Tool
#tool nuget:?package=nanoFramework.Device.OneWire&version=1.3.4-preview.15&prerelease                

Quality Gate Status Reliability Rating License 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
nanoFramework.Device.OneWire (preview) 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 snnipet below we're assigning GPIOs 16 and 17 to UART2.

//////////////////////////////////////////////////////////////////////
// Configure pins 16 and 17 to be used in UART2
Configuration.SetPinFunction(16, DeviceFunction.COM2_RX);
Configuration.SetPinFunction(17, DeviceFunction.COM2_TX);

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.

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 (2)

Showing the top 2 NuGet packages that depend on nanoFramework.Device.OneWire:

Package Downloads
nanoFramework.Iot.Device.Ds18b20

This package includes the .NET IoT Core binding Iot.Device.Ds18b20 for .NET nanoFramework C# projects.

nanoFramework.ClickDrivers

Drivers for MikroElektronika Click boards on nanoFramework.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on nanoFramework.Device.OneWire:

Repository Stars
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
nanoframework/nanoFramework.IoT.Device
📦 This repo includes .NET nanoFramework implementations for various sensors, chips, displays, hats and drivers
Version Downloads Last updated
1.4.22 727 8/1/2024
1.4.14 1,921 11/9/2023
1.4.8 4,694 12/22/2022
1.4.5 311 12/22/2022
1.3.4 2,999 3/29/2022
1.3.4-preview.17 139 3/28/2022
1.3.4-preview.15 138 3/17/2022
1.3.4-preview.14 131 3/14/2022
1.3.4-preview.13 196 2/25/2022