The program im using is Arduino IDE.
Im use wt32-eth01 that use’s eth.h Libary that has 8720 Ethernet chip
i have had it working with wifi and it works good ready my voltage, but there one location has no wifi only ethernet port available, i tried different sketchs but can’t seem get it working.
hope someone can point me right way.
lan port works fine, it get IP and can talk too google server(code removed).
Hi Pete,
i did see your project but i haven’t had lucky get it working, ethernet port wont light up at all, not sure where im going wrong. if don’t mind can help me get it working?
pretty sure my board base on esp32-s1 with 8720 add on top.
i have retry your project i get this error now
only settings i have change is ethernet pin info.
n file included from C:\Users\MiSTiC\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\WiFi\src/WiFi.h:29,
from C:\Users\MiSTiC\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\Ethernet\src/ETH.h:24,
from C:\Users\MiSTiC\AppData\Local\Temp.arduinoIDE-unsaved2023730-12632-1dw72aj.50md\sketch_aug30a\sketch_aug30a.ino:11:
C:\Users\MiSTiC\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\cores\esp32/IPv6Address.h:92:2: error: multiple types in one declaration
};
^
C:\Users\MiSTiC\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\cores\esp32/IPv6Address.h:92:2: error: declaration does not declare anything [-fpermissive]
i have tried different #include but no luck but i try using same one yours again.
OMG it is finally working after fixing some errors.
send my PSU unit voltage (testing) to blynk and it workings
thanks for help ALOT, i been tinkering for weeks with no luck.
you may know answer that this simple question, got mind blank going on atm.
my PSU is left on, i reboot MCU it seems too slowly count number up not showing true value straight away.
here’s full code and incase someone want use wt32-eth01 with blynk with ethernet.
#define BLYNK_TEMPLATE_ID "*********ID*******"
#define BLYNK_TEMPLATE_NAME "********name*******"
#define BLYNK_AUTH_TOKEN "**********token code******"
#define BLYNK_FIRMWARE_VERSION "1.0.0" // For Blynk.Air OTA, Increment with each
//voltage input pin
#define IN_PIN 39 //voltage input pin
#define WINDOW_SIZE 10 //voltage sample size
#include <ETH.h>
// You can use either the SSL or non-SSL library. Stick with SSL unless you have a good reason to change...
//#include <BlynkSimpleEsp32.h>
#include <BlynkSimpleEsp32_SSL.h>
#include <Update.h> // For Blynk.Air OTA
#include <HTTPClient.h> // For Blynk.Air OTA
//voltage settings/calc
int INDEX = 0;
int VALUE = 0;
int SUM = 0;
int READINGS[WINDOW_SIZE];
int AVERAGED = 0;
int voltage_offset = 14;// set the correction offset value
float voltage = 0;
static bool eth_connected = false;
BlynkTimer timer;
// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0)
{
// Set incoming value from pin V0 to a variable
int value = param.asInt();
// Update state
Blynk.virtualWrite(V0, value);
}
void WiFiEvent(WiFiEvent_t event)
{
switch (event) {
case ARDUINO_EVENT_ETH_START:
Serial.println("ETH Started");
//set eth hostname here
ETH.setHostname("esp32-ethernet");
break;
case ARDUINO_EVENT_ETH_CONNECTED:
Serial.println("ETH Connected");
break;
case ARDUINO_EVENT_ETH_GOT_IP:
Serial.print("ETH MAC: ");
Serial.print(ETH.macAddress());
Serial.print(", IPv4: ");
Serial.print(ETH.localIP());
if (ETH.fullDuplex()) {
Serial.print(", FULL_DUPLEX");
}
Serial.print(", ");
Serial.print(ETH.linkSpeed());
Serial.println("Mbps");
eth_connected = true;
break;
case ARDUINO_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
eth_connected = false;
break;
default:
break;
}
}
void setup()
{
Serial.begin(115200);
WiFi.onEvent(WiFiEvent);
ETH.begin();
Blynk.config(BLYNK_AUTH_TOKEN);
Blynk.connect();
timer.setInterval(1000L, myTimerEvent);
pinMode(IN_PIN, INPUT);
}
void loop()
{
if (eth_connected)
{
// reading voltage io39 and calcation
SUM = SUM - READINGS[INDEX]; // Remove the oldest entry from the sum
VALUE = analogRead(IN_PIN); // Read the next sensor value
READINGS[INDEX] = VALUE; // Add the newest reading to the window
SUM = SUM + VALUE; // Add the newest reading to the sum
INDEX = (INDEX+1) % WINDOW_SIZE; // Increment the index, and wrap to 0 if it exceeds the window size
AVERAGED = SUM / WINDOW_SIZE; // Divide the sum of the window by the window size for the result
double voltage = map(AVERAGED,0, 4096, 0, 1650) + voltage_offset;
voltage /= 100;
Blynk.virtualWrite(V0, voltage);
Serial.print("Voltage:");
Serial.print(voltage);
Serial.println("V");
delay (1000);
Blynk.run();
}
timer.run();
}
void myTimerEvent()
{
Blynk.virtualWrite(V1, millis() / 1000); //uptime data to V1
}
BLYNK_WRITE(InternalPinOTA) // For Blynk.Air OTA
{
String overTheAirURL = param.asString();
HTTPClient http;
http.begin(overTheAirURL);
int httpCode = http.GET();
if (httpCode != HTTP_CODE_OK) {return;}
int contentLength = http.getSize();
if (contentLength <= 0) {return; }
bool canBegin = Update.begin(contentLength);
if (!canBegin) { return;}
Client& client = http.getStream();
int written = Update.writeStream(client);
if (written != contentLength) {return;}
if (!Update.end()) {return;}
if (!Update.isFinished()) {return;}
reboot();
}
void reboot() // For Blynk.Air OTA
{
ESP.restart();
for (;;) {} // Wait here until the restart has begun
}
Looks like you voltage is the average of 10 reading. When you reboot it has to take 10 readings to get an accurate average. If you look at your output, after the 10th reading it stabilizes around 14V. You also have a delay (a no no for BLYNK) of 1 second. So it should take approx 10 seconds to get the 10 required measurements.