1

I am trying to read mic output via SPI. I am using an ADC0831 8 bit convertor. I tested the ADC and the code by using a voltage regulator. The value coming from the ADC's DO pin is correct.

I want to read the voltage of the mic and store it as raw sound data. However the value I read from RPi SPI is always betweeen 248-250 (8 bit value with respect to VREF). I cannot read any other voltage which is relevant with the sound.

Any help is appreciated

1

Don't try to get a sound wave by reading an ADC with the RPi. Get a real sound card. The RPi is not a hard real-time system, which is what you will need to ensure that you are sampling the microphone frequently enough. See this thread for a more detailed discussion: https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=114455.

For the ADC reading problem, check if you are reading the right channel. Note that channel numbering for ADC's often starts at 0, not 1. If you have a potentiometer, you could hook it up to the input and twiddle it to see if you can actually read a signal, as it is easier to get a good read off of a pot than a microphone.

  • Im trying to make a lightweight system.Sound card is one option but we wish to keep energy consumption as minimum as possible.Sound card via usb fetces 100mA current. That is more than we can compansate.I can read the output voltage of a regulator precisely with ADC.I verify the results of rpi with multimeter and they are the same. I think the problem is related with sampling rate. There are two concerns here, first is the sampling rate of ADC which seems enogh for audio according to the documents of the device. Second is the frequency of reading ADC via raspberry. Or 16 bit ADC is needed... – muhsin Apr 8 '16 at 7:46
  • @muhsin You will NOT be able to get anywhere close to the device specs read rate. Inherent code latencies will limit you to an absolute maximum of 1/3-1/4 of the advertised rate. With its close cousin the MCP3304 (rated for 100ksps) I pushed it to 30ksps by bitbanging the pins to evade the latency of the hardware SPI driver. You might be able to get it to 50ksps by bitbanging in C, but don't hope for anything over that. Read the thread: it explains it all. – dpdt Apr 8 '16 at 19:20
  • You are right. It is not possible to reach the device standarts. For the moment I am able to record the audio from SPI of raspberry by using ADC0831. Max.frequency that i can reach is 10Khz. The quality is not so good but it is better than nothing. 12 bit ADC produce similar results. Thanks for all suggestions... – muhsin Apr 20 '16 at 13:48
0

I agree with @dpdt answer. I also playing with a sound in the Raspberry Pi but I'm using a USB Sound Card which you can get by only $1. If I record it using Audacity the result is a *.wav or *.mp3 . I don't know about your purpose but I think using a USB Sound Card is a solution.

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.