IP settings for WT32 ETH01?

bananananana
Posts: 1
Joined: Tue Mar 28, 2023 12:13 pm

IP settings for WT32 ETH01?

Postby bananananana » Tue Mar 28, 2023 12:44 pm

I have a WT32 ETH01 board and want to make simple webserver using this library: https://github.com/khoih-prog/WebServer_WT32_ETH01

I'm able to upload and run the code fine with the Arduino IDE but I can't connect to the device through ethernet. I have it connected to my laptop using a Cat5e cable but I'm not sure what to set the IP address to.

I set the IP to 192.168.0.112 and the gateway to 192.168.0.1 in the code, then on my laptop(running windows 10) I set the ethernet ipv4 properties to match this:
IP Address: 192.168.0.112
Subnet mask: 255.255.255.0
Default gateway: 192.168.0.1

DNS: 8.8.8.8

I power up the device and in the serial output it says:
IPv4: 192.168.0.112
and looks like it is starting all ok.

But I can't access the webserver, if I try pinging 192.168.0.112 I get a "request timed out" message and if I try to open that IP address in the browser it times out as well

So my question is what am I doing wrong? What do I set the addresses to so I can get it working?

thanks! B

Code: Select all

#define DEBUG_ETHERNET_WEBSERVER_PORT       Serial

// Debug Level from 0 to 4
#define _ETHERNET_WEBSERVER_LOGLEVEL_       3

#include <WebServer_WT32_ETH01.h>

WiFiServer server(80);
169.254.11.126
// Select the IP address according to your local network
IPAddress myIP(192, 168, 0, 112);
IPAddress myGW(192, 168, 0, 1);
IPAddress mySN(255, 255, 255, 0);

// Google DNS Server IP
IPAddress myDNS(8, 8, 8, 8);

int reqCount = 0;                // number of requests received

void setup()
{
  Serial.begin(115200);
  Serial.println("setup begin");

  while (!Serial);

  // Using this if Serial debugging is not necessary or not using Serial port
  //while (!Serial && (millis() < 3000));

  Serial.print("\nStarting WebServer on " + String(ARDUINO_BOARD));
  Serial.println(" with " + String(SHIELD_TYPE));
  Serial.println(WEBSERVER_WT32_ETH01_VERSION);

  // To be called before ETH.begin()
  WT32_ETH01_onEvent();

  //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO,
  //           eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE);
  //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE);
  ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER);

  // Static IP, leave without this line to get IP via DHCP
  //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
  ETH.config(myIP, myGW, mySN, myDNS);

  WT32_ETH01_waitForConnect();

  // start the web server on port 80
  server.begin();
}

void loop()
{
  // listen for incoming clients
  WiFiClient client = server.available();

  if (client)
  {
    Serial.println(F("New client"));
    // an http request ends with a blank line
    bool currentLineIsBlank = true;

    while (client.connected())
    {
      if (client.available())
      {
        char c = client.read();
        Serial.write(c);

        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank)
        {
          Serial.println(F("Sending response"));

          // send a standard http response header
          // use \r\n instead of many println statements to speedup data send
          client.print(
            "HTTP/1.1 200 OK\r\n"
            "Content-Type: text/html\r\n"
            "Connection: close\r\n"  // the connection will be closed after completion of the response
            "Refresh: 20\r\n"        // refresh the page automatically every 20 sec
            "\r\n");
          client.print("<!DOCTYPE HTML>\r\n");
          client.print("<html>\r\n");
          client.print(String("<h2>Hello World from ") + BOARD_NAME + "!</h2>\r\n");
          client.print("Requests received: ");
          client.print(++reqCount);
          client.print("<br>\r\n");
          client.print("<br>\r\n");
          client.print("</html>\r\n");
          break;
        }

        if (c == '\n')
        {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r')
        {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }

    // give the web browser time to receive the data
    delay(10);

    // close the connection:
    client.stop();
    Serial.println(F("Client disconnected"));
  }
}

ESP_ondrej
Posts: 210
Joined: Fri May 07, 2021 10:35 am

Re: IP settings for WT32 ETH01?

Postby ESP_ondrej » Mon Apr 03, 2023 4:25 pm

Based on your description, it seems you configured the same IP address on your PC and in the ESP32 code.
I set the IP to 192.168.0.112 and the gateway to 192.168.0.1 in the code
in the code, then on my laptop(running windows 10) I set the ethernet ipv4 properties to match this:
IP Address: 192.168.0.112

Sudoku
Posts: 1
Joined: Thu Aug 24, 2023 7:05 am

Re: IP settings for WT32 ETH01?

Postby Sudoku » Thu Aug 24, 2023 8:03 am

hello, to connect directly to the notebook I think you need a crossover cable. if you are using a bridge cable you must connect to a hub.

Who is online

Users browsing this forum: No registered users and 39 guests