Skip to content

This code aims to use both Wifi and Ethernet together to determines whether ESP32 is getting Internet services vis Ping process.

Notifications You must be signed in to change notification settings

NegasonicX/Wifi-Ethernet-AutoReconnect-with-Ping--ESP32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Wifi & Ethernet AutoReconnect with Ping on ESP32

This code aims to use both Wifi and Ethernet together as well as determines whether ESP32 is getting Internet services vis Ping process.

GPIO Functions:

I am using ENC28J60 Ethernet Module and Devkit v1's integrated Wifi.

  • GPIO 18 : SCLK
  • GPIO 23 : MOSI
  • GPIO 19 : MISO
  • GPIO 5 : CS
  • SPI CLOCK MHz : 8MHz
  • NOTE : SDK Configurations for SPI has to be done on individual level

Understanding the Flow:

  • This code is developed for ESP32 on Embedded C Language using FreeRTOS.
  • Even if ESP32 is connected to an AP in station mode or Ethernet cable is plug in, you will still get the IP but that won't ensure whether ESP32 is receiving Internet services.
  • As per my rigorous research and programming, the only way I found out to know whether ESP32 has internet services or not was to ping say any open address ( "www.google.com" for this example ).
  • We initialize the Wifi and Ethernet services on ESP32. ( Remember, both works on DHCP! I will add static options in other examples )
  • ESP32 tries to connect with the provided SSID & Password. If radio conenction is not established, it will try reconnecting...
  • Meanwhile if Ethernet Cable is connected, ESP32 will start the ping process to know whether it is receiving the Internet services.
  • You can set various ping parameters like : ping intervals, ping counts, ping host, ping loss tolerance and so on.

Conclusion:

  • So far, I believe ping is the only method to know whether we are having active Internet Services
  • VERY IMPORTANT: ESP gives WIFI connection priority over Ethernet by default ( at least in my test cases ). Hence, if your ESP is connected to an AP but isn't receiving any Internet Packages, it won't shift to Ethernet!!

About

This code aims to use both Wifi and Ethernet together to determines whether ESP32 is getting Internet services vis Ping process.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages