Trying to use C# to connect to my light bulb

Hi guys

Today I tried to write e very simple c# script just to see if I could contact my yeelight bulb, but I cannot recieve answer, maybe I didn’t quite get how c# multicasting should be done, can you help ?


  IPAddress multicastaddress = IPAddress.Parse("");
        UdpClient udpclient = new UdpClient();
        IPEndPoint remoteep = new IPEndPoint(multicastaddress, 1982);
        string ssdpMessage = "M-SEARCH * HTTP/1.1\r\nHOST:\r\nMAN: \"ssdp:discover\"\r\nST: wifi_bulb";

        byte[] buffer = Encoding.ASCII.GetBytes(ssdpMessage);
        udpclient.Send(buffer, buffer.Length, remoteep);

        IPEndPoint AnyEndPoint = new IPEndPoint(IPAddress.Any, 0);

        while (true)
            Byte[] data = udpclient.Receive(ref AnyEndPoint);
            string strData = Encoding.ASCII.GetString(data);

Let us try your code and provide some update.

Could you put you full project code here? let me try it

Thank you very much, you can just copy paste this code on a new c# console project in the main it should work.

Thank Ricky , you can just copy paste this code on a new c# console project in the main it should run , regardless I will upload mine tonight :).

Hi Hitomi, I use your code and it works well.
Did you open developer mode in App setting? This is what needs to be done before using the Yeelight open API.

Hi Ricky , I indeed activated developer mode, thanks for testing my code and confirming it works !

On my side I don’t seem to receive any answer.

It could be caused by your router. If you are using OpenWrt, you need to turn on one option.