0

I was testing analog output from a microphone (Max9814) with an Arduino Uno, which came with nice results. The output provided by the microphone is converted into sound and is loud and clear.

Setup: (Max to Uno)

  • Pin Vdd to 3,3V
  • Pin GND to GND
  • Pin Out to A0

However when I tried to set it up with an ESP12e instead of an Uno, I got a lot of 'noise' and no clear sound at all.

Here I used the following setup: (Max to ESP)

  • Pin Vdd to VCC (VCC is measured at 3.3v with a multimeter)
  • Pin GND to GND
  • Pin Out to AD0

A little 'side step'

The problem arised that the analog output from the microphone delivered a voltage of around 1.24, while the ESP12e analog has 1v as max input. This made the analogRead max out all the time. For this reason I put a 10k OHM resistor between the OUT and AD0 combined with a 20k OHM resistor between gnd and AD0. This resulted into nice analog readings (instead of 1024, around 400-500 all the time).

However, like mentioned before, a lot of noise is in between and the sound is not clear. (I also tried to work with 'sample windows', here is the 'filtering mechanism' which can be found on many sites/questions and works perfectly fine):

//(global logic is set to take n samples and than print the line)
//Tried n of 5 to 20
//Also instead of just samples tried the micros variant instead of just samples which is also found on many sites to create a time window to record.
unsigned int sample = analogRead(A0);
if (sample < 1024) {  // toss out spurious readings
  if (sample > signalMax) {
    signalMax = sample;  // save just the max levels
  } else if(sample < signalMin) {
    signalMin = sample;  // save just the min levels
  }
}

unsigned int peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
Serial.println(peakToPeak);

Does somebody have a clue why the Arduino gives such clear and good sound, while the ESP12e does not. (The analog values do not 'seem' to differ much in the levels)

3

The ESP8266 is an incredibly (electrically) noisy environment.

Because you can't use anything except the internal voltage reference, which is in turn driven from the internal noisy power, you can't get anything even vaguely approaching stable readings.

It is recommended to disable the WiFI completely ("Modem Sleep") when doing ADC readings to reduce noise.

However, the ADC was never intended for this kind of work. Its primary role is for monitoring the battery voltage of your hardware - and as such it really doesn't care that much about noise, since you can average a number of samples for greater accuracy (something you can't really do with audio).

  • So that means I should chain (somehow?), for example, the Arduino to the ESP and 'pass' the data through the esp to send it away? – Sliver2009 Apr 17 at 13:45
  • 1
    Sure, you can do that. You could also attach an external ADC chip with a proper stable voltage reference to the ESP8266. – Majenko Apr 17 at 13:46
  • Ah, that is a very good note. Something like this?: Analog to Digital Converter - MCP3002 – Sliver2009 Apr 17 at 13:48
  • Sure. That's pretty much the same as the ADC in the Arduino. – Majenko Apr 17 at 13:49
  • Thanx for the feedback, very much appreciated! – Sliver2009 Apr 17 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.