0
\$\begingroup\$

I'm a beginner and I'm working on a project to light an LED using DOIT ESP32 devkit v1. I want to turn on and off the LED using a phone app via wifi (using Blynk application). I'm using the following code on Arduino IDE (version 1.8.13):

#define BLYNK_PRINT Serial
#define LED 2

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "...";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "...";
char pass[] = "...";

void setup() {  
  pinMode(LED, OUTPUT); 
  pinMode(LED, HIGH);
  Serial.begin(115200);

  delay(10);
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, pass);
  int wifi_ctr = 0;
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("WiFi connected");  

  Blynk.begin("Your auth token key", ssid, pass);

}

void loop(){
    Blynk.run();
}

The connection to the wifi succeeded, But when I press the serial monitor button I get an error saying "Invalid auth token"

enter image description here

I don't understand what am I doing wrong, I've check the auth key few times, that's the right one. In the Blynk project I've chose ESP32 Dev Kit and in the Arduino IDE I chose DOIT ESP32 Dev Kit V1 along with port COM4 (I've made sure that's the right one). I think the problem is that I'm not using Blynk right, What do I need to do?

Thank you.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ which part of the code sends the token? ... have you tried running blynk example code? \$\endgroup\$
    – jsotola
    Commented Sep 24, 2020 at 7:02
  • 2
    \$\begingroup\$ Check char auth[] = "..."; and Blynk.begin("Your auth token key", ssid, pass); \$\endgroup\$ Commented Sep 24, 2020 at 7:25

1 Answer 1

1
\$\begingroup\$

I did Have a problem in Blynk.begin("Your auth token key", ssid, pass); missed one letter in the auth token. (probably didn't copy correctly) I read it 100 times and still missed it, thank you everyone for your help.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.