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

// Install Inetkid.Modbus as a Cake Tool
#tool nuget:?package=Inetkid.Modbus&version=

Modbus Library

Modbus library for communication via RS-485 and TCP/IP. Very light and hackable. Support Modbus RTU, Modbus ASCII, Modbus TCP transport; and the role of client, server, master, slave, and gateway. Written in Visual Studio 2022 for .net6.

Quick Start


nuget install Inetkid.Modbus
nuget install Inetkid.Modbus.Rtu
nuget install Inetkid.Modbus.Ascii
nuget install Inetkid.Modbus.Tcp

Communicating with a modbus device

using System.IO.Ports;
using Inetkid.Modbus.Command;

byte deviceId = 1;
ushort address = 0;
ushort length = 2;
using (SerialPort sp = new("COM1") { ReadTimeout = 500, WriteTimeout = 100 })
    // Initialize ModbusCommand to use the modbus RTU protocol
    var command = new ModbusCommand().UseRtu(sp);

    // Set the request content to read the first 2 holding registers (analog output) 
    // and asynchronously execute the command
    var result = command.RequestReadHoldingRegisters(deviceId, address, length).Execute().Result;

    Console.WriteLine("Value at register 400001 is " + result.Registers[0]);
    Console.WriteLine("Value at register 400002 is " + result.Registers[1]);

See examples in

Emulates a modbus device

See examples in

Gateway TCP to RS485

See examples in

Creating device specific adaper

See examples in

Change Log

2023-05-17 Version

Split the functionality of RTU, ASCII and TCP to 3 separate nuget package to optimize the package size.

Changes to the abstract class ModbusAdapter

Bug fixes

For history of changes please refer to the file


Refer to the file


Copyright 2023 Raymond Tan.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


You are welcomed to improve the code. Please visit Targets .net 6 and above. Written in C# for Microsoft Visual Studio 2022.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Inetkid.Modbus:

Package Downloads

Package Description


Package Description


Package Description


Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated 208 1/9/2024
1.2.0 175 1/8/2024 185 5/16/2023 108 5/16/2023
1.0.0 137 4/19/2023