what i noticed is that when i give a 3.3v to the mic i get a reasonable output put the noise is still present but when i give a 5v then i get the same output that was posted by MarkT
I searched online and i found "power supply noise rejection"
Power supply noise rejection – Technical Brief. ... PSNR is a measurement of how well a circuit rejects noise from various frequencies which get coupled into the power supply. In high speed analog and digital circuitry, power supply pins are vulnerable to random noise.
so i tried giving vcc and ground of the mic from a nodemcu(3.3v) i have with me but still getting the same output.
from the zip file
TEST 4 is when i give vcc to 5v
TEST 5 and 6 is with 3.3v
Its a plot of sample value against sample number taken direct from the wav file - read a byte, plot it, just
a simple bit of python using matplotlib.
You have those noise spikes in your system, you have to troubleshoot this... The more information you
give us the more likely we can help. Without an oscilloscope problems like this are trickier to troubleshoot.
Here's the Python code if its useful to anyone...
Needs numpy and matplotlib.
import numpy as np
import matplotlib.pyplot as plt
content = None
with open ("TEST4.WAV", "rb") as f:
content = f.read()
samplen = np.zeros ([len(content)], int)
samplev = np.zeros ([len(content)], int)
for i in range (len(content)):
samplen[i] = i
samplev[i] = content[i]
#START = 1000
#LIMIT = 15000
START = 13700
LIMIT = 14200
# plot and show that the difference of output complex amplitudes for high and low has constant amplitude
fig = plt.figure()
ax = fig.add_subplot (1,1,1)
ax.plot (samplen[START:LIMIT], samplev[START:LIMIT], 'r')
plt.show()
#include <SD.h>
#include <SPI.h>
#include <TMRpcm.h>
#define SD_ChipSelectPin 4 //using digital pin 4 on arduino nano 328, can use other pins
TMRpcm audio; // create an object for use in this sketch
void setup() {
Serial.begin(115200);
if (!SD.begin(SD_ChipSelectPin)) {
return;
}else{
Serial.println("SD OK");
}
// The audio library needs to know which CS pin to use for recording
audio.CSPin = SD_ChipSelectPin;
}
void loop() {
if(Serial.available()){ //Send commands over serial to play
switch(Serial.read()){
case 'r': audio.startRecording("test.wav",16000,A0); break; //Record at 16khz sample rate on pin A0
case 'R': audio.startRecording("test.wav",16000,A0,1); break; //Record, but with passthrough to speaker.
case 't': audio.startRecording("test.wav",16000,A0,2); break; //Do not record. Output direct to speaker
//Note: If samples are dropped before writing, it
// will not be heard in passthrough mode
case 's': audio.stopRecording("test.wav"); break; //Stop recording
case 'p': audio.play("test.wav"); break; //Play the recording
case '=': audio.volume(1); break; //Increase volume by 1. Does not affect recording
case '-': audio.volume(0); break; //Decrease volume by 1. Does not affect recording
case 'S': audio.stopPlayback(); break; //Stop all playback
}
}
}
The things I want to check is do you have level logic shifters on the SD card. A stupid Fritzing diagram is not going to tell me that, a schematic will because you will / should have labeled the SD card with the actual type it is.
Have you tried recording at a lower sample rate?
It is likely the dropouts you are seeing is a result of sporadic writing to the SD card.