I develop new bits of code in Arduino IDE and when they’re working, I bake them into my final project in PIO.
The target is a Waveshare ESP32-P4-ETH and I use esp32-p4 as the board identifier
I slightly modified an ESP-DashboardPlus example which compiles and runs in Arduino IDE, but I can’t get it to compile in PIO.
I have used the same libraries and the latest ESP32 framework, but no luck. I’ve tried the various fixes I’ve found in the forums , again no luck.
Currently the first error I get is
Compiling .pio\build\esp32-p4\lib40c\WebServer\middleware\MiddlewareChain.cpp.o fatal error: NetworkServer.h: No such file or directory
My PlatformIO.ini looks like this
[env:esp32-p4] platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip board = esp32-p4 framework = arduino
monitor_speed = 115200
lib_deps = ESP-DashboardPlus
ESP32Async/ESPAsyncWebServer
ArduinoJson
This is my main.cpp
#include <arduino.h>
#include <ETH.h>
#include <ESPAsyncWebServer.h>
#include "ESPDashboardPlus.h"
#include "dashboard_html.h"
#define ETH_PHY_TYPE ETH_PHY_TLK110
#define ETH_PHY_ADDR 1
#define ETH_PHY_MDC 31
#define ETH_PHY_MDIO 52
#define ETH_PHY_POWER 51
#define ETH_CLK_MODE EMAC_CLK_EXT_IN
#define greenLED 8
#define redLED 46
AsyncWebServer server(80);
ESPDashboardPlus dashboard("My Device");
void setup()
{
Serial.begin(115200);
IPAddress ip(192, 168, 1, 177);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 254, 0);
IPAddress dns(192, 168, 0, 1);
ETH.begin(ETH_PHY_TYPE, ETH_PHY_ADDR, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_POWER, ETH_CLK_MODE);
ETH.config(ip, gateway, subnet, dns); //Must be AFTER ETH.begin() !!!
Serial.println(ETH.localIP());
// Initialize dashboard with pre-compressed HTML
dashboard.begin(&server, DASHBOARD_HTML_DATA, DASHBOARD_HTML_SIZE);
// Add a stat card
dashboard.addStatCard("temp", "Temperature", "23.5", "°C");
pinMode(greenLED, OUTPUT);
digitalWrite(greenLED, HIGH);
pinMode(redLED, OUTPUT);
digitalWrite(redLED, HIGH);
// Add a toggle with callback
ToggleCard* greenled = dashboard.addToggleCard("greenled", "Green LED", "Status", false);
greenled->onChange = [](bool state) {
digitalWrite(greenLED, !state);
};
ToggleCard* redled = dashboard.addToggleCard("redled", "Red LED", "Status", false);
redled->onChange = [](bool state) {
digitalWrite(redLED, !state);
};
server.begin();
}
void loop() {
dashboard.loop();
// Update values periodically
static unsigned long lastUpdate = 0;
if (millis() - lastUpdate > 2000) {
lastUpdate = millis();
dashboard.updateStatCard("temp", String(random(20, 30)));
}
}
Any thoughts?