/*************************************************************
You can use this sketch as a debug tool that prints all incoming values
sent by a widget connected to a Virtual Pin 1 in the Blynk App.
App dashboard setup:
Slider widget (0...100) on V1
*************************************************************/
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL648ZjHLIy"
#define BLYNK_TEMPLATE_NAME "MyEsp32"
#define BLYNK_AUTH_TOKEN "T3Da6oyKdp6ssg7IA5IMdoVFmpzuBx_M"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define LED 2
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "iNoomniim_2G";
char pass[] = "0011000111";
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
BLYNK_WRITE(V0)
{
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("V0 Slider value is: ");
Serial.println(pinValue);
if(pinValue ==1){
digitalWrite(LED,HIGH);
}else{
digitalWrite(LED,LOW);
}
}
BlynkTimer timer;
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V1, millis() / 1000);
}
void setup()
{
// Debug console
Serial.begin(115200);
pinMode(LED,OUTPUT);
Blynk.begin(BLYNK_AUTH_TOKEN, "iNoomniim_2G", "0011000111");
timer.setInterval(1000L, myTimerEvent);
// You can also specify server:
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}