Blynk Edgent Ethernet Connection

Hello,
I’m building a system using the ESP32 Feather and the Adafruit Featherwing Ethernet, where the device will connect to either Wi-Fi or Ethernet based on user input. My example code compiles successfully, but I haven’t been able to test it yet since the hardware is still in transit.

I read online that Edgent doesn’t support Ethernet, and when I checked the library, I didn’t see any Ethernet-related handling.

Can I use Edgent with an Ethernet connection? If not, is there a way to use Edgent features like Dynamic Provisioning and OTA while connected via Ethernet?

#define BLYNK_TEMPLATE_ID "xxxxxx"
#define BLYNK_TEMPLATE_NAME "xxxxxxxxxxe"
#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#include "BlynkEdgent.h"
#include <EEPROM.h>
#include <Ethernet.h>

#define MODE_ADDR 0
String connMode = "wifi";  // varsayılan
bool isEthernet = false;

void setup() {
  Serial.begin(115200);
  delay(100);

  EEPROM.begin(512);
  connMode = readConnectionMode();
  isEthernet = (connMode == "eth");

  Serial.println("Seçilen bağlantı modu: " + connMode);

  if (isEthernet) {
    setupEthernet();
  } else {
    setupWiFi();
  }

  BlynkEdgent.begin(); 
}

void loop() {
  BlynkEdgent.run();
  checkSerialInput();
}

// --- WiFi Mode ---
void setupWiFi() {
  // Edgent içinden hallediliyor
  Serial.println("WiFi Modu başlatılıyor...");
}

// --- Ethernet Mode ---
void setupEthernet() {
  Serial.println("Ethernet Modu başlatılıyor...");

  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  IPAddress ip(192, 168, 1, 77); // İsteğe bağlı statik IP
  Ethernet.begin(mac, ip);
  delay(1000);

  Serial.print("IP adresi: ");
  Serial.println(Ethernet.localIP());
}

// --- Seri Giriş Dinleme ---
void checkSerialInput() {
  if (Serial.available()) {
    String input = Serial.readStringUntil('\n');
    input.trim();
    input.toLowerCase();

    if (input == "wifi" || input == "eth") {
      writeConnectionMode(input);
      Serial.println("Yeni mod kaydedildi: " + input);
      delay(1000);
      ESP.restart();
    } else {
      Serial.println("Geçersiz giriş. 'wifi' veya 'eth' yazın.");
    }
  }
}

// --- EEPROM Yardımcı Fonksiyonlar ---
void writeConnectionMode(String mode) {
  EEPROM.write(MODE_ADDR, mode == "eth" ? 1 : 0);
  EEPROM.commit();
}

String readConnectionMode() {
  int val = EEPROM.read(MODE_ADDR);
  return (val == 1) ? "eth" : "wifi";
}

You say that connection type will be chosen by user input, but clearly that’s can’t be via Blynk, as you need a connection to the Blynk cloud server before user input can be processed.

When you refer to “dynamic provisioning with Ethernet” presumably you’re talking about provisioning a dynamic auth token?
I don’t know how you’re achieve this, as Blynk’s dynamic provisioning is done via a WiFi connection between the mobile device and the Blynk device.

Strangely, the ESP32 WiFi library is also used when connecting via Ethernet, so ultimately you may be able to achieve some of what you want.
OTA can be achieve without Edgent.

Take a look at this post…

Pete.