I have ordered pins to sodder onto this board, but at the moment, I have it wired up as shown in the attached picture (which may be the issue?)
The problem is, the audio output from the sound-detector board gives me a constant value on the arduino, whether there is sound coming into the microphone or not. The only time the value changes is when I unplug the sound-detector board from the power source, at which point I get values of 0.
The envelope detector output, however, works correctly. In a quiet environment, I get very low voltage values, and when speaking into the microphone, I get varying voltage values depending on how loudly I am speaking into the microphone.
However, for my application, I need raw audio-data and not the audio signal envelope.
Does anyone know what the issue could be, the code is very simply and shown below.
float i;
void setup()
{
Serial.begin(9600);
}
void loop() {
// send the value of analog input 0:
Serial.println(analogRead(A0));
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(2);
}
Moderator edit: </mark> <mark>[code]</mark> <mark>
Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.
When you attach an image it's helpful to embed the image so it's easy for everyone to see it at a glance. Instructions for doing this are found at: http://forum.arduino.cc/index.php?topic=364156.0
However, for my application, I need raw audio-data and not the audio signal envelope.
You also can't delay 2 milliseconds if you're going to read the audio waveform. i.e. CD audio is sampled at 44,100 times per second. The Arduino can't sample quite that fast but with a 2mS delay you're sampling at about 500Hz. But of course, you can't really "print out" the data at fast sample rates either.
DVDdoug:
You also can't delay 2 milliseconds if you're going to read the audio waveform. i.e. CD audio is sampled at 44,100 times per second. The Arduino can't sample quite that fast but with a 2mS delay you're sampling at about 500Hz. But of course, you can't really "print out" the data at fast sample rates either.
I am attempting to sample around 8kHz for my application. Below is some code I used to determine the sampling-rate with the basic analogread function.
// Arrays to save our results in
unsigned long start_times[100];
unsigned long stop_times[100];
float values[100];
// Setup the serial port and pin 2
void setup() {
Serial.begin(9600);
}
void loop() {
unsigned int i;
// capture the values to memory
for(i=0;i<100;i++) {
start_times[i] = micros();
Serial.values[i]=analogRead(A0);
stop_times[i] = micros();
}
// print out the results
Serial.println("\n\n--- Results ---");
for(i=0;i<100;i++) {
Serial.print(values[i]);
Serial.print(" elapse = ");
Serial.print(stop_times[i] - start_times[i]);
Serial.print(" us\n");
}
delay(6000);
}
The time I get, on average, is about 116 uS, resulting in around 8.6 kHz, which should be fine for my application. I realize in my initial code I was doing a
Serial.print(analogread(xyz))
command, which will greatly slow down the sampling rate. However, I plan on simply storing the values read at the analog input in an array, then continuing on from there with some feature extraction. I only need very small samples so the board memory size is not an issue. It was my mistake to post the Serial.print command in the original code.
Even now, I am still getting the same constant values at the analog input, around 1.2-1.5 volts, from the microphone audio output. These values do not change depending on whether it is completely quiet near the microphone, or very loud. I do not think this is a sampling rate issue, but maybe I am misunderstanding something? If I can get past this audio-output from the sound-detector board issue, I can move on with the rest of the project.