diff --git a/platformio.ini b/platformio.ini index d77bf513..f3f880a4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -84,6 +84,22 @@ lib_deps = build_flags = "-D WT32_ETH01" +[env:espoe32] +platform = espressif32 +board = m5stack-core-esp32 +framework = arduino +monitor_speed = 115200 +upload_speed = 115200 +; Uncomment this line to allow for remote upgrade. If name resolution does not work for you, replace with the IP of ESPAltherma +; upload_port = ESPAltherma.local +; Uncomment this line if you want to define the protocol. Autodetected otherwise. +; upload_protocol = espota + +lib_deps = + PubSubClient + +build_flags = "-D ESPOE32" + [env:native] # Used to run unit test; g++ must be in PATH. platform = native diff --git a/src/main.cpp b/src/main.cpp index 66c0e97a..c8112071 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,6 +18,14 @@ #include #endif +#ifdef ESPOE32 +#include +#define ETH_ADDR 1 +#define ETH_POWER 5 +#define ETH_MDC 23 +#define ETH_MDIO 18 +#endif + #include #include @@ -175,7 +183,7 @@ void checkWifi() } } -#ifdef WT32_ETH01 +#if defined(WT32_ETH01) || defined(ESPOE32) void WiFiEvent(WiFiEvent_t event) { switch (event) { @@ -208,7 +216,11 @@ void WiFiEvent(WiFiEvent_t event) void setupEthernet() { WiFi.onEvent(WiFiEvent); - ETH.begin(); + #ifdef WT32_ETH01 + ETH.begin(); + #elif ESPOE32 + ETH.begin(ETH_ADDR, ETH_POWER, ETH_MDC, ETH_MDIO, ETH_PHY_IP101, ETH_CLOCK_GPIO0_IN); + #endif if (ETH.linkUp()) { Serial.printf("Connected. IP Address: %s\n", ETH.localIP().toString().c_str()); @@ -334,7 +346,7 @@ void setup() EEPROM.begin(10); readEEPROM();//Restore previous state -#ifdef WT32_ETH01 +#if defined(WT32_ETH01) || defined(ESPOE32) mqttSerial.print("Setting up ethernet..."); setupEthernet(); #else