{"id":13834445,"url":"https://github.com/vgolovanov/ThingsBoardDotNet","last_synced_at":"2025-07-10T04:31:59.462Z","repository":{"id":205175811,"uuid":"349761755","full_name":"vgolovanov/ThingsBoardDotNet","owner":"vgolovanov","description":"ThingsBoardDotNet is a .Net library designed to work with ThingsBoard platform","archived":false,"fork":false,"pushed_at":"2021-07-20T13:42:01.000Z","size":2857,"stargazers_count":2,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-20T19:40:01.483Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vgolovanov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-03-20T15:24:01.000Z","updated_at":"2022-06-18T00:44:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"acc34219-4688-4486-bfe3-769c8fac08ff","html_url":"https://github.com/vgolovanov/ThingsBoardDotNet","commit_stats":null,"previous_names":["vgolovanov/thingsboarddotnet"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vgolovanov/ThingsBoardDotNet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgolovanov%2FThingsBoardDotNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgolovanov%2FThingsBoardDotNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgolovanov%2FThingsBoardDotNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgolovanov%2FThingsBoardDotNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vgolovanov","download_url":"https://codeload.github.com/vgolovanov/ThingsBoardDotNet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgolovanov%2FThingsBoardDotNet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264528742,"owners_count":23623219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T14:00:34.744Z","updated_at":"2025-07-10T04:31:59.094Z","avatar_url":"https://github.com/vgolovanov.png","language":"C#","funding_links":[],"categories":["SDKs and REST clients"],"sub_categories":[],"readme":"# ThingsBoardDotNet\n\n**ThingsBoardDotNet** is a .Net library designed to work with [ThingsBoard](https://thingsboard.io/) platform and allows you to monitor and control IoT devices. At that moment ThingsBoardDotNet works on the following .Net platforms : \n- .Net Core 3.1\n- [.Net nanoFramework](https://nanoframework.net/)\n\n**What is ThingsBoard ?**\nThingsBoard is an open-source IoT platform that enables rapid development, management, and scaling of IoT projects.\nWe recommend to review [what-is-thingsboard](https://thingsboard.io/) page and [getting-started guide](https://thingsboard.io/docs/getting-started-guides/helloworld/).\n\n**Prerequisites**\n\nAny hardware and software platform compatible with [.Net Core](https://docs.microsoft.com/en-us/dotnet/core/install/) and [.Net nanoFramework](https://github.com/nanoframework/nf-interpreter).\n\nYou will need to have ThingsBoard server up and running. The easiest way is to use [Live Demo  ](https://demo.thingsboard.io/signupserver). The alternative option is to install ThingsBoard using [Installation Guide](https://thingsboard.io/docs/user-guide/install/installation-options/).\n\nSample application code written in C# language, that will connect to ThingsBoard server via MQTT protocol to upload telemetry data and listen to RPC commands. All operations are visualized using a built-in customizable dashboard.\n\n**Simple Weather Station on .Net Core**\n\nIn .Net Core application we will not cover sensor drivers and all telemetry data will be emulated by random numbers.\n\n**Simple ESP32 Weather Station With BME280**\n\nWe will use an ESP32 Dev Kit board with .Net nanoFramework and BME280 sensor measuring relative humidity, barometric pressure and ambient temperature. \nAlso this application will allow you to control GPIO of yours .Net device using ThingsBoard RPC widgets.\n\n**Connection diagram**\n\nThe following picture summarizes the connections for this project:\n\n![ESP32 wiring](Essentials/ESP32_wiring.png)\n\nConnect VIN pin to the 3.3V output and connect GND to ground on the ESP32 board. Remaining pins are used for I2C communication. Connect SDA (data line) to IO21 and SCL (clock line) to IO22 on ESP32 board.\n\n**Device provisioning**\n\nThis step contains instructions that are necessary to connect your device to ThingsBoard.\n\nOpen ThingsBoard Web UI (http://localhost:8080) in browser and login as tenant administrator. If you loaded the demo data during TB installation, the next credentials can be used:\n\n- login: tenant@thingsboard.org\n- password: tenant\n\nGo to “Devices” section. Click “+” button and create a device with the name “ESP32 Pico Device”. Set “Device type” to “default”.\n\n![Device](Essentials/device.png)\n\nOnce device created, open its details and click “Manage credentials”.\n\nCopy auto-generated access token from the “Access token” field. Please save this device token. It will be referred to later as **$ACCESS_TOKEN**.\n\n![Credentials](Essentials/credentials.png)\n\n**Provision your dashboard**\n\nDownload the dashboard file using this [link](https://thingsboard.io/docs/samples/esp32/resources/esp32-dht22-temp-and-gpio-dashboard.json). Use import/export instructions [instructions](https://thingsboard.io/docs/user-guide/ui/dashboards/#dashboard-importexport) to import the dashboard to your ThingsBoard instance.\n\n**Creating ESP32 firmware**\n\nTo get started with nanoFramework, follow [Getting Started](https://docs.nanoframework.net/content/getting-started-guides/getting-started-managed.html) tutorial from nanoFramework website.\n\nDownload ThingsBoardDotNet repository from GitHub and open solution in Visual Studio. Open and make default SamplesNanoFramework project. Edit following variables in ThingsBoardGpioAndDHT22Demo.cs file.\n\n```csharp\nprivate static string thingsBoardHost = \"demo.thingsboard.io\";\nprivate static string thingsBoardAccessToken = \"Access_TOKEN\";\nprivate static string wifiSSID = \"REPLACE-WITH-YOUR-SSID\";\nprivate static string wifiApPASSWORD = \"REPLACE-WITH-YOUR-WIFI-KEY\";\n```\n\n Build and Deploy Solution to the ESP32 board from Visual Studio.\n\nWith ThingsBoardDotNet library you can:\n\n\nSubscribe to ***OnRpcRequestTopic*** event to receive RPC calls from ThingsBoard Platform\n```csharp\nthingsBoard.OnRpcRequestTopic += OnRpcRequestTopic;\n```\n\nThe reflection helper class lets you use methods names from c# class as RPC methods called from ThingsBoard.\n```csharp\nReflectionHelper.FindRpcMethods(typeof(ThingsBoard_Rpc_and_Telemetry_Demo));\n```\nConvention names for c# methods can be bypassed by custom attribute ***RpcName***.\n```csharp\n[RpcName(\"getGpioStatus\")]\npublic static void GetGpioStatus(TBRpcRequest rpcRequest){}\n```\n\nEvent handler method will be called when an RPC call is raised from the ThingsBoard application. With reflection helper class RPC name will be found in class either by C# method name or custom attribute ***RpcName***.\n```csharp\n private static void OnRpcRequestTopic(object sender, RpcEventArgs e)       \n{            \n    ReflectionHelper.InvokeRpcMethod(e.RpcRequest);        \n}\n```\nTelemetry publishing\n```csharp\nTBTelemetry telemetry = new TBTelemetry();\ntelemetry.Add(\"temperature\", bme280Sensor.ReadTemperature());\ntelemetry.Add(\"humidity\", bme280Sensor.ReadHumidity());\ntelemetry.Add(\"pressure\", bme280Sensor.ReadPressure());\n                              \nthingsBoard.SendTelemetry(telemetry);\n```\n\n**Data visualization and GPIO control**\n\nFinally, open ThingsBoard Web UI. You can access this dashboard by logging in as a tenant administrator.\n\nIn case of local installation (if the demo data was added during TB installation):\n\n- login: tenant@thingsboard.org\n- password: tenant\nIn case of live-demo server:\n\nlogin: your live-demo username (email)\npassword: your live-demo password\n\nGo to **“Devices**” section and locate “**ESP32 Pico Device**”, open device details and switch to “**Latest telemetry**” tab. If all is configured correctly you should be able to see latest values of *“temperature”* and *“humidity”* in the table.\n\n![Telemetry](Essentials/telemetry.png)\n\nAfter, open **“Dashboards”** section then locate and open **“ESP32 Pico Dashboard”**. As a result, you will see a time-series chart displaying temperature and humidity level (similar to dashboard image in the introduction).\n\nOnce you complete this sample/tutorial, you will see your sensor data on the following dashboard.\n\n![Thingsboard dashboard](Essentials/dashboard.png)\n\nYou should also observe a GPIO control for your device. It consists of two widgets: one is for controlling LED blink speed (in milliseconds) and second for turning individual LEDs on and off.\n\nYou can switch the status of GPIOs using the control panel. As a result, you will see LEDs status change on the device. To control LED blink speed, simply turn a knob and observe a speed change.\n\n.Net nanoFramework and Json.NetMF code credits goes to the [nanoFramework team](https://discord.gg/gCyBu8T).\n\nThingsboard documentation credits goes to the [ThingsBoard team](https://thingsboard.io/company/).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvgolovanov%2FThingsBoardDotNet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvgolovanov%2FThingsBoardDotNet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvgolovanov%2FThingsBoardDotNet/lists"}