Zigbee host dongle to .NET

Basic install of a Zigbee dongle, and then making the interface available to a .Net application

The target stack

Zigbee dongle → Zigbee2MQTT → MQTT broker (Mosquitto) → your .NET 8 app

Step 1: Install Mosquitto (MQTT broker)

bash

sudo apt install mosquitto mosquitto-clients
sudo systemctl enable mosquitto
sudo systemctl start mosquitto

Step 2: Install Zigbee2MQTT

bash

# Install Node.js first if needed
sudo apt install nodejs npm

# Create directory and install
sudo mkdir /opt/zigbee2mqtt
sudo chown -R $USER /opt/zigbee2mqtt
git clone --depth 1 https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt
cd /opt/zigbee2mqtt
npm install

Step 3: Find your dongle’s port

bash

ls /dev/serial/by-id/

It’ll show something like usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_...

– I get usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_eadae30e6c8bef11ad452bccef8776e9-if00-port0

Step 4: Configure Zigbee2MQTT

Edit /opt/zigbee2mqtt/data/configuration.yaml:

yaml

serial:
  port: /dev/ttyUSB0  # use your actual port from step 3

mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://localhost

frontend:
  enabled: true  # gives you a web UI on port 8080

Step 5: In your .NET 8 app

Add the MQTTnet NuGet package and subscribe to topics:

csharp

var factory = new MqttFactory();
var client = factory.CreateMqttClient();

var options = new MqttClientOptionsBuilder()
    .WithTcpServer("localhost", 1883)
    .Build();

await client.ConnectAsync(options);

client.ApplicationMessageReceivedAsync += e =>
{
    var topic = e.ApplicationMessage.Topic;
    var payload = e.ApplicationMessage.ConvertPayloadToString();
    Console.WriteLine($"{topic}: {payload}");
    return Task.CompletedTask;
};

await client.SubscribeAsync("zigbee2mqtt/#");

Zigbee2MQTT publishes device data as JSON to topics like zigbee2mqtt/your-device-name.

. To get a device list, publish to the bridge topic:

From the command line:

bash

mosquitto_pub -t "zigbee2mqtt/bridge/request/devices" -m ""

Then listen for the response:

bash

mosquitto_sub -t "zigbee2mqtt/bridge/response/devices"

From your .NET app:

csharp

// Subscribe to the response first
await client.SubscribeAsync("zigbee2mqtt/bridge/response/devices");

// Then request the device list
var message = new MqttApplicationMessageBuilder()
    .WithTopic("zigbee2mqtt/bridge/request/devices")
    .WithPayload("")
    .Build();

await client.PublishAsync(message);
```

The response comes back as JSON with each device's IEEE address, friendly name, model, manufacturer, and whether it's interview complete.

**Alternatively**, Zigbee2MQTT also publishes the full device list automatically on startup to:
```
zigbee2mqtt/bridge/devices

So you can just subscribe to that topic and you’ll get it whenever Zigbee2MQTT starts or restarts — no need to request it.

If you enabled the frontend in your config, you can also just visit http://localhost:8080 to see all devices visually while you’re developing.

Claude is AI and can make mistakes. Please double-check responses.

Share: X (Twitter) Facebook LinkedIn