Aidid
November 18, 2022, 8:51am
1
I tried this coding on old blynk and it works well, but when jump into new blynk the control cannot operate.
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""
#define BLYNK_AUTH_TOKEN ""
#define BLYNK_PRINT Serial
const byte led= 2;
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "";
char pass[] = "";
void setup() {
pinMode(led, OUTPUT);
Serial.begin(115200);
delay(10);
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
}
John93
November 18, 2022, 9:01am
2
Do you mean that your device is online but the LED is not working, or that you’re trying to connect your device to the cloud with no success ?
Aidid
November 18, 2022, 9:04am
3
yup successfully connected to the blynk, but when I push button from blynk web, led not reflected (still low) .
John93
November 18, 2022, 9:06am
4
I guess you’re using a digital pin datastream. If that’s the case, then I highly recommend using virtual pins instead.
https://docs.blynk.io/en/blynk.edgent-firmware-api/virtual-pins
Aidid
November 18, 2022, 9:17am
5
I tried the virtual pin , but still same.
John93
November 18, 2022, 9:17am
6
Posting the updated sketch might help.
Aidid
November 18, 2022, 9:19am
7
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""
#define BLYNK_AUTH_TOKEN ""
#define BLYNK_PRINT Serial
const byte led= 2;
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "";
char pass[] = "";
void setup() {
pinMode(led, OUTPUT);
Serial.begin(115200);
delay(10);
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
}
For virtual pins to work, you need to have additional code that is triggered when the virtual pin is pressed.
This consists of callback functions with the name ’BLYNK_WRITE(vPin)’ where ’vPin’ is the virtual PIN number of your datastream.
Read this for more info…
I thought I’d write a guide about how to use virtual pins with app widgets such as buttons, to control physical devices such as relays, LEDs etc…
Why use virtual pins anyway?
I’d always recommend using virtual pins over physical pins when developing your code. There are a number of reasons, but here are what I consider to be the main ones:
Virtual pins are hardware independent. This means that it’s far easier to port your code from one hardware platform to another in future (when you realise…
Pete.
1 Like