ESP32 - void not runing

Hello everyone !

I recently purchased ESP32s. While wanting to test them before putting them into service, I realized that the void after the void loop does not launch. In my case the void “analogRead”. I don’t understand, certainly something stupid that I forgot. The same code works on my ESP8266.
At launch I have the return of connection of the ESP32 to the blynk server then nothing more.
if I put my void “analogRead” in the void loop it works.

Any ideas ?

Thank you



#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
//
#define AOUT_PIN 34
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxx";
char ssid[] = "xx";
char pass[] = "xx";
SimpleTimer timer;

void setup() {  
 
  Serial.begin(115200);

  delay(10);
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, pass);
  int wifi_ctr = 0;
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("WiFi connected");  

   Blynk.begin(auth, ssid, pass, IPAddress(10, 3, 141, 1), 8080);
   
   timer.setInterval(2000L, analogRead);

   
}

void loop(){
    Blynk.run();
    
}

void analogRead()
{
int value = analogRead(AOUT_PIN); // read the analog value from sensor

  Serial.print("Moisture value: ");
  Serial.println(value);

  delay(500);

}

You need to add timer.run(); to your void loop.

In future, if you’re using a Legacy local server then you should state this at the very beginning of your post, as this is now an extremely unusual occurrence.

Pete.

Of course I still use it. Not you ?
I have a lot of projects in local server. The new possibilities of 2.0 are interesting but 1.0 suits me much better because I can use it without an internet connection.
Have you upgraded to 2.0?

I suspected it was stupidity like that…

Thanks Pete

You’re in the extreme minority and when people look at forum posts they assume that the user is running Blynk IoT unless they explicitly state that they are not.
So, when you make posts that relate to Blynk Legacy you need to explicitly state that this is what you are using.

Pete.