dear all , i am trying to get data from my datastreams V6 . it is an int. with
BLYNK_WRITE(V6)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
Serial.print("V6 Slider value is: ");
Serial.println(pinValue);
}
however it doesn’t to run ever . I had my full code belwo : can anyone give me some suggetion ?
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "********"
#define BLYNK_TEMPLATE_NAME "****"
#define BLYNK_AUTH_TOKEN "****"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
BLYNK_WRITE(V6)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V6 Slider value is: ");
Serial.println(pinValue);
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop()
{
Blynk.run();
}
@tommynewman Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
sorry for my tuping mistook regarding V1 and V6 .
i had added
Blynk.syncVirtual(V1); after Blynk.run(); in the main loop ().
i am able to read from V1 . It is a good way to do so?
It’s just a function, so can go anywhere in your sketch, provided it’s not inside another function.
But, its only purpose is to run code once when Blynk first connects or re-connects. I would suggest you read the documentation to understand the correct use of BLYNK_CONNECTED() and Blynk.syncVirtual(vPin before using them in your code.