![Why is conversion time 10 instances slower in my ESP32-WROOM-32U? Why is conversion time 10 instances slower in my ESP32-WROOM-32U?](https://techtoguide.com/wp-content/uploads/2023/12/esp32-Arduino-GFX-Library-breaks-after-reinstalling.png)
[ad_1]
The next code is used to point out conversion time and most sampling frequency. The code is from this GitHub web page for a spectrum analyzer based mostly on the ESP32. The writer in his YouTube video reveals that his studying is round 10 μs for the conversion time and round 100000 Hz as most sampling frequency.
Right here is my case:
Conversion time: 93.54 uS
Max sampling frequency: 10690.92 Hz
It’s 10 instances slower! What’s the downside?
#outline AUDIO_IN_PIN 35
int analogValue;
unsigned lengthy newTime;
void setup() {
Serial.start(115200);
Serial.println("START");
}
void loop() {
newTime = micros();
// Do 1 million reads and file time taken
for (int i = 0; i < 1000000; i++) {
analogValue = analogRead(AUDIO_IN_PIN);
}
float conversionTime = (micros() - newTime) / 1000000.0;
Serial.println("END");
Serial.print("Conversion time: ");
Serial.print(conversionTime);
Serial.println(" uS");
Serial.print("Max sampling frequency: ");
Serial.print((1.0 / conversionTime) * 1000000);
Serial.println(" Hz");
}
Edit: Sorry my dangerous, I added yield()
to see what occurs, however nothing has modified.
Edit: I’ve tried the @thebusybee recommandation and the consequence is similar!
void loop() {
newTime = micros();
//delay(10);
//delay(100);
delay(1000);
// Do 1 million reads and file time taken
for (int i = 0; i < 1000000; i++) {
analogValue = analogRead(AUDIO_IN_PIN);
}
float conversionTime = (micros() - newTime) / 1000000.0;
Serial.println("END");
Serial.print("Conversion time: ");
Serial.print(conversionTime);
Serial.println(" uS");
Serial.print("Max sampling frequency: ");
Serial.print((1.0 / conversionTime) * 1000000);
Serial.println(" Hz");
}
[ad_2]