-
Notifications
You must be signed in to change notification settings - Fork 3
Description
I am trying to save energy with a WT32-eth01 board. With the example 'Basicota.ino' it draws some 160mA. I read that the core ESP32 (no WiFi, no BT) draws some 50mA and the lan8720a chip also draws 50mA in Base 100 and 25mA in Base 10 connection. So my math tells me that in a minimum setup -no WiFi, no BT, Base 10 ethernet- it should draw some (average) 75mA.
I changed the BasicOta.ino example a bit. Added static IP --> That works
Then I added <Wifi.h> in the includes.
Now the static IP will not work, It assigns IP=0.0.0.0
Maybe it requires some delays, so I added 1 sec delays, and then 10 secs delays between code.
Now it assigns an IP via DHCP, not a static IP.
And still 160mA....
1- Why does static IP suddenly stops working when (WiFi.h> is declared?
2- Do I have to shut down Wifi to save energy? In other words: Does the WT32-eth01 board start with Wifi (and/or BT) on by default? And if it does NOT start by default why is it consuming 160mA?
3 How can I assign a 10 Base connection to the ethernet port? Does it start with 100 or with 10?
It may be that some questions are out of scope here, but there is little to no information about the WT32 eth01 board.
Thanks.
Oh wait... code I tried:
`/*
- BasicOTA example from the ESP32 ArduinoOTA library modified for Ethernet.
- jan 2025:
- added WiFi and trying to shut it off to save energy..
*/
#include <EthernetESP32.h>
#include <ESPmDNS.h>
#include <ArduinoOTA.h>
#include <MacAddress.h>
#include <WiFi.h>
//W5500Driver driver;
//ENC28J60Driver driver;
//EMACDriver driver(ETH_PHY_LAN8720);
EMACDriver driver(ETH_PHY_LAN8720, 23,18,16);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEF };
void setup() {
IPAddress ip(192, 168, 1, 32);
IPAddress gw(192, 168, 1, 254);
IPAddress dns(192, 168, 1, 254);
IPAddress mask(255, 255, 255, 0);
Serial.begin(115200);
delay(10000);
while (!Serial);
Ethernet.init(driver);
delay(10000);
Serial.println("Configuring static IP ");
Ethernet.begin(mac, ip, dns, gw, mask);
delay(10000);
Serial.println("Just before printethernetstatus");
printEthernetStatus();
delay(10000);
if (ip != Ethernet.localIP()) {
Serial.println("ERROR: Static IP was not used.");
// while (true) {
// delay(1);
// }
}
ArduinoOTA
.onStart( {
String type;
if (ArduinoOTA.getCommand() == U_FLASH) {
type = "sketch";
} else { // U_SPIFFS
type = "filesystem";
}
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
})
.onEnd([]() {
Serial.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) {
Serial.println("Auth Failed");
} else if (error == OTA_BEGIN_ERROR) {
Serial.println("Begin Failed");
} else if (error == OTA_CONNECT_ERROR) {
Serial.println("Connect Failed");
} else if (error == OTA_RECEIVE_ERROR) {
Serial.println("Receive Failed");
} else if (error == OTA_END_ERROR) {
Serial.println("End Failed");
}
});
ArduinoOTA.begin();
delay(10000);
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(Ethernet.localIP());
delay (10000);
WiFi.disconnect();
WiFi.mode(WIFI_OFF);
}
void loop() {
ArduinoOTA.handle();
}
void printEthernetStatus() {
byte mac[6];
Ethernet.MACAddress(mac);
Serial.print("MAC: ");
Serial.println(MacAddress(mac));
if (mac[0] & 1) { // unicast bit is set
Serial.println("\t is the ordering of the MAC address bytes reversed?");
}
Serial.print("IP Address: ");
Serial.println(Ethernet.localIP());
Serial.print("gateway IP Address: ");
Serial.println(Ethernet.gatewayIP());
Serial.print("subnet IP mask: ");
Serial.println(Ethernet.subnetMask());
Serial.print("DNS server: ");
IPAddress dns = Ethernet.dnsServerIP();
if (dns == INADDR_NONE) {
Serial.println("not set");
} else {
Serial.println(dns);
}
}
`