Skip to content

Xiaomi TH sensor 2 (LYWSD03MMC)

Sergey edited this page Jan 11, 2025 · 2 revisions

For Xiaomi Gateway 2

This is BLE sensor, Xiaomi Gateway 2 supports only ZigBee devices.

For Xiaomi Gateway 3

using var gw3 = new XiaomiGateway3("<gateway ip>", "<gateway token>");
{
    gw3.OnDeviceDiscovered += x =>
    {
        if(x is MiThMonitor2 device && device.Did == "<specific did here>")
        {
            Console.WriteLine(device.ToString());

            device.OnTemperatureChange += (oldTh) => Console.WriteLine($"Temperature is {device.Temperature}");
            device.OnHumidityChange += (oldHumidity) => Console.WriteLine($"Humidity is {device.Humidity}");
            device.OnBatteryPercentChange += (oldBatteryPercent) => Console.Write($"Battery perce}nt is {device.BatteryPercent}");            
        }
    };

    gw3.DiscoverDevices();
}