Post topics, source code that relate to the Arduino Platform

User avatar
By elheck
#68224 I am currently working on an ESP8266 with the Arduino IDE. I try to implement an ESP8266 in STA mode as multicast receiver. I was writing my code with the help of this documentation [ ... class.html]. Especially the following part:

> The WiFiUDP class supports sending and receiving multicast packets on STA interface. When sending a multicast packet, replace udp.beginPacket(addr, port) with udp.beginPacketMulticast(addr, port, WiFi.localIP()). When listening to multicast packets, replace udp.begin(port) with udp.beginMulticast(WiFi.localIP(), multicast_ip_addr, port). You can use udp.destinationIP() to tell whether the packet received was sent to the multicast or unicast address.

Sending to the multicast group with `udp.beginPacketMulticast(addr, port, WiFi.localIP())` and `udp.write(message, messageLength)`works flawlessly.

The receiving part of my code is as follows:

Code: Select all   #include <ESP8266WiFi.h>
    #include <WiFiUdp.h>
    #define BUFFER_LENGTH 256
    const char* ssid = "xxxxxx";
    const char* password = "xxxxxx";
    WiFiUDP Udp;
    IPAddress multicastAddress(226,1,1,1);
    unsigned int multicastPort = 4096;
    char incomingPacket[BUFFER_LENGTH];
    void setup(){
       WiFi.mode(WIFI_STA); //station
       while (WiFi.status() != WL_CONNECTED)
           WiFi.begin(ssid, password);
        Udp.beginMulticast(WiFi.localIP(), multicastAddress, multicastPort);
    void loop(){
       int packetLength = Udp.parsePacket();
          int len =, BUFFER_LENGTH);
            if (len > 0){
              incomingPacket[len] = 0;
                Serial.printf("%s\n", incomingPacket);

When sending a packet with a simple [ ... ample.html] multicast sender (with matching IP and port), my multicast receiver on my linux laptop receives the packet, but the ESP8266 doesn't.

Maybe some of you have experienced a similar behavior and are able to give me some hints, where I might be wrong.
User avatar
By hazyj
#68398 Any luck solving your issue? I am currently having exact same problem: esp8266 client is not receiving the multicast packages sent from my esp8266 server via udp.beginPacketMulticast(addr, port, WiFi.localIP()).

My code is simply a way for all clients to find the IP address of the server and to do so dynamically.

Also, I don't understand this statement from documentation:

"You can use Udp.destinationIP() to tell whether the packet received was sent to the multicast or unicast address." Is this a typo? Should it be "sent from the multicast or unicast address" instead?

User avatar
By gibo77
#85409 I am also having the same problem on UDP multicast receiving. I could not receive packet!
My program is basic and has no other content. Just bare bones.

I tried the solution on the link below, but still did not work.

Code: Select all

Can somebody help us please. As per documentation of Arduino ESP8266 that multicast works.