Problem with EEPROM and WiFi under 1.8.13


The sketch listed below works fine when built with the 1.8.9 IDE on Windows 10 with ESP 1.0.4. The code basically sets Pin 23 High : Low at a given frequency. (If you attach an LED to pin 23 it will flash accordingly).

It also starts a WiFi Access Point called ESP32-AP on IP Address Password: 12345678. If a Client attaches to the Access Point, it is allocated an appropriate 192.168.4.x IP Address at which point the Client can open a browser, go to where it will be presented with a web page to change the frequency.

As stated under 1.8.9 everything works perfectly.

Under 1.8.13 the LED flashes, the Access Point is created, but clients cannot connect. No failure is returned to the client, but the client is not being assigned an IP address.

Now for the really strange bit. If you comment out the #include<EEPROM.h> line, then everything works as expected. The code does not use any EEPROM functionality, obviously, if it did then it would not compile with the #include commented out. But just including the #include <EEPROM.h> statement is sufficient to cause a clash with the WiFi / WebServer to prevent clients for successfully connecting.

#include <EEPROM.h>
#include <WiFi.h>
#include <WebServer.h>

#define MAX_FREQUENCY 50000000

hw_timer_t* timer = NULL;
volatile SemaphoreHandle_t frequencySemaphore;

uint8_t PIN = 23;
bool PINstate = LOW;

static uint32_t frequency = 1; // Frequency in Hz
const char* ssid     = "ESP32-AP";
const char* password = "12345678";

// Set web server port number to 80
IPAddress local_ip(192,168,4,1);
IPAddress gateway(192,168,4,1);
IPAddress subnet(255,255,255,0);
WebServer server(80);

* WebServer Request Handlers
* ==========================
void handle_OnConnect()
server.send(200, "text/html", SendHTML(frequency)); 

void handle_NotFound()

void handle_SetFrequency()

void handle_Request()
String sFreq = server.arg("frequency");
Serial.println("Frequency: " + sFreq);

int reqFreq = sFreq.toInt();
if (reqFreq > 0)
  frequency = reqFreq;
server.send(200, "text/html", SendHTML(frequency));

String SendHTML (int frequency)
int freqLength = snprintf(NULL, 0, "%d", frequency);

char sFreq[freqLength];
sprintf(sFreq, "%d", frequency);

String ptr = "<!DOCTYPE html> <html>\n";
ptr +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
ptr +="<title>LED Control</title>\n";
ptr +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
ptr +="body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;} h3 {color: #444444;margin-bottom: 50px;}\n";
ptr +=".button {display: block;width: 80px;background-color: #3498db;border: none;color: white;padding: 13px 30px;text-decoration: none;font-size: 25px;margin: 0px auto 35px;cursor: pointer;border-radius: 4px;}\n";
ptr +=".button-on {background-color: #3498db;}\n";
ptr +=".button-on:active {background-color: #2980b9;}\n";
ptr +=".button-off {background-color: #34495e;}\n";
ptr +=".button-off:active {background-color: #2c3e50;}\n";
ptr +="p {font-size: 14px;color: #888;margin-bottom: 10px;}\n";
ptr +="</style>\n";
ptr +="</head>\n";
ptr +="<body>\n";
ptr += "<h1>ESP32 Web Service</h1>\n";
ptr += "<p>Current Frequency: ";
ptr += sFreq;
ptr += "\n<form name=\"SetFrequency\" method=\"PUT\" action=\">\n";
ptr += "<label for=\"frequency\">Frequency:</label>\n";
ptr += "<input id=\"frequency\" type=\"number\" name=\"frequency\" min=\"1\" max=\"50000000\">\n";
ptr += "<button type=\"submit\">Submit</button>\n";
ptr += "</form>\n";
ptr += "</body></html>\n";

return ptr;

// Signal generator function
// Trigger via timer
void IRAM_ATTR OnTimer()
 digitalWrite(PIN, PINstate);
 PINstate = !PINstate;

void setup() 
 pinMode(PIN, OUTPUT);

 frequency = 10;
 Serial.println("Retrieved Frequency: " + String(frequency));
 if (frequency <= 0 || frequency > MAX_FREQUENCY)
   frequency = DEFAULT_FREQUENCY;

 // Define timer.
 timer = timerBegin(0, 80, true);
 timerAttachInterrupt(timer, &OnTimer, true);

 // Define Semaphore to inform us when frequency has changed.
 frequencySemaphore = xSemaphoreCreateBinary();

WiFi.softAP(ssid, password);
WiFi.softAPConfig(local_ip, gateway, subnet);

server.on("/", handle_OnConnect);
server.on("/SetFrequency", handle_SetFrequency);

int interval = 500000 / frequency;
timerAlarmWrite(timer, interval, true);

void loop() 
    if (xSemaphoreTake(frequencySemaphore, 0) == pdTRUE)
      int interval = 500000 / frequency;
      timerAlarmWrite(timer, interval, true);