Combine two kind of (network) connection


I would like to combine two kinds of connexion like WIFI and Ethernet (I have already made my code to work with ENC28J60 and ESP8266 but not together). Did anyone once do that?

PD: My aim is not two use both of them at the same time but for example look if the wifi connexion is available and if it is not, try with Ethernet for example or being able to choose between one of those.

Thank you

I do vaguely seem to remember this being asked before, maybe as a question about using a SIM800 cellular data connection when Wi-Fi isn’t available.

It should be fairly easy to do. Search the forum for code example about re-connection routines - this may be a good starting point:

Instead of re-connecting to Wi-Fi when it’s available again, switch over to trying to connect via Ethernet instead (and vice versa).


Thank you Pete, your comment has been very Helpful.

Between using Blynk.config() as a non-blocking command, and the fact the BlynkTimer works without server connection, then using lambda functions with timers, one could even put the logic entirely into the Setup() function (although not necessary… just saying).

Boot, try one connection for x time, if nothing, try the next method, then the next, etc… then connect to Blynk and start the usual looping run.

1 Like

Thank you, I will try and reply as soon as posible.

Hello Jonathan, Were you able to get the ethernet and wifi network working combine? I am also trying to do something like this. Thanks

Jonathan last visited the forum in 2018, so your chance of a reply might be quite slim.


Thanks. well i am trying to use ethernet and wifi at the same time, but when i add both libraries it gives an error, how can i do that?

#include <WiFi.h>  // Wifi library
#include <WiFiClient.h>   // Wifi library
#include <BlynkSimpleEsp32.h>   // Wifi library
#include <SPI.h> //Ethernet library
#include <Ethernet2.h> //Ethernet library
#include <BlynkSimpleEthernet2.h>  //Ethernet library

Library <BlynkSimpleEsp32.h> and <BlynkSimpleEthernet2.h> conflict. It gives an error like

BlynkSimpleEsp32.h:96:25: note: previous declaration as 'BlynkEsp32Client _blynkTransport'
  static BlynkEsp32Client _blynkTransport(_blynkWifiClient);

BlynkSimpleEthernet2.h:24:36: error: conflicting declaration 'BlynkEthernet Blynk'
  BlynkEthernet Blynk(_blynkTransport);

@burakdede please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:


I arranged.

The original post was about using Ethernet or WiFi, not both at the same time.
I’d guess that the only way to achieve both connections at the same time would be to use both cores of the ESP32 and even then I’m not sure it would be possible.


I may have expressed myself wrongly, sorry, my purpose is not to use both at the same time, but I will add both libraries and run the connection that will work for me, so I can make changes between the connection.