I need a pretty simple example of tzapu wifimanager

Is there some kind of settings on the wemos ESP8266 that would be messed up that it doesn’t work on either of mine?
I discovered if I load a basic Blynk sketch that uses the blynk.begin to put in the WiFi credentials it will work. But then when I load yours again, it just hangs up.
Any idea why or what might be wrong with my wemos. I have 2 of them and they both act this way.
Right after I added that EEPROM.begin(512) statement.
Thanks.

You are flashing Wemos without SPIFFs, I suppose.

I’m researching this now to see what you mean, but the only option I have is seen in this photo. Is this what you mean?

I’ve discovered that my wemos is actually running, but it takes a LONG time, maybe 5 minutes. before it’ll go into auto connect AP mode.
The Serial outputs:

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v614f7c32
~ld
mounting FS...

And then it hangs for about 5 minutes. Then the serial monitor updates to:

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v614f7c32
~ld
mounting FS...
mounted file system
*WM: Adding parameter
*WM: blynk
*WM: 
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Already connected. Bailing out.
*WM: IP Address:
*WM: 192.168.1.4
connected...yeey :)
BLYNK Connection Fail
token
*WM: settings invalidated
*WM: THIS MAY CAUSE AP NOT TO START UP PROPERLY. YOU NEED TO COMMENT IT OUT AFTER ERASING THE DATA.

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)


 ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset

I’ve found someone with the exact sounding issue in the ESP8266 forum. They said the Spiffs.begin() makes it hang a long time on the Wemos D1 Pro Mini. It’s closed, but I don’t see how/if they resolved it?
https://github.com/esp8266/Arduino/issues/4237

If the Spiffs thing is making it hang, why was it working before, and now suddenly hang for 5 minutes?

Hurray! :joy:
I found my problem. I commented out my EEPROM.begin(), put() and get()
and now it’s working again. It connects to Blynk in about 10 seconds. And it goes into AP mode if I unplug my router.

But I really need to save about 6 integers to memory, that are configuration values for my project.
I will try deleting my EEPROM library and adding it back (I use the library manager for my libraries). Maybe I’m using the wrong library? I’m using
#include <EEPROM.h>
Or maybe I can store my config settings in the Spiff thing? I’ll keep researching…
Thanks.

Use SPIFFS:
https://www.esp8266.com/viewtopic.php?f=29&t=8194

Pete.

I tried adding this to my project, but it looks like messed up the spiff data in the wifi config settings because I got a lot of error stuff on the monitor.

int myFirstInt = 123;
int mySecondInt = 234;
void saveSettings() {
  //This will save the variables (integers) anytime the user wants to update them

  //I already called this once getting the wifi config file, do I need it again?
  SPIFFS.begin();

  // open file for writing
  File f = SPIFFS.open("/f.txt", "w");
  if (!f) {
    Serial.println("file open failed");
  }
  f.println(myFirstInt); //my val I need saved
  f.println(mySecondInt);

  //I'll have about 8 values to save
  f.close();
}

I called getSettings() in the setup()
Maybe I just need to add my variables to the same config file that the wifi settings are in. I’ll try that now.

Oh, I was calling getSettings() the first thing in my setup(). But I didn’t have SPIFFS.begin() in the getSettings() function. I added it in and it worked. It read my integers (though I I have to figure out how to get them from a string to an int), and then it got the wifi info and connected. I guess it doesn’t matter that I have SPIFF.begin() more than once. I have it in the wifi manager section, and then in these two functions I just previously posted getSettings() and saveSettings()

Is there a way to save a small struct array to the SPIFFS? These are my settings I need stored. I got the above simple code working but not sure how to save this whole thing

struct settings {
  uint16_t TC_M1_OFFSET;
  uint16_t TC_M2_OFFSET;
  uint16_t TC_FB_OFFSET;
  int fireboxOffsetTemp; //allow temp to drop this much below setpoint before sending alarm
  double aggKp;
  double aggKi;
  double aggKd;
  double consKp;
  double consKi;
  double consKd;
} s;

This is rather bulky, but I got it working. It saves 10 integers and floats to SPIFFS, and can read them back. If it doesn’t find the file (first time users), it will create one with default values.

void saveSettings() {
  SPIFFS.begin();

  // open file for writing
  File settings = SPIFFS.open("/settings.txt", "w");
  if (!settings) {
    Serial.println("file open failed");
  }
  settings.println(s.TC_M1_OFFSET);
  settings.println(s.TC_M2_OFFSET);
  settings.println(s.TC_FB_OFFSET);
  settings.println(s.fireboxOffsetTemp);
  settings.println(s.aggKp);
  settings.println(s.aggKi);
  settings.println(s.aggKd);
  settings.println(s.consKp);
  settings.println(s.consKi);
  settings.println(s.consKd);
  settings.close();
}


void getSettings() {
  SPIFFS.begin();
  // open file for reading
  File settings = SPIFFS.open("/settings.txt", "r");
  if (!settings) {
    Serial.println("file open failed");
    //makeSettings(); //create default values
  }
  for (int i = 1; i < 10; i++) { //I have 10 values stored
    String val = settings.readStringUntil('\n');
    s.TC_M1_OFFSET = val.toInt();
    val = settings.readStringUntil('\n');
    s.TC_M2_OFFSET = val.toInt();
    val = settings.readStringUntil('\n');
    s.TC_FB_OFFSET = val.toInt();
    val = settings.readStringUntil('\n');
    s.fireboxOffsetTemp = val.toInt();
    val = settings.readStringUntil('\n');
    s.aggKp = val.toFloat();
    val = settings.readStringUntil('\n');
    s.aggKi = val.toFloat();
    val = settings.readStringUntil('\n');
    s.aggKd = val.toFloat();
    val = settings.readStringUntil('\n');
    s.consKp = val.toFloat();
    val = settings.readStringUntil('\n');
    s.consKi = val.toFloat();
    val = settings.readStringUntil('\n');
    s.consKd = val.toFloat();
     settings.close();

    //Check that it worked now
    Serial.print("s.TC_M1_OFFSET is: ");
    Serial.println(s.TC_M1_OFFSET);
    Serial.print("s.consKd is: ");
    Serial.println(s.consKd);
    Serial.print("s.aggKd is: ");
    Serial.println(s.aggKd);
    Serial.print("s.fireboxOffsetTemp is: ");
    Serial.println(s.fireboxOffsetTemp);
  }
}

void makeSettings() { //create default values if the file doesn't exist
  Serial.println(F("First time run - No file found, so we'll create default values"));
  s.TC_M1_OFFSET = 0;
  s.TC_M2_OFFSET = 0;
  s.TC_FB_OFFSET = 0;
  s.fireboxOffsetTemp = 15;
  s.aggKp = 8;
  s.aggKi = 0.2;
  s.aggKd = 1;
  s.consKp = 2;
  s.consKi = 0.1;
  s.consKd = .5;
  saveSettings();
}

Yes, but if you’re using this settings for Pro, then it’s ok. You can also try changing IwIP variant to higher bandwidth instead of lower memory.

OK. I read something about the Wemos D1 Mini Pro – being the same as the D1 Mini, only with more memory, and someone had an issue with it, and they compiled it in the IDE as Wemos D1 R2 & Mini. I tried that and it’s like all my problems went away. The issue with it sometimes hanging up mainly, but also, it seemed to take for ever to compile and load and then the serial monitor was sluggish. Anyway, all is working great with it now. I have the wifi settings in a SPIFFS file that loads on startup, and if it can’t connect it switches to AP mode. And I have another SPIFFS file for my project settings, that the user can change thru the Blynk Terminal.
Thanks for all the help!

Hi! I have tried this code, I have a big flaw, when the esp8266 driver lost the source, then ssid, pass and blynk token must be re-setup. Do you have a solution?
Thank you very much

The code is designed to save these settings to SPIFFS memory on the ESP.
When you compile and upload the code in the Arduino IDE you have to choose to allocate some of the available memory to SPIFFS otherwise there is nowhere to save this data.
Once you’ve done that, take a good look at the serial monitor output, it tells you what’s happening at each stage of the process and will highlight where your problem lies.

Pete.

1 Like