I have problem to display my data in thingspeak
the data are not same as in my serial monitor
Hardware use:
1- Esp 32
2- MQ 135, MQ 7, MQ 4, MQ 8 (GAS SENSOR)
This is my coding
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "jO6eiUFb7TYwBGjUEp5YmYMc3FRolDP7";
char ssid[] = "nino_ai";
char pass[] = "faris2210";
int redLed = 5;
int yellowLed = 17;
int greenLed = 16;
int gas1 = 33;
int gas2 = 32;
int gas3 = 35;
int gas4 = 34;
int analogSensor1 = 0;
int analogSensor2 = 0;
int analogSensor3 = 0;
int analogSensor4 = 0;
BlynkTimer timer;
void setup()
{
pinMode(redLed, OUTPUT);
pinMode(yellowLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(gas1, INPUT);
pinMode(gas2, INPUT);
pinMode(gas3, INPUT);
pinMode(gas4, INPUT);
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
digitalWrite(redLed, 0);
digitalWrite(yellowLed, 0);
digitalWrite(greenLed, 0);
timer.setInterval(1000L, myTimerEvent);
timer.setInterval(5000L, SendToThingspeak);
}
void myTimerEvent()
{
Blynk.virtualWrite(V1, analogSensor1);
Blynk.virtualWrite(V2, analogSensor2);
Blynk.virtualWrite(V3, analogSensor3);
Blynk.virtualWrite(V4, analogSensor4);
}
void loop()
{
Blynk.run();
timer.run();
analogSensor1 = analogRead(gas1);
analogSensor2 = analogRead(gas2);
analogSensor3 = analogRead(gas3);
analogSensor4 = analogRead(gas4);
Serial.print("Sensor 1: ");
Serial.println(analogSensor1);
Serial.print("Sensor 2: ");
Serial.println(analogSensor2);
Serial.print("Sensor 3: ");
Serial.println(analogSensor3);
Serial.print("Sensor 4: ");
Serial.println(analogSensor4);
Serial.println();
delay(100);
if ((analogSensor1 > 100 && analogSensor1 < 500) && (analogSensor2 > 100 && analogSensor2 < 500) && (analogSensor3 > 100 && analogSensor3 < 500) && (analogSensor4 > 100 && analogSensor4 < 500))
{
digitalWrite(redLed, 0);
digitalWrite(yellowLed, 0);
digitalWrite(greenLed, 1);
}
else if ((analogSensor1 > 500 && analogSensor1 < 1500) && (analogSensor2 > 100 && analogSensor2 < 500) && (analogSensor3 > 100 && analogSensor3 < 500) && (analogSensor4 > 100 && analogSensor4 < 500))
{
digitalWrite(redLed, 0);
digitalWrite(yellowLed, 1);
digitalWrite(greenLed, 0);
}
else if ((analogSensor1 > 1500 && analogSensor1 < 3000) && (analogSensor2 > 100 && analogSensor2 < 500) && (analogSensor3 > 100 && analogSensor3 < 500) && (analogSensor4 > 100 && analogSensor4 < 500))
{
digitalWrite(redLed, 1);
digitalWrite(yellowLed, 0);
digitalWrite(greenLed, 0);
}
}
void SendToThingspeak()
{
Blynk.virtualWrite(V0, gas1, gas2, gas3, gas4);
}
Thats all thankyou
Hope for fast respomse