This code work perfectly fine.
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6Im5ueUYs"
#define BLYNK_TEMPLATE_NAME "gas"
#define BLYNK_AUTH_TOKEN "YoSG3piv1DOpv_hW56UAPjNgqtCqZodZ"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char ssid[ ] = "babe";
char pass[] = "bruhbruh";
#include <MQ135.h>
#include <DHT.h>
#define PIN_MQ135 25
#define DHTPIN 14
#define DHTTYPE DHT22
MQ135 mq135_sensor(PIN_MQ135);
DHT dht(DHTPIN, DHTTYPE);
float temperature, humidity;
BlynkTimer timer;
void setup() {
Serial.begin(9600);
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
dht.begin();
}
void loop() {
humidity = dht.readHumidity();
temperature = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temperature)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
float correctedPPM = mq135_sensor.getCorrectedPPM(temperature, humidity);
Serial.print("\nCorrected PPM: ");
Serial.print(correctedPPM);
Serial.println("ppm");
Serial.print("humidity: ");
Serial.print(humidity);
Serial.println("%");
Serial.print("temperature: ");
Serial.print(temperature);
Serial.println("*C");
Serial.print("Raw MQ135: ");
Serial.println(analogRead(PIN_MQ135));
// Blynk.virtualWrite(V2, correctedPPM);
// Blynk.virtualWrite(V0, humidity);
// Blynk.virtualWrite(V1, temperature);
delay(1000);
}
Output(Serial monitor): Corrected PPM: 97.26ppm
humidity: 74.20%
temperature: 30.40*C
Raw MQ135: 120
but, when blynk added.
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6Im5ueUYs"
#define BLYNK_TEMPLATE_NAME "gas"
#define BLYNK_AUTH_TOKEN "YoSG3piv1DOpv_hW56UAPjNgqtCqZodZ"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char ssid[] = "babe";
char pass[] = "bruhbruh";
#include <MQ135.h>
#include <DHT.h>
#define PIN_MQ135 25
#define DHTPIN 14
#define DHTTYPE DHT22
MQ135 mq135_sensor(PIN_MQ135);
DHT dht(DHTPIN, DHTTYPE);
float temperature, humidity;
BlynkTimer timer;
void setup() {
Serial.begin(9600);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
dht.begin();
}
void loop() {
humidity = dht.readHumidity();
temperature = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temperature)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
float correctedPPM = mq135_sensor.getCorrectedPPM(temperature, humidity);
Serial.print("\nCorrected PPM: ");
Serial.print(correctedPPM);
Serial.println("ppm");
Serial.print("humidity: ");
Serial.print(humidity);
Serial.println("%");
Serial.print("temperature: ");
Serial.print(temperature);
Serial.println("*C");
Serial.print("Raw MQ135: ");
Serial.println(analogRead(PIN_MQ135));
// Blynk.virtualWrite(V2, correctedPPM);
// Blynk.virtualWrite(V0, humidity);
// Blynk.virtualWrite(V1, temperature);
delay(1000);
}
I just uncomment the Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); and my mq135 stop send any signal.
The output look like this(Serial monitor):
Corrected PPM: 0.00ppm
humidity: 74.30%
temperature: 30.40*C
Raw MQ135: 0
I don’t know why mq135 can’t send any signal back to my esp32_wrover
Help.