GithubHelp home page GithubHelp logo

negasonicx / wifi-ethernet-autoreconnect-with-ping--esp32 Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 83 KB

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

C 100.00%
esp32 esp-idf embedded-c espressif esp-wifi ethernet-full-duplex ping

wifi-ethernet-autoreconnect-with-ping--esp32's Introduction

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!!

wifi-ethernet-autoreconnect-with-ping--esp32's People

Contributors

negasonicx avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.