Change auth, ssid and pass from BLYNK terminal for NANO+ESP-01 project

Of course, very neat.

But i have a question, if your customer get your product, at the first time, how can they connect the Esp to wifi with your default SSID and Password?

It’s in the manual, probably :slight_smile:

I set in the program as SSID and PASS any value, for example, AAA and BBB. Client on your phone, set it as the parameters for mobile HOTSPOT. The module connects to the Internet via mobiles Hotspot and the client can put own network parameters to the program. After changing the status of the port 8 to LOW and reset program will log on to the network client.

2 Likes

that’s great idea…

Blynk has also Wi-Fi wizard for business. We call it Provisioning. In few clicks you can connect your device with your network from the app.

In the bottom of http://www.blynk.io/business/ you can find few screenshots.

1 Like

This means that I lost a whole week to prepare and test the login procedure.
What a pity :angry:

The work you did will be invaluable to many.

:slight_smile:
thank you Costas

@krzyspx see your great work in action with a Wio Link (CONFIG button)

Don’t worry about the token, I have changed it on my device :slight_smile:

It’s cool, that application works for ESP also. Is something had to change in the code e.g. writing to the EEPROM?
Good idea with RST button.
Thanks

No changes required for EEPROM.

I switched to EEPROM by default and Smartphone AP with pin 0 HIGH (not LOW).
So on a Wio Link it is, press the RESET button and then within a fraction of a second press the CONFIG button to ensure it boots to AP. You can’t hold pin 0 down and do a reset or you go into flashing mode.

@krzyspx could I please ask you to provide a sketch extract for us to attach to another button (in Switch mode) that would set the next boot up mode i.e. without the use of a physical button, into Smartphone AP connection or EEPROM connection.

So a flag would be set in the Blynk project to EEPROM for connection type 1 or 2 and if the physical button is not pressed it takes the EEPROM flag to determine the connection type.

See initial extract below, just needs the EEPROM flag write and read on bootup.

String nextbootstring;
BLYNK_WRITE(V14) // next boot, EEPROM flag to have 2 values, 
                 // 0 normal boot based on physical button state of HIGH or LOW
                 // 1 boot from EEPROM credentials
{
  int nextboot = param.asInt(); // ON EEPROM, OFF AP CREDENTIALS
  if (nextboot == 1) {  // boot from EEPROM credentials
    nextbootstring = "ESP will boot from EEPROM credentials next time.";
    // code here, set an EEPROM flag to 1, read at bootup if physical button is not pressed 
  }
  else{   // boot from AP credentials
    nextbootstring = "ESP will boot from AP credentials next time."; 
    // code here, if EEPROM flag is 1, set to 0
  }
  terminal.println(nextbootstring);
  terminal.flush();
}

Ok I have made the required changes and it all seems fine.

So now wyborwifi() looks like this:

void wyborwifi() // Select WiFI boot up mode
{
  pinMode(PIN_CONFIG, INPUT_PULLUP);  // was pin 8
  int m = digitalRead(PIN_CONFIG);    // was pin 8
  EEPROM.begin(4); // read in first byte at address 0
  int eeAddr = 0;
  bootflag = EEPROM.read(eeAddr);// read EEPROM flag for boot mode
  delay(100);
  if ((m == 1) && (bootflag != 1)){ // if pin is HIGH (default) use Smartphone AP credentials, else use EEPROM credentials
    smartphoneconnect();   // use Smartphone AP credentials
  }
  else     
  {
    eepromconnect();       // use EEPROM credentials    
  }
}

And the button code is:

int bootflag; // 0 normal Smartphone AP boot, 1 EEPROM credentials boot
String nextbootstring;
BLYNK_WRITE(V14) // next boot, EEPROM flag to have 2 values, 
                 // 0 normal boot based on physical button state of HIGH or LOW
                 // 1 boot from EEPROM credentials
{
  int nextboot = param.asInt(); // ON EEPROM, OFF AP CREDENTIALS
  if (nextboot == 1) {  // boot from EEPROM credentials
    nextbootstring = "ESP will boot from EEPROM credentials next time.";
    bootflag = 1; 
    int eeAddr = 0;
    EEPROM.write(eeAddr, bootflag);
    EEPROM.commit();
  }
  else{   // boot from AP credentials
    nextbootstring = "ESP will boot from AP credentials next time."; 
    if(bootflag == 1){  // only write value to EEPROM if flag is currently 1
      bootflag = 0;
      int eeAddr = 0;
      EEPROM.write(eeAddr, bootflag);
      EEPROM.commit();
    }
  }
  terminal.println(nextbootstring);
  terminal.flush();
}

Tested and works ok.
Edit: @krzyspx I have moved all your starting addresses from 0 to 1 and now the sketch with read and write is fine, rather than get and put.

1 Like

It’s a great solution - replace the physical button on the record byte EEPROM
First - the customer does not have to open the case to change the wifi
second - it is able to support more than two networks stored in the program memory or EEPROM
Thank you very much Costas for the creative development of the project

Can you spot the bugs in my code as it is not booting from EEPROM credentials?

I have tried changing bootflag from int to String but still no joy.

I’m not a programmer, but the electronics only.:relaxed:
I would put byte to memory by command EEPROM.write and read - EEPROM.read and should it work

But put and get is working for your strings so why not mine of “0” and “1”?

I can try read and write.

@krzyspx sketch extract above with the note about moving your addresses from 0 to 1 is now working OK.

I have a problem with the procedure EEPROM.begin (4) - compilation hangs
EEPROM.begin () is OK
what Arduino IDE you use? CC or ORG?
I had to change to the CC because in ORG did not work procedures put and get eeprom. And do not need call EEPROM.begin procedure

1 Like