So when i run my code without the blynk interface commands it works perfectly fine, but when i run the blynk.begin command it breaks all my readings and the out put is 0 (should be 2800). I believe it has something to do with the baud rate of blynk needed to be set differently than the serial output but still confused why output would be altered. When i comment out the begin command works perfectly fine although not connected to blynk…
If someone could direct me to an article that better explains this or offer a simple fix i can copy in that would be great!
#define BLYNK_TEMPLATE_ID "xxx"
#define BLYNK_DEVICE_NAME "xxx"
#define BLYNK_AUTH_TOKEN "xxx"
#define sensor1 27
#define sensor2 25
#define sensor3 26
//CONNECT TO INTERNET AND VERIFY CREDENTIALS
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
////WIFI STUFF CHANGE TO YOUR NETWORK OR DEVICE WONT CONNECT TO WIFI
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xx";
char pass[] = "xx";
void setup() {
// put your setup code here, to run once:
//Blynk.begin(auth, ssid, pass);
Serial.begin(115200);
pinMode(sensor1, INPUT);
pinMode(sensor2, INPUT);
pinMode(sensor3, INPUT);
}
void loop() {
Blynk.run();
Serial.print("Sensor1: ");
Serial.println(analogRead(sensor1));
Serial.print("Sensor2: ");
Serial.println(analogRead(sensor2));
Serial.print("Sensor3: ");
Serial.println(analogRead(sensor3));
Serial.println(" ");
int dry1 = 2895; // value for dry sensor
int dry2 = 2885; // value for dry sensor
int dry3 = 2890; // value for dry sensor
int wet1 = 1070; // value for dry sensor
int wet2 = 1150; // value for dry sensor
int wet3 = 1080; // value for dry sensor
int sensorVal1 = analogRead(sensor1);
int percentageHumididy1 = map(sensorVal1, wet1, dry1, 100, 0);
int sensorVal2 = analogRead(sensor2);
int percentageHumididy2 = map(sensorVal2, wet2, dry2, 100, 0);
int sensorVal3 = analogRead(sensor3);
int percentageHumididy3 = map(sensorVal3, wet3, dry3, 100, 0);
Serial.print(percentageHumididy1);Serial.println("%");
Serial.print(percentageHumididy2);Serial.println("%");
Serial.print(percentageHumididy3);Serial.println("%");
// Blynk.virtualWrite(V35,percentageHumididy1);
// Blynk.virtualWrite(V36,percentageHumididy2);
// Blynk.virtualWrite(V37,percentageHumididy3);
delay(5000);
}