利用重力声计和带raspberry pi的ADC模块获得DBa值

2024-04-27 00:24:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要帮助,以获得实际值从重力声计与覆盆子皮。你知道吗

我有一个python程序来获取这些细节

import sys
sys.path.append('../')
import time
from DFRobot_ADS1115 import ADS1115
ADS1115_REG_CONFIG_PGA_6_144V        = 0x00 # 6.144V range = Gain 2/3
ADS1115_REG_CONFIG_PGA_4_096V        = 0x02 # 4.096V range = Gain 1
ADS1115_REG_CONFIG_PGA_2_048V        = 0x04 # 2.048V range = Gain 2 (default)
ADS1115_REG_CONFIG_PGA_1_024V        = 0x06 # 1.024V range = Gain 4
ADS1115_REG_CONFIG_PGA_0_512V        = 0x08 # 0.512V range = Gain 8
ADS1115_REG_CONFIG_PGA_0_256V        = 0x0A # 0.256V range = Gain 16
ads1115 = ADS1115()

while True :
    #Set the IIC address
    ads1115.setAddr_ADS1115(0x48)
    #Sets the gain and input voltage range.
    ads1115.setGain(ADS1115_REG_CONFIG_PGA_6_144V)
    #Get the Digital Value of Analog of selected channel
    adc0 = ads1115.readVoltage(0)
    time.sleep(0.2)
    adc1 = ads1115.readVoltage(1)
    time.sleep(0.2)
    adc2 = ads1115.readVoltage(2)
    time.sleep(0.2)
    adc3 = ads1115.readVoltage(3)
    print "A0:%dmV A1:%dmV A2:%dmV A3:%dmV"%(adc0['r'],adc1['r'],adc2['r'],adc3['r'])

它显示如下值

A0:0mv A1:1098mV A2:3286mV A3:498mV

但我不知道如何以分贝为单位得到实际的声音值。你知道吗


Tags: oftheimportconfigtimesysrangesleep
1条回答
网友
1楼 · 发布于 2024-04-27 00:24:32

您可以在此处找到文档: https://wiki.dfrobot.com/Gravity__Analog_Sound_Level_Meter_SKU_SEN0232

回答你的问题:

For this product,the decibel value is linear with the output voltage.When the output voltage is 0.6V, the decibel value should be 30dBA. When the output voltage is 2.6V, the decibel value should be 130dBA. The calibration is done before leaving the factory, so you don't need to calibrate it. So we can get this relation: DecibelValue(dBA) = Output Voltage(V) × 50

因此,您需要检查连接到哪个连接器(A0,A1,A2或A3)您的声级计。取这个值(看起来是mV),把它转换成V,再乘以50。 或者把你的值除以20。你知道吗

相关问题 更多 >