Moonglade

Modern Markdown blogging with AI-powered localization and search.

Tag: IoT


A Brief Overview of the Time-Series Database InfluxDB and How to Interact with It Using .NET

This article addresses the sensor data management requirements of water utility companies' pump rooms and introduces the application of the time-series database InfluxDB. It first explains the optimization advantages of time-series databases for scenarios involving high write throughput, time-based queries, and immutable data. It then compares the differences between time-series databases and relational databases in core concepts such as Bucket, Measurement, Tag, Field, and Timestamp, with particular emphasis on the distinction that Tags are used for low-cardinality dimension indexing while Fields store non-indexed metric values. Subsequently, based on the .NET environment, it provides a detailed demonstration of the complete workflow: installing the client via NuGet, configuring connection information, writing data using PointData method chaining, and performing efficient queries using the Flux language. Finally, it points out that mastering the correct usage of Tags and Fields is key to operating InfluxDB efficiently, and that this solution can effectively improve sensor data write performance and query efficiency.

Views 324
.NET Flux InfluxDB IoT TagDB TimeSeries

Creating an MQTT client with automatic reconnection using `ManagedMqttClient` from MQTTnet

This article introduces how to simplify MQTT communication development in C# projects by leveraging the ManagedMqttClient extension package from MQTTnet. Compared to the native MqttClient, this extension package has built-in features for automatic reconnection, offline message queuing, and automatic subscription state recovery, significantly reducing the maintenance cost of reconnection logic. The article focuses on analyzing three core concepts in the MQTT protocol: QoS (Quality of Service) levels, where QoS 1 (at least once) is suitable for most scenarios, QoS 2 (exactly once) is reliable but has high performance overhead, and QoS 0 is used for low-priority data where packet loss is acceptable; the CleanSession flag, where setting it to false allows the Broker to cache QoS 1/2 messages while the client is offline and resend them after reconnection, which is ideal for devices requiring data integrity; and the Retain message mechanism, which allows the Broker to store the latest state of a Topic so that new subscribers can immediately obtain the most recent data, commonly used for device state synchronization. Finally, through examples of a temperature sensor and an alarm system, the article demonstrates how to combine these parameters based on business requirements to balance message reliability, real-time performance, and system resource consumption, providing clear guidelines for MQTT configuration in real-world projects.

Views 334
.NET C# IoT MQTT MQTTnet ManagedMqttClient