Readback of Ethernet.localIP() is not the assigned address which the board is using

[code]
////////////////// USER CONFIGURATION /////////////////////////////
#define USE_DHCP 0                              // set to 1 for DHCP
IPAddress industruino_ip (192, 168, 0, 177);    // example
//#define TCP_SERVER "www.arduino.cc"
#define TCP_SERVER "192.168.0.5"
#define TCP_SERVER_PORT 80                     // for http

[/code]

[code]
  } else {        // static IP
    SerialUSB.print("My IP: ");
    SerialUSB.println(industruino_ip);
    Ethernet.begin(mac, industruino_ip);
  }
  printTime();
  SerialUSB.print("Ethernet started with above MAC and IP: ");
  SerialUSB.println(Ethernet.localIP());
  lcd.setCursor(0, 3);
  lcd.print("IP ");
  lcd.print(Ethernet.localIP());

[/code]

7:33:22.710 -> [2.13] Reading MAC from RTC EEPROM: 0:4:A3:B:0:4D:91:E8
17:33:22.710 -> Extracted 6-byte MAC address: 0:4:A3:4D:91:E8
17:33:22.747 -> [2.15] Ethernet module found
17:33:24.744 -> My IP: 192.168.0.177
17:33:25.753 -> [5.16] Ethernet started with above MAC and IP: 224.212.0.216
17:33:25.753 -> [5.17] END OF SETUP
17:33:25.753 ->
17:33:25.753 -> [5.17] connecting to server 192.168.0.5 on port 80... [5.19] failed to connect, restarting Ethernet
17:33:26.792 ->

Examination on the server side with wireshark shows that it is trying to connect from the correct IP 192.168.0.177

Why is it returning that multicast address as its local IP address, and how to fix?

Thanks,

Chris

 

 

Chris_B
Chris_B
14
| 1 1 1
Asked on 11/25/19, 11:05 PM
0
vote
1571 Views

hi, i can't think of a specific reason why you are seeing that, but just to double check: are you using the Industruino version of the Ethernet2 library as in https://github.com/Industruino/documentation/blob/master/ethernet.md#ethernet2-library and do you see any reason why the connection is eventually failing? i mean, you have an http server running on that ip?

Tom
on 11/25/19, 11:40 PM

are you using the Industruino version of the Ethernet2 library as in https://github.com/Industruino/documentation/blob/master/ethernet.md#ethernet2-library

Tom's tip solved my problems, though never figured out what the issue was.  It was not the SPI speed, I fixed that by hand according to the instructions and so initializing the Ethernet had already been working (I could ping the unit from a laptop).  It was something more mysterious/subtle preventing connections from working. 

Nevertheless, junking Ethernet2 in favor of Industruino's Ethernet2-master fixed everything.  Both IndustruinoEthernetClient and WebServer example sketches compile and run using the correct library.  Neither was working with merely the Ethernet2 library having SPI set correctly.

Edit:

Followup.  After running into problems--namely missing functions that are provided in the updated Arduino Ethernet package but not in Ethernet2--I revisited the Arduino version.  My program running under Industruino Ethernet2-master also runs under updated Ethernet, with a single change to C:\Program Files (x86)\Arduino\libraries\Ethernet\src\utility\w5100.h from 8Mhz to 4Mhz

// Arduino Zero can't use W5100-based shields faster than 8 MHz
// https://github.com/arduino-libraries/Ethernet/issues/37#issuecomment-408036848
// W5500 does seem to work at 12 MHz.  Delete this if only using W5500
#if defined(__SAMD21G18A__)
#undef SPI_ETHERNET_SETTINGS
// #define SPI_ETHERNET_SETTINGS SPISettings(8000000, MSBFIRST, SPI_MODE0) 
#define SPI_ETHERNET_SETTINGS SPISettings(4000000, MSBFIRST, SPI_MODE0)
#endif

 

 

 

 

Chris_B
Chris_B
14
| 1 1 1
Answered on 11/26/19, 3:29 PM
0
vote

hi Chris, thanks much for the feedback. i've tried to use that latest Arduino Ethernet library but i cannot get it to work. I made the change you suggested but the included examples fail at the DHCP and report hardwareStatus = EthernetNoHardware Could you please check if you made any other changes? Do the examples work for you? (after changing Serial to SerialUSB of course)

Tom
on 2/12/20, 4:15 AM

Hi Tom, didn't see your Feb comment until just now, haven't visited the forums in a while... I'm using a static IP so haven't any idea what might be wrong with the default Arduino Ethernet library re hanging on DCHP.

Chris_B
on 10/14/20, 1:23 AM

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

58 follower(s)

Stats

Asked: 11/25/19, 11:05 PM
Seen: 1571 times
Last updated: 12/19/19, 4:48 PM