Skip to content

A Python Script that performs a basic sound pressure level monitor using the Pimoroni Enviro+

License

Notifications You must be signed in to change notification settings

roscoe81/northcliff_spl_monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Northcliff SPL Monitor

A Python Script that performs a basic sound pressure level monitor using the Pimoroni Enviro+

This script explores the potential of using the Pimoroni Enviro+ as a sound pressure level monitor. This project is still in the experimental phase. It should therefore not be used when accurate sound pressure level readings are required and should only be used as a base for future development.

Versions 1.0 and later use streaming to overcome the microphone's startup "plop" that was identified in the excellent review here

The microphone's startup "plop" can be seen here and it plays havoc with the sound readings if the microphone is started for each sampling. A DC offset remained after removing the startup "plop", seen here and removing that DC results in this.

Version 2.8 introduces improved A-Curve weighting. This requires the installation of some additional modules and an adjustment of the alsamixer microphone level to avoid clipping. These are highlighted in the Setup section.

Setup

sudo apt-get update

sudo apt-get upgrade

curl -sSL https://get.pimoroni.com/enviroplus | bash

sudo pip3 install matplotlib

sudo python -m pip uninstall sounddevice

sudo pip3 install sounddevice==0.3.15


For Versions 2.8 and later:

sudo apt-get install python3-scipy

sudo pip3 install git+https://github.com/endolith/waveform_analysis.git@master


For Versions 2.8 and later if wishing to use matplotlib for microphone debugging:

sudo apt-get install python3-gi-cairo


Follow instructions at: https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-test including “Adding Volume Control”

Use the following instead of the documented text for ~/.asoundrc:

  1. #This section makes a reference to your I2S hardware, adjust the card name
  2. #to what is shown in arecord -l after card x: before the name in []
  3. #You may have to adjust channel count also but stick with default first
  4. pcm.dmic_hw {
  5. type hw
  6. card adau7002
  7. channels 2
  8. format S32_LE
  9. }
  10. #This is the software volume control, it links to the hardware above and after
  11. #saving the .asoundrc file you can type alsamixer, press F6 to select
  12. #your I2S mic then F4 to set the recording volume and arrow up and down
  13. #to adjust the volume
  14. #After adjusting the volume - go for 50 percent at first, you can do
  15. #something like
  16. #arecord -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -V mono -v myfile.wav
  17. pcm.dmic_sv {
  18. type softvol
  19. slave.pcm dmic_hw
  20. control {
  21. name "Master Capture Volume"
  22. card adau7002
  23. }
  24. min_dB -3.0
  25. max_dB 30.0
  26. }

For versions prior to Version 2.8:

Use alsamixer to set adau7002 capture level to 50


For Version 2.8 and later:

Use alsamixer to set adau7002 capture level to 10


Operation

For a numerical display of the current approximate overall sound level (Display 0):

Run python3 northcliff_spl_monitor.py or python3 northcliff_spl_monitor.py 0

or for a graphical display of current and past approximate overall sound levels (Display 1):

Run python3 northcliff_spl_monitor.py 1

or for a graphical display of current and past approximate sound levels by frequency band (Display 2):

Run python3 northcliff_spl_monitor.py 2

Version 2.1 adds the ability to cycle through the three displays by briefly touching the Enviro+'s light/proximity sensor

Version 2.2 adds a line in Display 1 that shows the maximum sound level that's been recorded since selecting that display, as well as the time and date when it was recorded. The maximum sound level is reset when selecting another display.

About

A Python Script that performs a basic sound pressure level monitor using the Pimoroni Enviro+

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages