#define BLYNK_TEMPLATE_ID "TMPLOCRXh0T1"
#define BLYNK_TEMPLATE_NAME "TESTING"
#define BLYNK_AUTH_TOKEN "4SNtY61KC-K8G3IZfZyWWKpG3zy_3Z-l"
#define BLYNK_PRINT Serial
#define WIFI_SSID "Wokwi-GUEST"
#define WIFI_PASSWORD ""
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define PINSwitch V1
#define PINRegulate V3
bool Switch;
double Regulate;
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
void updateCondition()
{
if(Switch == true)
{
Blynk.virtualWrite(PINRegulate, Regulate);
}
else
{
Blynk.virtualWrite(PINRegulate, 0);
String Sregulate = String(Regulate);
Sregulate = " ";
Serial.println(Sregulate);
}
}
BLYNK_WRITE(PINSwitch)
{
Switch = param.asInt(); // assigning incoming value from pin V1 to a variable
updateCondition();
Serial.print("Switch condition: ");
Serial.println(Switch);
}
BLYNK_WRITE(PINRegulate)
{
Regulate = param.asDouble(); // assigning incoming value from pin V1 to a variable
Serial.print("Setting Temperature: ");
Serial.println(Regulate);
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, WIFI_PASSWORD, WIFI_SSID);
// 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();
updateCondition();
}