Skip to content

The code base accompanying one step in the video series on creating a next-level WiFi library for your ESP32 projects. The video associated with this code base focused on the existing reconnect logic already built into WiFi.h and how we can code to work with that context.

License

Notifications You must be signed in to change notification settings

OhioIoT-Examples/ESP32-WiFi_Reconnect-The-Right-Way

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32 WiFi: Reconnect The Right Way

Overview

This code serves is an output from the YouTube video ESP32 WiFi - Reconnect The Right Way, part of a video series marching toward your next-level WiFi library for ESP32 IoT developers. 👉 Subscribe to the OhioIoT YouTube Channel for more on All Things IoT: hardware, firmware, connectivity, cloud computing, and dev toolkit.

Getting Started

git clone https://github.com/OhioIoT-Examples/ESP32-WiFi_Reconnect-The-Right-Way.git

Getting Started - PlatformIO

  • Set your wifi credentials in src/main.cpp
  • Compile and run

Getting Started - Arduino IDE

  • Open wifi_lab.ino in the wifi_lab/ folder. That sketch directly links all three files in the lib/wifi_tools directory.
  • Add your wifi credentials in wifi_lab.ino.
  • When you are satisfied that it works:
    • copy the wifi_tools folder to your Arduino shared libraries/ folder
    • change your include in wifi_lab.ino to be #include "wifi_tools.h"

Updates

  • 09-15-2025: Re-inserted WiFi.reconnect() as the reconnect function in the event handler. wifi_tools.reconnect() is only calling WiFi.reconnect() after the timer exceeds he threshold. This works if we are constantly polling this function in the loop whenever !wifi_tools.is_connected. Events happen when they happen. If your disconnected event happens before the timer is exceeded - no reconnect.
  • 09-19-2025: My observation thus far was that a disconnect event is called every time you call WiFi.begin() and fail to connect. That doesn't mean it's always the case. Until it is confirmed, we need to keep checking the reconnect() function in the loop whenever it is the case that we are not connected. See more at the 13:38 mark of ESP32 WiFi - Final Checklist.

OhioIoT is an IoT platform designed for small-scale IoT projects (https://www.ohioiot.com).

About

The code base accompanying one step in the video series on creating a next-level WiFi library for your ESP32 projects. The video associated with this code base focused on the existing reconnect logic already built into WiFi.h and how we can code to work with that context.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages