Arduino Peak Detector and Uni-Directional Microphone

I have got this circuit with the help of stack exchange that uses a peak detector to let me sample extremely fast without the Arduino needing to sample quickly at all (that is at least what I understood. Sorry I have been using the arduino for a while but havn't done large projects like this without much of a guide before)

This is the schematic I was given. I put this onto a breadboard with an arduino and a

https://www.ebay.co.uk/itm/Negative-Voltage-conversion-Dual-Power-5V-12V-to-12V-100ma-For-Amplifier/223330100802?_trkparms=aid%3D111001%26algo%3DREC.SEED%26ao%3D1%26asc%3D20160908105057%26meid%3D31f7eadb0a2f47b7b9b02746a3790849%26pid%3D100675%26rk%3D1%26rkt%3D15%26sd%3D223330100802%26itm%3D223330100802&_trksid=p2481888.c100675.m4236&_trkparms=pageci%3A226ce78b-68e6-11e9-bdd7-74dbd180cdd4|parentrq%3A5eb8b35f16a0a68d5fa15266fffba178|iid%3A1.

Here is a picture of the breadboard. (also with 100nf capacitors on the + and - of the opamp)


I read the output with analog read and am Just getting 0. Any help would be appreciated,
Many Thanks,
Thomas

It looks like you are shorting out the power supply. Never connect Vout+ and Vout- together!

Also, you aren't powering the op-amp. What op-amp are you using?

Pieter

I am using a Lm358, and I didn't think that was right but the person on stack exchange seemed very knowledgeable and helpful so I used his schematic. My project is to have many unidirectional microphones in a semi circle (9) to detect the direction of the loudest noise. Any ideas are appreciated, thanks.

EDIT:
His schematic is correct I am just reading it wrong

The schematic tells you to connect Vout- to the V-, gnd, Vss, or Vee of the op-amp, and Vout+ to V+, Vdd, or Vcc of the op-amp and the resistor to the microphone. The schematic seems correct, as far as I can tell.

Okay I understand, I am just reading it wrong. I will connected out- directly too pin 4 and out+ directly too pin 8. I am still reading 0. Do you think I have created the circuit on the breadboard wrong? Thanks

It's hard to tell what's going on on your breadboard.
Could you upload a new picture that clearly shows all connections?
What's the purpose of the capacitors on the inputs? Are you reading the correct pin in your code?

Maybe you blew up te regulator. Try measuring its output voltage with a DMM, or use an LED+ series resistor to see if it still provides power.

Yeah sorry I thought it would be too hard to follow the breadboard anyway so I didn't upload a great picture. Here is a better one:


And the stack exchange guy said I should put 'decoupling capacitors (100nf)' on the power pins. I only just realised they are not the power pins. Shall I remove them entirly or just move them to v- and v+
Many Thanks,
Thomas

(as a side note thank you very much for reading through the breadboard from a picture, I would never be able to do that)

You forgot to connect the ground, and you didn't connect the mic to Vout+ through R4. The wire to your Arduino is connected to ground instead of the output of the circuit (through the 1kΩ resistor).

I don't think the connection between Vout+ and R4 is correct. I can't really tell if the other connections around the microphone are correct.

I redid the circuit and now am getting a load of random values. Here is the new circuit:

Here is a video of it:

Okay okay we have progress. When I put a delay I can see the peak detector working I think! It rises to 1023 then slowly drops!!!

EDIT:
Okay it doesn't work. It rises to 1023 every few seconds and drops regardless of noise. I actually removed the microphone and it did the same.

Can you post the schematic for what you have now? Schematic, not wiring diagram if at all possible.

Yes, it is the original schematic unless I have made a mistake:

Does the polarity of the electret microphone matter?

EDIT:
I read through the schematic one more time and re-positioned some components, and now I am pretty sure that the schematic is what I have on the breadboard. The analog read now starts at 0 slowly rises to around 1023 then drops again. If these results point to the schematic being wrong, Ill use a bigger breadboard and remake the whole thing. Thanks
Like This:

1023
1023
1023
1023
1023
1023
1023
1004
949
855
752
645
537
437
334
232
100
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
21
78
164
285
414
541
663
790
913
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
972
910
805
691
581
475
373
270
144
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
38
98
198
344
476
625
763
945
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023

The turn-on "glitch" is probably normal.

And the amplifier only has a gain of 10 so you might get small readings unless the sound is very loud.

If you appear to be reading "something" with loud sounds, try increasing R3 to 100K.

You can also switch to the optional 1.1V ADC reference to compensate for low signal levels.

Are all of the grounds tied together?

Are the + & - terminals on the electret mic clearly marked and correctly connected? (The audio signal is AC, so polarity doesn't matter but the power to an electret mic does matter.)

Do you have a multimeter? If not, it's probably time to get one...

Make sure you have the positive & negative power supplies to the op-amp.

...You can buy a [u]sound sensor board[/u] with an envelope follower (peak detector) output.

My project is to have many unidirectional microphones in a semi circle (9) to detect the direction of the loudest noise. Any ideas are appreciated, thanks.

You'll need a significant (percentage-wise) distance-difference to get a significant difference in loudness. And indoors, it may not work at all because reflections tend to even-out loudness throughout the room.

With no signal the output of the op-amp (before the diode) should be resting at about 0.6V (because of the diode in the feedback loop). The other side of the diode (and the Arduino's analog input) should be reading about zero. We know it's not positive because the Arduino is reading zero, but it might be negative.

The circuit is simply wrong, I a tempted to say go find a proper one, but basically the inverting and non-inverting inputs are swapped over, so the opamp is a comparator with a vast amount of hysteresis. There is far too little
gain possible with those resistors too.

Where did you get this bad circuit from?

Firstly, I have a multi-meter and this device will be in a room with acoustic foam in it. Secondly, I got this from a post over at Uni-Directional Electret Microphones and an Arduino - Electrical Engineering Stack Exchange

The circuit is simply wrong, I a tempted to say go find a proper one, but basically the inverting and non-inverting inputs are swapped over, so the opamp is a comparator with a vast amount of hysteresis.

Good catch!!! ...I did not notice that. :blush:

Swap the + &- inputs to the op-amp (so you get negative feedback to control the gain) and increase the feedback resistor R3 for more gain, and it should work.

Or, SparkFun publishes the [u]schematic[/u] for their board if you want to see a another version/option. (You can leave-out the buffer since the Arduino is has a high impedance input, and you can leave-out the Schmitt trigger since you only want an analog output.

I've made amplifiers and I've made peak detectors but I've never made an all-in-one circuit with an electret mic. ..If it was me, I'd buy the boards. The cost is going to be about the same and you don't have the hassle of building, testing, and debugging and you get a nicely-assembled printed circuit board without having to design your own board. (Although, I would prefer a board with a gain-adjustment pot.)

Thank you very much everyone, and to DVDdoug, I swapped the two inputs and am getting the same results... I think I have probably ruined the circuit somewhere when swapping around connections. The reason I want my own board is so I can have all 9 of these around the outside on one PCB rather then a lot of them on top of each other, which I feel in the long run will make it cheaper. Since I am remaking the whole circuit, should I go with the sparkfun schematic or the one I have listed below? Many Thanks,
Thomas