08-06-2024, 11:51 PM
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");
}