Skip to content

Commit

Permalink
Add support for ESPOE32 board
Browse files Browse the repository at this point in the history
  • Loading branch information
Alibloke committed Feb 20, 2024
1 parent 2b04916 commit bdf430a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
16 changes: 16 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
#include <ETH.h>
#endif

#ifdef ESPOE32
#include <ETH.h>
#define ETH_ADDR 1
#define ETH_POWER 5
#define ETH_MDC 23
#define ETH_MDIO 18
#endif

#include <PubSubClient.h>
#include <ArduinoOTA.h>

Expand Down Expand Up @@ -175,7 +183,7 @@ void checkWifi()
}
}

#ifdef WT32_ETH01
#if defined(WT32_ETH01) || defined(ESPOE32)
void WiFiEvent(WiFiEvent_t event)
{
switch (event) {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bdf430a

Please sign in to comment.