I’m trying to read an Analog Sensor every 5 Seconds, push it to Blynk, go to deep Sleep and repeat. If i use the Serial Interface everything works fine, but as soon as i add Blynk i only get the max Value(4095) as output of the Sensor. The Sensor is connected to pin D13.
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP 5 /* Time ESP32 will go to sleep (in seconds) */
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
const char auth[]="**********************************";
const char ssid[]="****************";
const char pwd[]="***************";
RTC_DATA_ATTR int bootCount = 0;
void Blynk_put(){
Serial.println(analogRead(13));
Blynk.virtualWrite(V0,analogRead(13));
}
void setup(){
Serial.begin(115200);
Blynk.begin(auth,ssid,pwd);
delay(1000); //Take some time to open up the Serial Monitor
//Increment boot number and print it every reboot
++bootCount;
Serial.println("Boot number: " + String(bootCount));
//Print the wakeup reason for ESP32
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) +
" Seconds");
Blynk_put();
Serial.println("Going to sleep now");
delay(1000);
Serial.flush();
esp_deep_sleep_start();
}
void loop(){
//This is not going to be called
}