How to connect wokwi to blnyk?

I have a project on wokwi using ESP32 and I’m having a hard time connecting it to blynk due to the lack of tutorials available,maybe someone can help me tell me what to do.
there is an error library “BlynkEdgent.h” not found, how to solve it…
i use : BLYNK_FIRMWARE_VERSION “0.1.0” in my wokwi code

i use blynk IOT or new version of blynk

That’s usually because you have only opened the .ino file of the Edgent example, and are missing all of the others.
If you open the Edgent example in the Arduino IDE you should see multiple tabs, like this:

That’s simply a way for you ro track your own code revisions, and is only used when Blynk.Air OTA updates are pushed to the device.

You should be using Blynk C++ library version 1.1.0 but that is something entirely separate to the BLYNK_FIRMWARE_VERSION variable within the sketch.

You also appear to have deleted some important lines of code from the top of your sketch…

// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID           "REDACTED"
#define BLYNK_DEVICE_NAME           "REDACTED"

Without adding this data from your template configuration in the Blynk web console your sketch will never work.
You should also un-comment one of these lines, which you also appear top have deleted:

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_WROVER_BOARD
//#define USE_TTGO_T7
//#define USE_ESP32C3_DEV_MODULE
//#define USE_ESP32S2_DEV_KIT

and/or check that the board type you are using in Settings.h matches your board.

But, I’ve be very surprised if an emulator could successfully emulate a device so that it can be provisioned by the Blynk app, so I doubt that the Edgent sketch is the best way forward. You’d be better starting with a simple Blynk WiFi connection sketch instead, creating the device from your template in the Blynk web console, the adding the auth token and your WiFi credentials to the sketch.

Pete.

Thanks for your advice, but how to use auth token and WiFi credentials in wokwi…?

I think you have to install the Wokwi public gateway then use the “Wokwi-GUEST” SSID and blank password.

The Blynk Auth token is obtained from the device you create from your template in the web console, and it’s used in the Blynk.begin command.

Have you looked at the Sketch Builder examples to see how it’s used?..

Pete.

I haven’t seen it yet…, how do I get the Auth Token?

Blynk edgent doesn’t work with wokwi, but a non edgent sketch works fine.
You can start with a basic example like this

#define BLYNK_TEMPLATE_ID           "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_AUTH_TOKEN            "YourAuthToken"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


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

char auth[] = BLYNK_AUTH_TOKEN;

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

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

Just go to the console/devices/device info tab, copy the template ID, template name, and the auth token, and add it to the sketch, then set the ssid to “Wokwi” and the pass to " " and it should work.

thank you, but still error error: ‘v1’ was not declared in this scope
WidgetLCD lcd(v1); where should i put it?

It should be (V1), you should use uppercase V not lowercase v.

I’ve already told you twice!
Maybe if you don’t want to read what I write then take a look at the documentation…

Pete.

i have to connect the same Wifi in both wokwi and blynk too?

i have successfully connected in wokwi with my WiFi, but there is a little problem in blynk that can’t connect to WiFi. maybe i will try again later. thank you for taking the time to help me

Why ?

Blynk will manage your WiFi connecti9n. Don’t use the Wokwi WiFi connection code, just the credentials, as I said before.

Pete.