Wt32-eth01-ip setup

i am trying to set up an ip address for WT32-ETH01 and pinging to it from a pc with a direct lan connection between the two.
this is my code :

#include <ETH.h>
IPAddress local_IP(192, 168, 1, 50);   // Static IP Address
IPAddress gateway(192, 168, 1, 1);       // Gateway
IPAddress subnet(255, 255, 255, 0);      // Subnet Mask
IPAddress primaryDNS(8, 8, 8, 8);        // Primary DNS
IPAddress secondaryDNS(8, 8, 4, 4);      // Secondary DNS

void setup() {
  Serial.begin(9600);
  delay(1000);
ETH.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS);
  // Power up Ethernet PHY
  //pinMode(16, OUTPUT);
 // digitalWrite(16, HIGH);
  delay(100);
  ETH.begin();  // Start Ethernet
}

void loop() {
  Serial.print("IP Address: ");
  Serial.println(ETH.localIP());
  delay(5000);
}

the issue i am facing is this is the ip address am i getting.
IP Address: 0.0.0.0.

Have you looked at the sample sketches for the ETH library?

swap begin() and config() (yes it is not normal)
or use my EthernetESP32 library

this is the modfied code. (note the the eth lights are not up in either version of my code )

#include <ETH.h>
IPAddress local_IP(192, 168, 1, 50);   // Static IP Address
IPAddress gateway(192, 168, 1, 1);       // Gateway
IPAddress subnet(255, 255, 255, 0);      // Subnet Mask
IPAddress primaryDNS(8, 8, 8, 8);        // Primary DNS
IPAddress secondaryDNS(8, 8, 4, 4);      // Secondary DNS
#define ETH_PHY_TYPE ETH_PHY_LAN8720
//#define ETH_PHY_ADDR 0      // commented out
#define ETH_PHY_MDC 23
#define ETH_PHY_MDIO 18
//#define ETH_PHY_POWER -1    // commented out
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
void setup() {
  Serial.begin(9600);
  delay(1000);
  // pinMode(16, OUTPUT);     // set pin to output
  //digitalWrite(16, HIGH);  // turn on power
  
  delay(100);
  ETH.begin();  // Start Ethernet
  ETH.config(local_IP);
}

void loop() {
  Serial.print("IP Address: ");
  Serial.println(ETH.localIP());
  delay(5000);
}

i perfomred the change you suggsted but still ip address is 0.0.0.0
something else is if i put pin 16 as high output the lights of the eth connectors lights up but i get the bootloader setup instead of the the serial print i defined:

load:0x3fff0030,len:4832
load:0x40078000,len:16460
load:0x40080400,len:4
load:0x40080404,len:3504
entry 0x400805cc

I used the EthernetESP32 library with the ESP32 ETH-01 module - DHCP returned the IP address OK

If you got working code that i could try just as a sanity check.
That would be great.

try this hello server

// for ESP32-ETH01 
/*
 * HelloServer example from the ESP32 WebServer library modified for Ethernet.
 */

#include <EthernetESP32.h>
#include <WebServer.h>
#include <ESPmDNS.h>

//W5500Driver driver;
//ENC28J60Driver driver;
//  EMACDriver(EthPhyType phyType, int mdcPin = 23, int mdioPin = 18, int powerPin = -1, emac_rmii_clock_gpio_t clockPin = EMAC_APPL_CLK_OUT_GPIO, emac_rmii_clock_mode_t clockMode = EMAC_CLK_EXT_IN);
EMACDriver driver(ETH_PHY_LAN8720, 23, 18, 16);   // note powerPin = 16 required

WebServer server(80);

const int led = 35;//13;

void handleRoot() {
  digitalWrite(led, 1);
  server.send(200, "text/plain", "hello from esp32!");
  digitalWrite(led, 0);
}

void handleNotFound() {
  digitalWrite(led, 1);
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}

void setup(void) {
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);

  Serial.begin(115200);
  delay(2000);
  while (!Serial);

  Ethernet.init(driver);

  Serial.println("\n\nESP32-ETH01 Initialize Ethernet with DHCP:");
  if (Ethernet.begin()) {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  } else {
    Serial.println("Failed to configure Ethernet using DHCP");
    while (true) {
      delay(1);
    }
  }

  if (MDNS.begin("esp32")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);

  server.on("/inline", []() {
    server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void) {
  server.handleClient();
  delay(2);  //allow the cpu to switch to other tasks
}

serial monitor output

Initialize Ethernet with DHCP:
  DHCP assigned IP 192.168.1.66
MDNS responder started
HTTP server started

web browser

photo

okay so i succsceeded in seting a static ip address
my overall issues were :

  1. i connected the 3.3volts power from my usb (the voltage was actuly 2.9 so it wasnt working well )
    2.i didnt disconnect the i00 from ground, which didnt enable my code to run.
  2. the enable needed to get gnd after each new code iteration.
  3. i didn't send the proper parameters to ETH.BEGIN.
    i am attaching the working code :
#include <ETH.h>
IPAddress local_IP(192, 168, 1, 50);   // Static IP Address
IPAddress gateway(192, 168, 1, 1);       // Gateway
IPAddress subnet(255, 255, 255, 0);      // Subnet Mask
IPAddress primaryDNS(8, 8, 8, 8);        // Primary DNS
IPAddress secondaryDNS(8, 8, 4, 4);      // Secondary DNS
#define ETH_PHY_TYPE ETH_PHY_LAN8720
//#define ETH_PHY_ADDR 0      // commented out
//eth_phy_type_t ETH_PHY_LAN8720;
#define ETH_ADDR        1
#define ETH_POWER_PIN   16
// Pin# of the I²C clock signal for the Ethernet PHY
#define ETH_MDC_PIN     23
#define ETH_TYPE        ETH_PHY_LAN8720
// Pin# of the I²C IO signal for the Ethernet PHY
#define ETH_MDIO_PIN    18
//#define ETH_PHY_POWER -1    // commented out
#define ETH_CLK_MODE    ETH_CLOCK_GPIO17_OUT
uint8_t mac[] = {0xDE, 0xAD, 0xBE, 0xEE, 0xFE, 0xEE}; // use any MAC
void setup() {
  Serial.begin(9600);
  delay(1000);
  // pinMode(16, OUTPUT);     // set pin to output
  //digitalWrite(16, HIGH);  // turn on power
  ETH.begin(ETH_PHY_TYPE,ETH_ADDR,ETH_MDC_PIN,ETH_MDIO_PIN,ETH_POWER_PIN,ETH_CLK_MODE);
  ETH.macAddress(mac);
  delay(100);
  ETH.begin();  // Start Ethernet
  ETH.config(local_IP, gateway, subnet, primaryDNS);;
}

void loop() {
  Serial.print("IP Address: ");
  Serial.println(ETH.localIP());
  delay(5000);
}

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