I am currently busy with a project and urgently need help in the right direction. I am a total newbie so please bear with me. I am trying to develop a device to triangulate a sound source. The final project will have multiple sensors the same as the the one I am busy with. The final triangulation will be done by the combined data from 2 or more sensors. The current sensor will only provide a compass bearing to the detected sound.

I have three microphones in an equal triangle formation, each spaced 1 meter apart. I numbered them 1 to 3 with number 1 at the point which will point north 0/360 degrees, number 2 at 120 degrees and three at 240 degrees. they are connected to Analog input pins 1,2 and 3 on an Arduino Mega 2560. Incorporated in this design is also a DS18B20 Thermometer to calculate the correct speed of sound at any given time. Please see the attached Fritzing image for the current setup.

I have used FASTADC as to do faster analog reads (currently reading at 18 microseconds). When the threshold of a microphone is exceeded, I check the remaining mics for a 2nd detection from where the bearing can be calculated.

I will probably add sound analyzing at a later stage, maybe on another microprocessor.

As I said, I am a newbie, please have a look at the code and give me comments on how to improve on the coding and design. When connecting an Xbee I realized that the analog Read values are pushed up quite a lot, normal quiet environment reads will be in the range of 500 to 600, with the Xbee they are pushed to 900 or more. Is it an issue with power distribution or something affecting the RX/TX ports on the Arduino?

// Timing Varsdouble detectTime; // Var for detection time outdouble time1; // Var to hold 1st detection time, time when 1st mic exceeded the set thresholddouble time2; // Var to hold 2nd detection time, time when 2nd mic exceeded the set threshold

sensors.requestTemperatures(); // get current TempSerial.print("Current Temperature: "); Serial.println(sensors.getTempCByIndex(0)); // print current tempSerial.println("Waiting...................."); // show we are ready for detection

When connecting an Xbee I realized that the analog Read values are pushed up quite a lot, normal quiet environment reads will be in the range of 500 to 600, with the Xbee they are pushed to 900 or more. Is it an issue with power distribution or something affecting the RX/TX ports on the Arduino?

Probably RF noise intruding on your analog circuitry. To test this, temporarily replace the microphones with resistors (or switch them off, if they are switchable) then check your values with and without Xbee.

Attention to your analog ground path could help here, as might using sheilded cable to connect the mics if you aren't already. Also, capacitive low-pass filtering to get rid of high frequency hash may help.

I suggest you take the Vxx and Gnd for the Xbee from different pins (the ones at either the end of the 36-pin conector would be suitable) rather than running them to the breadboard where your analog circuitry is.

Depending on the microphones, you might need some sort of preamp between them and the analog inputs.

With no information on your circuitry there's no way to judge where the analog noise might be coming from.

(check the attachment to the original post, for the wiring)

Well that (apparently) tells me only that you are using some sort of microphone module, not a microphone directly - is there information on that unit?

Secondly you seem to be running logic signals well away from the ground connection - all logic signals (being super-fast) ought ideally to run close to a ground line to keep stray inductance under control and to provide a return-path for the transients (otherwise you force that return path to be any near-by wire) - bundle the power supply and signal wires to the Xbee together for instance. And keep them fairly short.

[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

I am using the sparkfun electret breakout board for sound collection which has a 100x opamp, and have not paid any attention to shielding, that might sort the issue, the xbee is a 900mhz Pro uFL. I will also power the xbee from another rail to see if it improves.

Just to post a follow up, you might be interested in checking http://ruralhacker.blogspot.pt/p/micloc.html out.I planned to release the schematics and code earlier, but I had no time on my hands.Maybe it can still be of some help for your project.