W5500 + DUE, DHCP issue

Hi !

the pitch : with mac address byte 0, bit0 set to 1, I cant get an Ip address from dhcp !
(I tried with a large set of address) example below
Thanks for your help

#include <Arduino.h>
#include <SPI.h>     
#include <Ethernet.h>   // Copyright 2018 Paul Stoffregen

#define PINLED 3

byte mac[6];
byte localIp[]={192,168,0,47};

void blink(uint8_t nb)
{
  for(nb=nb;nb>0;nb--){
    digitalWrite(PINLED,HIGH);delay(5);
    digitalWrite(PINLED,LOW);delay(100);
  }
}

void serialPrintLocalIp()
{
for(uint8_t i=0;i<4;i++){
    Serial.print(Ethernet.localIP()[i]);if(i<3){Serial.print(".");}}
  Serial.println();
}  

void serialPrintIp(uint8_t* ip)
{
  for(int i=0;i<4;i++){Serial.print(ip[i]);if(i<3){Serial.print(".");}}
  Serial.println();
}

void serialPrintMac(uint8_t* mac)
{
  for(uint8_t i=0;i<6;i++){Serial.print(mac[i],HEX);if(i<5){Serial.print(".");}}
  Serial.println();
}

void setup() {

  Serial.begin(115200);
  delay(1000);
  Serial.println("\nready");
   
  memcpy(mac,"\x55\x55\x55\x55\x55\x55",6); 
  
  Serial.print(" mac=");serialPrintMac(mac);

  if(Ethernet.begin(mac) == 0)
    {
    Serial.print("\nFailed with DHCP... forcing Ip ");serialPrintIp(localIp);
    Ethernet.begin (mac, localIp); 
    }
  Serial.print(" localIP=");Serial.print((IPAddress)Ethernet.localIP());
  Serial.println();

  

  while(1){blink(1);delay(1000);}
}

void loop() {
  // put your main code here, to run repeatedly:

}

ready
 mac=54.55.55.55.55.55
 localIP=192.168.0.219

ready
 mac=55.55.55.55.55.55

Failed with DHCP... forcing Ip 192.168.0.47
 localIP=192.168.0.47

The MAC address that works is a unicast address while the one that does not is a multicast address. Wikipedia has a better explanation than I could write.

The last time I purchased w5500 boards they came with unique MAC addresses printed on slips of paper. But if you did not get any, there is no choice but to make up your own.

1 Like

Thank you very much ! I didnt know multicast !
There is many ESP in my LANs some with multicast, some unicast and they all work. So I suppose an issue with Ethernet lib or W5500 chip.

I bought about 20 W5500 modules at Aliexpress ; no one had any paper... It doesnt matter : They are used inside the LAN I can use any address.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.