Edge ESP8266

Hello friends,
I had a problem with the computer and I had to upload a sketch that I was already using without problem, but when I upload the new sketch with another ID I get an error message on the serial monitor, and I can’t enable the new device with my smartphone, where am I going wrong?

This is the error message,

   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.1.0 on NodeMCU

 #StandWithUkraine    https://bit.ly/swua


[4951] Current time: Wed Oct  5 01:20:27 2022

[4951] Connecting to blynk.cloud:443

[6832] Invalid auth token


this is my sketch


#define BLYNK_TEMPLATE_ID "xxxxxxxxx"
#define BLYNK_DEVICE_NAME "xxxxxxxx"


#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

//#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD

#include "BlynkEdgent.h"
#include <AceButton.h>
using namespace ace_button;

// define the GPIO connected with Relays and switches
#define RelayPin1 12  //D6 0 V3
//#define RelayPin2 15  //
#define RelayPin2 13 //D7 100 V1
#define RelayPin3 14 //D8 0 V2

//#define SwitchPin1 10  //SD3
#define SwitchPin1 10   //SD3 
#define SwitchPin2 15  //D5
#define SwitchPin3 3   //RX

#define wifiLed   16   //D0

//Change the virtual pins according the rooms
#define VPIN_BUTTON_1    V1
#define VPIN_BUTTON_2    V2
#define VPIN_BUTTON_3    V3 
//#define VPIN_BUTTON_4    V4

int toggleState_1 = 0; //Define integer to remember the toggle state for relay 1
int toggleState_2 = 0; //Define integer to remember the toggle state for relay 2
int toggleState_3 = 0; //Define integer to remember the toggle state for relay 3
//int toggleState_4 = 0; //Define integer to remember the toggle state for relay 4




void handleEvent1(AceButton*, uint8_t, uint8_t);
void handleEvent2(AceButton*, uint8_t, uint8_t);
void handleEvent3(AceButton*, uint8_t, uint8_t);
//void handleEvent4(AceButton*, uint8_t, uint8_t);

void relayOnOff(int relay){
    switch(relay){
      case 1: 
             if(toggleState_1 == 0){
              digitalWrite(RelayPin1, LOW); // turn on relay 1
              toggleState_1 = 1;
              Serial.println("Device1 ON");
              }
             else{
              digitalWrite(RelayPin1, HIGH); // turn off relay 1
              toggleState_1 = 0;
              Serial.println("Device1 OFF");
              }
             delay(100);
      break;
      case 2: 
             if(toggleState_2 == 0){
              digitalWrite(RelayPin2, LOW); // turn on relay 2
              toggleState_2 = 1;
              Serial.println("Device2 ON");
              }
             else{
              digitalWrite(RelayPin2, HIGH); // turn off relay 2
              toggleState_2 = 0;
              Serial.println("Device2 OFF");
              }
             delay(100);
      break;
      case 3: 
             if(toggleState_3 == 0){
              digitalWrite(RelayPin3, LOW); // turn on relay 3
              toggleState_3 = 1;
              Serial.println("Device3 ON");
              }
             else{
              digitalWrite(RelayPin3, HIGH); // turn off relay 3
              toggleState_3 = 0;
              Serial.println("Device3 OFF");
              }
      
              delay(100);
              
      
             
      break;
      default : break;      
      }  
}

BLYNK_CONNECTED() {
  // Request the latest state from the server
  Blynk.syncVirtual(VPIN_BUTTON_1);
  Blynk.syncVirtual(VPIN_BUTTON_2);
  //Blynk.syncVirtual(VPIN_BUTTON_3);
  Blynk.syncVirtual(VPIN_BUTTON_3);
}

// When App button is pushed - switch the state

BLYNK_WRITE(VPIN_BUTTON_1) {
  toggleState_1 = param.asInt();
  if(toggleState_1 == 1){
    digitalWrite(RelayPin1, LOW);
  }
  else { 
    digitalWrite(RelayPin1, HIGH);
  }
}

BLYNK_WRITE(VPIN_BUTTON_2) {
  toggleState_2 = param.asInt();
  if(toggleState_2 == 1){
    digitalWrite(RelayPin2, LOW);
  }
  else { 
    digitalWrite(RelayPin2, HIGH);
  }
}

BLYNK_WRITE(VPIN_BUTTON_3) {
  toggleState_3 = param.asInt();
  if(toggleState_3 == 1){
    digitalWrite(RelayPin3, LOW);
  }
  else { 
    digitalWrite(RelayPin3, HIGH);
  }
}


void setup()
{
  Serial.begin(115200);
  delay(100);
  
  pinMode(RelayPin1, OUTPUT);
  pinMode(RelayPin2, OUTPUT);
  pinMode(RelayPin3, OUTPUT);
 // pinMode(RelayPin4, OUTPUT);

  pinMode(wifiLed, OUTPUT);

  pinMode(SwitchPin1, INPUT_PULLUP);
  pinMode(SwitchPin2, INPUT_PULLUP);
  pinMode(SwitchPin3, INPUT_PULLUP);
 // pinMode(SwitchPin4, INPUT_PULLUP);

  //During Starting all Relays should TURN OFF
  digitalWrite(RelayPin1, HIGH);
  digitalWrite(RelayPin2, HIGH);
  digitalWrite(RelayPin3, HIGH);
//  digitalWrite(RelayPin4, HIGH);

  digitalWrite(wifiLed, HIGH);

  config1.setEventHandler(button1Handler);
  config2.setEventHandler(button2Handler);
  config3.setEventHandler(button3Handler);
 // config4.setEventHandler(button4Handler);

  button1.init(SwitchPin1);
  button2.init(SwitchPin2);
  button3.init(SwitchPin3);
 // button4.init(SwitchPin4);

  BlynkEdgent.begin();

  Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
  Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
  Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
 // Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4);

  //timer.setInterval(3000L, checkBlynkStatus); // check if Blynk server is connected every 3 seconds
}

void loop() {

    BlynkEdgent.run();

    //Manual Switch Control
    button1.check();
    button2.check();
    button3.check();
   // button4.check();
}

void button1Handler(AceButton* button, uint8_t eventType, uint8_t buttonState) {
  Serial.println("EVENT1");
  relayOnOff(1);
  Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);   // Update Button Widget
}
void button2Handler(AceButton* button, uint8_t eventType, uint8_t buttonState) {
  Serial.println("EVENT2");
  relayOnOff(2);
  Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);   // Update Button Widget
}
void button3Handler(AceButton* button, uint8_t eventType, uint8_t buttonState) {
  Serial.println("EVENT3");
  relayOnOff(3);
  Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);   // Update Button Widget
}

Thanks in advanced for help me

You need to re-provision your board, because Edgent uses dynamic Auth tokens and the old Auth token which is stored in EEPROM of your device will n9 longer match the Auth token that is expected.

Press the Blynk reset button on your board for 10 seconds and re-provision the device from the app, or use the app to reconfigure the device.

Pete.

1 Like

Hello Pete,
As always I followed your instructions and problem solved! Thank you so much for this one.
Just to clarify, for me to connect the new device via mobile, I connected to the AP that the ESP creates and appears in the list of networks, once connected I followed the steps to connect the ESP to the network I wanted by choosing the network name and putting the network password, and then the ESP connected and the LED starts to enter the predicted fade effect indicating that it is connected, I believe this is the right method, yes?
Greetings again, thank you, and congratulations for your knowledge and for sharing it.
kwiek.

That’s not the nicest way. You’d normally use the “+ Add Device” option in the app and you’ll see the device if it’s in “waiting to be provisioned” mode (LED flashing rapidly). This give you a simplified setup and more options.

Pete.

I actually tried the method you say is cooler, and on other occasions I did it this way, but today I don’t know why, despite the device appearing when placing and following the steps of +Device, and the LED flashing quickly, but at the time after connecting, it ended with the following message: message: Could not connect, check if the mobile and device are close to the router, (Both were) I tried several times without success, until I connected the mobile to the ESP that appeared in the list of networks , and connected on time.

Obviously following the same steps as +Device

Thank you Pete!

kwiek