nanoFramework.Device.OneWire
1.4.5
Prefix Reserved
See the version list below for details.
dotnet add package nanoFramework.Device.OneWire --version 1.4.5
NuGet\Install-Package nanoFramework.Device.OneWire -Version 1.4.5
<PackageReference Include="nanoFramework.Device.OneWire" Version="1.4.5" />
paket add nanoFramework.Device.OneWire --version 1.4.5
#r "nuget: nanoFramework.Device.OneWire, 1.4.5"
// Install nanoFramework.Device.OneWire as a Cake Addin #addin nuget:?package=nanoFramework.Device.OneWire&version=1.4.5 // Install nanoFramework.Device.OneWire as a Cake Tool #tool nuget:?package=nanoFramework.Device.OneWire&version=1.4.5
Welcome to the .NET nanoFramework 1-Wire® Class Library repository
Build status
Component | Build Status | NuGet Package |
---|---|---|
nanoFramework.Device.OneWire |
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.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.14.1)
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 | 864 | 8/1/2024 |
1.4.14 | 1,939 | 11/9/2023 |
1.4.8 | 4,761 | 12/22/2022 |
1.4.5 | 314 | 12/22/2022 |
1.3.4 | 3,003 | 3/29/2022 |
1.3.4-preview.17 | 141 | 3/28/2022 |
1.3.4-preview.15 | 139 | 3/17/2022 |
1.3.4-preview.14 | 132 | 3/14/2022 |
1.3.4-preview.13 | 197 | 2/25/2022 |