Your sketch doesn’t have any # include <> statements for the Blynk libraries, so its impossible for it to compile as it stands.
You’re also using SimpleTimer instead of BlynkTimer, but you don’t have a # include <> statement for that library either…
This line doesn’t belong in this sketch…
and this won’t work with Blynk IoT because it’s a Legacy command…
Even if it did work, or you replaced it with the IoT equivalent (logEvent) then you’d send the same notification once every second while data > 500 and quickly hit the allowed limit for events.
Read this for more info on how to do notifications in Blynk IoT and how to use ‘flag’ variables to avoid unwanted repeat notifications…
i have corrected the code and it is able to compile but still cannot connect to blynk and the serial monitor is also blank . thank you
#include <SimpleTimer.h>
#include<WiFiClient.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "lRoRyr52ZZomiPLKEPaCoiha1MHDVpI6"
/* WiFi credentials */
char ssid[] = "anjing";
char pass[] = "bajingan";
char server[] = "blynk-cloud.com";
int port = 8080;
char auth[] = "lRoRyr52ZZomiPLKEPaCoiha1MHDVpI6";
SimpleTimer timer;
int mq135 = A0; // smoke sensor is connected with the analog pin A0
int data = 0;
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, pass);
Blynk.config(auth, server, port);
timer.setInterval(1000L, getSendData); // new data will be updated every 1 sec
}
void loop()
{
timer.run(); // Initiates SimpleTimer
Blynk.run();
}
/***************************************************
* Send Sensor data to Blynk
**************************************************/
void getSendData()
{
data = analogRead(mq135);
Blynk.virtualWrite(V4, data); //
}
this is the code that is updated t. it is able to connect with blynk but the problem is data is not be able to send to my template
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "lRoRyr52ZZomiPLKEPaCoiha1MHDVpI6"
#include<WiFiClient.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
/* WiFi credentials */
char ssid[] = "anjing";
char pass[] = "bajingan";
char server[] = "blynk.cloud";
int port = 8080;
int mq135 = 34; // smoke sensor is connected with the analog pin A0
char auth[] = "lRoRyr52ZZomiPLKEPaCoiha1MHDVpI6";
int analog_data=analogRead(mq135);
BlynkTimer timer;
void sendSensor()
{
Blynk.virtualWrite(V4,analog_data);
delay(300);
}
void setup()
{
Serial.begin(9600);
WiFi.begin(ssid, pass);
Blynk.config(auth, server, port);
timer.setInterval(1000L, sendSensor); // new data will be updated every 1 sec
}
void loop()
{
timer.run(); // Initiates SimpleTimer
Blynk.run();
Serial.println(analog_data);
delay(200);
}