Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem With Ethernet Port
#1
I have the following Arduino code and I can not get my A32 Pro to connect to the network and take IP, in the port if I see that there is connection but I can not get it to take an IP address from the DHCP of my network.

Code:
#ifndef ETH_PHY_TYPE
#define ETH_PHY_TYPE  ETH_PHY_LAN8720
#define ETH_PHY_ADDR  0
#define ETH_PHY_MDC   23
#define ETH_PHY_MDIO  18
#define ETH_PHY_POWER -1
#define ETH_CLK_MODE  ETH_CLOCK_GPIO0_IN
#endif

#include <ETH.h>
#include "Arduino.h"
#include "PCF8574.h"
#include <Wire.h>
#include <WiFi.h>
#include <Ethernet.h>
#include <SPI.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include "esp_system.h"
#include "esp_task_wdt.h"

EthernetClient ethClient;
PubSubClient client(ethClient);

void setup() {
  Serial.begin(115200);
 
  ETH.begin();

  while (Ethernet.localIP() == INADDR_NONE) {
    Serial.println("Esperando dirección IP...");
    delay(1000);  // Esperar 1 segundo antes de verificar nuevamente
  }
 
  while (ETH.localIP() == INADDR_NONE) {
    Serial.println("Esperando dirección IP...");
    delay(1000);  // Esperar 1 segundo antes de verificar nuevamente
  }

  while (!ETH.linkUp()) {
    Serial.print(".");
    delay(1000);
  }

  Serial.println("");
  Serial.println("Ethernet conectado");
}
Reply
#2
A32 pro not use by LAN8720, it use by w5500 chip.
https://www.kincony.com/forum/showthread.php?tid=5812
this is arduino demo code for w5500 work with UDP
Reply
#3
In the end you can solve it using the following code, I share it in case someone needs it.

Code:
#include "Arduino.h"
#include "PCF8574.h"
#include <Wire.h>
#include <WiFi.h>
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include "esp_system.h"
#include "esp_task_wdt.h"
#include <U8g2lib.h>

#define INT_GPIO 41
#define MISO_GPIO 40
#define MOSI_GPIO 44
#define SCK_GPIO 4
#define CS_GPIO 39

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

EthernetClient ethClient;
PubSubClient client(ethClient);

void(* resetFunc) (void) = 0;

void setup() {
  while (!Serial && (millis() < 5000));

  delay(500);

   // Configurar SPI con los pines especificados
  SPI.begin(SCK_GPIO, MISO_GPIO, MOSI_GPIO, CS_GPIO);

  // Inicializar la conexión Ethernet
  Ethernet.init(CS_GPIO);  // Inicializar con el pin CS
  Ethernet.begin(mac);

  // Esperar a que se asigne una dirección IP
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.");
    while (true) {
      delay(1); // No continuar
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  } else {
    Serial.print("Ethernet IP: ");
    Serial.println(Ethernet.localIP());
  }
 

  //Inicializar el Watchdog Timer 
  esp_task_wdt_config_t config;
  config.timeout_ms = 30000; // Establece el tiempo de espera a 30 segundos
  esp_task_wdt_init(&config);
  esp_task_wdt_add(NULL);
}

void loop() {

  esp_task_wdt_reset();
}

Now my problem is trying to enable the Watchdog, it is not respecting the function esp_task_wdt_reset() since I am constantly resetting the card, if anyone has any example of Watchdog on the esp32 S3 I would appreciate it.
Reply
#4
https://iotassistant.io/esp32/enable-har...duino-ide/
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)