December 06, 2024, 07:06:16 PM

ESP32-PoE-ISO power on

Started by vestbjerg48, January 02, 2020, 05:30:03 PM

Previous topic - Next topic

vestbjerg48

Im having trouble getting my ISO board to start eth correctly, when only powered by PoE. When both PoE and USB is connected, everything works fine.
When only PoE is connected, the green and activity leds do not light up, until i push the reset button.

Any experiences with this ?

vestbjerg48


vestbjerg48

#2
tcpip_adapter_init();

    esp_event_loop_create_default();
    tcpip_adapter_set_default_eth_handlers();
    esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, &eth_event_handler, NULL);
    esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &got_ip_event_handler, NULL);

    eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
    eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
    phy_config.phy_addr = 0; //Add this to set the PHY address to 0 - its hard coded to 1 by ETH_PHY_DEFAULT_CONFIG above.

    gpio_pad_select_gpio(PIN_PHY_POWER);
    gpio_set_direction(PIN_PHY_POWER, GPIO_MODE_OUTPUT);
    gpio_set_level(PIN_PHY_POWER, 1);
    vTaskDelay(pdMS_TO_TICKS(150));

    esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config);
    esp_eth_phy_t *phy = esp_eth_phy_new_lan8720(&phy_config);
    esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
    config.on_lowlevel_init_done = phy_device_power_enable_via_gpio();

    esp_eth_handle_t eth_handle = NULL;
    ESP_ERROR_CHECK(esp_eth_driver_install(&config, &eth_handle));
    ESP_ERROR_CHECK(esp_eth_start(eth_handle));

#define PIN_PHY_POWER 12
static esp_err_t phy_device_power_enable_via_gpio() {
    gpio_pad_select_gpio(PIN_PHY_POWER);
    gpio_set_direction(PIN_PHY_POWER, GPIO_MODE_OUTPUT);
    gpio_set_level(PIN_PHY_POWER, 1);
    vTaskDelay(100 / portTICK_PERIOD_MS);   // note <100ms didn't work
    return ESP_OK;
}

vestbjerg48

#3
I have tried doing esp_restart(), if the unit does not get an IP within 25s. That does not help either - only pressing RST1 makes the board get an IP.