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.

Who is online

Users browsing this forum: No registered users and 6 guests