Serial monitor readings are broken when Blynk.begin(auth, ssid, pass) is used

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);
}

Also if there is a way to use two devices with the same app interface? When i loaded new device it just copied templete so now i have a copy of my main project with dead virtual pins rather then all the data feeding to one sceen.

First of all, you should read this
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

1 Like

These are ADC2 pins, which cannot be used with WiFi.

You should read this:

In particular the part that says:

Pete.

This could fix it but currently im not even reading the data on blynk im reading from my serial monitor and when i disable blynk.begin it reads correct data could it also be something to do with them being on same baud rate? i have this exact code working with a ph sensor so really confused…

Ill get back to you on changing the pins im using a KEEYEES esp32 nodemcu though and from what i saw the layout is different.

@PeteKnight ^

What’s your point?

Pete.

@PeteKnight im confused sorry. Would connecting to wifi cause an error in the pin readout even just on my serial monitor? I thought u were saying the data sent over wifi would be corrupt not like the hardware wouldn’t work once connected to wifi. Also how would I determine which is a adc2 as none of mine were and I was using adc17,18,19

I’d start by clicking on the link I provided and reading it, all will become clear when you do that.

Pete.