Strange problem with esp32

Hello,

When i perform analogRead(26) (A0 or GPIO26) in my sketch without
blynk, i get normal value.

But if add even Blynk.begin() in setup(), and
get analogRead by timer, i get 4095 value permanent.

I can’t imagine how Blynk.begin changes analogRead value =(

My simple coode is:

#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

char auth[] = "44014567b8274c2cb99d90b42#####";
char ssid[] = "topwaynew1";
char pass[] = "########";


BlynkTimer timer;

#define GR1_PIN 26

int gr1=0;
boolean tictic=0;

void setup() {
  Serial.begin(115200);
  pinMode(GR1_PIN,INPUT);
  
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(6000L, sendUptime);
}

void sendUptime(){
  gr1=analogRead(GR1_PIN);      
  Serial.println("Light="+String(GR1_PIN)+", V:"+String(gr1));
  Blynk.virtualWrite(V20, gr1);
  tictic=!tictic;
}

// the loop function runs over and over again forever
void loop() {
  Blynk.run();
  timer.run();
}

and i see in terminal:
Light=26, V:4095

if i comment
// Blynk.begin(auth, ssid, pass);

i see in terminal right value:
⸮[5001] Connecting to 0.0.0.0
Light=26, V:1931

1 Like

Unless they (espressif) have done something recently, I understood that analogRead() didn’t work yet on the ESP32 EDIT - Nope, I was thinking of analogWrite()

Regardless… when you comment out Blynk.begin(auth, ssid, pass); then of course nothing is going to display correctly on your virtual pins. My coffee maker seems to stop working everytime I turn it off as well :stuck_out_tongue:

i dont use vpins, I use simple Serial.print to get results

Ah, I see… I thought you were referring to the Terminal Widget (on V20) not the IDE serial monitor.

What have you got on the (A0 or GPIO26) pin, and how is it wired? I will try and duplicate it on my ESP32.

afaik, this is not related to blynk, but to wifi on esp32.

try using a pin from adc1 until this issue gets solved.
the last comment also says there is a fix on the way:

"me-no-dev
commented 16 days ago
There is a fix coming for ADC2 and WiFi soon :slight_smile: "

more info about analog pins here:

https://esp-idf.readthedocs.io/en/v2.0/api/peripherals/adc.html

2 Likes

thank you !

I wonder if it is related to WiFi, I have the same problem when using Blynk with just BLE. The ADC1 channels seem to work, but the 3 ADC2 channels don’t. I would like to use those, because they are connected to a Grove breakout board that I am using.