0
\$\begingroup\$

I have been trying to read the values from this mic https://www.adafruit.com/product/1063 with the this ADC https://www.adafruit.com/product/1083 in python. I am confused about the readings, because the minimum value that I am getting is 0 which is not logical to the reading of the mic where it should be there negative values for it, even though the ADC can read negative values as well. Is there any way to get the correct values from the the mic? Here is my code :

import Adafruit_ADS1x15
import matplotlib.pyplot as plt
import numpy as np

# Initialize communication with the adc
adc = Adafruit_ADS1x15.ADS1015()

# Gain and correspending ranges
#  - 2/3 = +/-6.144V
#  -   1 = +/-4.096V
#  -   2 = +/-2.048V
#  -   4 = +/-1.024V
#  -   8 = +/-0.512V
#  -  16 = +/-0.256V

GAIN = 2/3 
Channel = 0
Data_rate = 3300    # Samples per second
N_samples = 3300    # Samples
Resolution = 12      # Bits
Full_scale_range = 2*6.144 # Volts
Step = Full_scale_range/(2**Resolution)

adc.start_adc(Channel, gain=GAIN, data_rate= 3300)

signal = np.zeros((N_samples,1))

for i in range(N_samples):
  value = adc.get_last_result()
  signal[i] = value*Step

adc.stop_adc()

## Plotting
indecies = np.arange(N_samples)
plt.plot(indecies,signal)
plt.show()
```
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.