ESP32 W5500 Ethernet problem

Protos
Posts: 3
Joined: Sun Jun 02, 2019 8:45 am

ESP32 W5500 Ethernet problem

Postby Protos » Sun Jun 02, 2019 9:01 am

Hi Guys,

I am using the ESP32 to make a number of modules which are powered by PoE. I have also written an app for the PC (windows 8.1) which sends requests to these modules on a scheduled basis and the modules send data back to the PC. The PC also looks for new modules on the network using the 'arp -a' command, getting the reply back as a text string it can parse and see what devices are on the network. It is all working well apart from one thing. When the ESP32 connects to the network, it is allocated an IP address by DHCP but this IP address does not immediately show up on the ARP table. I have got round this by setting my PC to a static IP address - 192.168.2.14 and getting the ESP32 to try to connect to it as a server, this action ensures that the ESP32's IP address is immediately added to the ARP table.

This is the code I use to manage it

Code: Select all

#include <SPI.h>
#include <Ethernet2.h>

byte            mac[6];

EthernetServer  server(6000);
IPAddress       ip(192, 168, 2, 14);
EthernetClient  client;

void setup() 
{
  Serial.begin(115200);
  delay(3000);

  esp_efuse_mac_get_default(mac); // get unit mac address from efuse

  pinMode(5, OUTPUT);
  Serial.println("App started ..... ");
  Serial.print("Unit MAC address : ");
  for(int i=0; i<5; i++)
  {
    Serial.print(mac[i], HEX);
    Serial.print(":");
  }
  Serial.println(mac[5], HEX);
  Serial.println("Starting Ethernet connection now ..."); 
  Ethernet.init(5);
  if(Ethernet.begin(mac))
  {
    server.begin();
    Serial.print("server is at ");
    Serial.println(Ethernet.localIP());
    client.connect(ip, 80);
  }
  else
    Serial.println("Network FAIL");
}


void loop() 
{
}
I wonder if anyone has any better suggestions for accomplishing this without having to set the PC address as static? I have tried different IP addresses in the client.connect command including the IP of my router but only the PC address works.

These devices are to be installed at a manufacturing plant and need to be 'plug and play' ie connect them to the network and they appear on the PC app.

Cheers, Steve.

anything
Posts: 1
Joined: Thu Sep 05, 2019 10:31 am

Re: ESP32 W5500 Ethernet problem

Postby anything » Thu Sep 05, 2019 10:53 am

Hi,
why do you not parse the dcpd.log of your dhcp server to prevent this arp table parsing?

anyway for explaination:
- connect any cliente to a network > generates a dhcp log event
- if mac adresse is "any esp" >writeTo> esp.dhcp.log (or any other database thingy should be working well); if mac is already in database update IP for this mac; else create db entry for this mac...
- implement any type of check for the esp clients are still up: for example ping $IP periodically < if ping time out == hostDown then drop the mac from your esp mac host |IP database thingy or spawn any other type of alert to keep informed
- and work with this "own database" instead of any cached arp entrys...
maybe there are any "cache settings" OS related and you can turn of cache behavior of your operating system ? ;)

It would be interesting if you get a solution and how you get solved your issue.

kind regards,
anything

Who is online

Users browsing this forum: No registered users and 81 guests