hi, im pretty new with this. for the past few days i was unable to connect to Blynk, but the wifi shows up on my phone then after i upload the code, the wifi didnt show up or able to connect to the Blynk app. below here is my code.
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
BlynkTimer timer;
char auth[] = "EjTxXLZL-OpFO18kQbcAx22sA9N_WZtl";
char ssid[] = "cubaan";
char pass[] = "12345";
int redLed = 19;
int greenLed = 21;
int smokeA0 = 34;
int sensorValue = 0;
boolean state = false;
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(smokeA0, INPUT);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
Serial.print("Connecting to Wifi");
}
void loop() {
int analogSensor = analogRead(smokeA0);
Serial.print("Pin A0: ");
Serial.println(analogSensor);
// Checks if it has reached the threshold value
if (sensorValue > 200)
{
Blynk.notify("Gas Detected!");
digitalWrite(greenLed, LOW);
digitalWrite(redLed, HIGH);
}
else
{
digitalWrite(greenLed, HIGH);
digitalWrite(redLed, LOW);
}
delay(1000);
} ```
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: ```
1 Like
Hey there,
First, you should read this
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean
Second, are you using blynk legacy or IOT ?
1 Like
i see, thanks!
im using blynk legacy
Check this very useful article
1 Like