PlatformIO Community

Connect Internet W5500 Esp32

I have a Esp32 connected to Router with cable, how to connect internet ?
I would linke how to connect internet with shield W5500 Esp32 (cable) and after use library Firebase ?

There are threads about this topic already:

Basically you have to use a fixed version of the Ethernet library that works for the ESP32 (open issue). You can use my version of the library (https://github.com/maxgerhardt/Ethernet/) with the provided examples and also OTA.

Firebase is available as a library (https://github.com/mobizt/Firebase-ESP32) but hardcoded to WiFi in a few places it seems. You can create a fork and replace WiFi.h with Ethernet.h functions.

I already used this library (https://github.com/mobizt/Firebase-ESP32) but I prefer this (https://github.com/ioxhop/IOXhop_FirebaseESP32)

// Library Wifi
#include <WiFi.h>

// Library Firebase
#include <IOXhop_FirebaseESP32.h>

// Libraties Ethernet
#include <Ethernet.h>
#include <EthernetUdp.h>

// Libraries Blynk
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <BlynkSimpleEnergiaEthernet.h>

// Credentials of Firebase to connect
#define FIREBASE_HOST "...."   
#define FIREBASE_AUTH "..."

// Credentials to connect Wifi
#define WIFI_SSID "...."               
#define WIFI_PASSWORD "..."

// Connect Local
EthernetUDP Udp;
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
char ReplyBuffer[] = "acknowledged";
byte mac[] = { 0x70, 0x69, 0x69, 0x2D, 0x30, 0x31 };
unsigned int localPort = 3001;

// LEDs
int ledVermelho = 21;
int ledAzul = 2;

char auth[] = ".....";


void setup() {

    Serial.begin(115200);

     // Initialize Ethernet method
    initializeEthernet();

    //  Initialize Wi-fi method
    //  connectWifi();

    pinMode(ledVermelho, OUTPUT);
    digitalWrite(ledVermelho, 1);
    pinMode(ledAzul, OUTPUT);
    digitalWrite(ledAzul, 1);
}



void loop() {
    runConnectLocal();
}



void connectWifi() {
    // connect to wifi.
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
    Serial.print("connecting");
    while (WiFi.status() != WL_CONNECTED) {
        Serial.print(".");
        delay(500);
    }
    Serial.println();
    Serial.print("connected: ");
    Serial.println(WiFi.localIP());
    Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}



// Methods to initialize ethernet services
void initializeEthernet() {
    Ethernet.init(33);// CS pin 33
    Ethernet.begin(mac);// use DHCP

    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
         Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
        while (true) {
             delay(1); // do nothing, no point running without Ethernet hardware
        }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
          Serial.println("Ethernet cable is not connected.");
    }

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

    Udp.begin(localPort);

    // Begin Blynk services
    Blynk.begin(auth);

    // Initialize Firebase Services
   //  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}



void runConnectLocal() {
    int packetSize = Udp.parsePacket();
    if (packetSize) {
        Serial.println("Passou conex√£o local " + packetSize);
        Serial.print("Received packet of size ");
        Serial.println(packetSize);
        Serial.print("From ");
        IPAddress remote = Udp.remoteIP();
        for (int i=0; i < 4; i++) {
              Serial.print(remote[i], DEC);
            if (i < 3) {
                Serial.print(".");
            }
       }
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    Serial.print("Contents: ");
    Serial.println(packetBuffer);

    // send a reply to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
}
delay(10);

// Run Blynk
Blynk.run();

// run power method
//    powerLed();
}


void powerLed() {
     int ledStatus = Firebase.getInt("power");
     Serial.println(ledStatus);
     digitalWrite(ledVermelho, ledStatus);
     digitalWrite(ledAzul, ledStatus); 
}

So, I have this code that I use to connect with Firebase, when I use connection wi-fi method using firebase, its work perfeclty

But, when trying the same firebase library and connection with lan cable with W5500 shield, its no work

more a details, when I use app blynk using connection cabe, its work, if I try use firebase library, show the following message when debug:

/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1442 (xQueueGenericReceive)- assert failed!
abort() was called at PC 0x400880c1 on core 1