SPL Meter using Wemos D1 mini

Hello everyone!

I'm a biomedical engineering student working on a project, where I need to develop a sound pressure meter for an intensive care environment. My goal is to measure noise levels in decibels (dB) using a prototype with a Wemos D1 Mini board and a MAX4466 sensor.

In addition to the doubts about sampling and data processing that I mentioned earlier, I would like to know if my current hardware is suitable for achieving these goals or if there are any limitations I should consider. Are the Wemos D1 Mini and MAX4466 sensor suitable for accurately and reliably sampling sound at 44.1 kHz? Are there any hardware limitations or special considerations I should be aware of when working with these devices?

I have an initial code for sound sampling, but I suspect that I am not achieving the proper sampling time to reach the required 44.1 kHz. Currently, I am using a "delay" in my code, but I know that this is not the best option to achieve accurate sampling frequency.

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/8768649e-d5da-4a65-ab9d-f11ea0b5e85c 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float aDC;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

//float aDC;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 

  // read the input on analog pin 0:
  aDC = analogRead(A0);
  // print out the value you read:
  Serial.println(aDC);

  delay(125);
  
}

I would like to know what modifications I can make in my code to meet the desired sampling time according to the 44.1 kHz requirement. Are there any specific functions or techniques I should consider to achieve precise sampling?

I would greatly appreciate any guidance or advice you can provide. Thank you very much!

Practical testing is needed. Nobody can tell for sure based on Your post.

Set it up and test. Theoretical investigations would likely be too time consuming.

have a look at commercially available sensors that are already used in intensive care environments then compare specs with your sensor.

The sample rate isn't that critical. High frequencies are normally weak (with natural sounds) and with a real SPL meter they are attenuated in the measurement (A-weighting) to account for the fact that our ears are most sensitive at mid-frequencies.

If your measurements are not weighted you can just find the peaks over a short period of time without worrying about about the sample rate.

There are lots of "complications" that make it impractical, if not impossible, to make an SPL meter for regulatory, health & safety, or legal purposes.

That said, I made an SPL Meter with different hardware. There are lots of comments and notes regarding the complications. (It's very simple and I don't do any weighting.)

What I learned from the test was that I had very few samples using the delay (125). I tried using a sample time of 1/44100 and that allowed me to get more samples. My doubt is in the level of accuracy.

Well they are not weighted in Arduino, I figured that I could obtain an Excel with all the data and export it to Matlab, where I can do the signal processing. The main issue is that it prevents me from having real time measurements, which I want.
I guess my main doubt is if I can sample the sound and do the signal processing with any library in Arduino so I can have the real time dB levels.

That's impossible for us to tell anything about. You need to compare Your values with the values from a reference device.

Taking a snapshot of a sound wave won't do it.
Forget about an analogue microphone and the crappy A/D of an ESP.

I think you should use some sort of MEMS microphone with digital I2S output (!= I2C).
And an ESP32, with hardware I2S, and FFT code.
Can't help you with that, but this page could be a start.
Leo..

I've consider using a MEMS mic, but it's very hard to find it in my country and the import laws are a mess, that's why I have chosen this technology.

Do you know how to test if the ADC of the board can sample at 44100KHz?

Maybe. I have seen sample times of 10us on the net.
But not at a constant rate with a single core CPU, and not at 16-bit depth.
I think you're on your own if you follow the path you're on.
Leo..

Hi Wawa, fortunately I was loaned a MEMS microphone. In this case i will be using a STEVAL MKI155V2. On the page you attached i saw that the code uses the library <driver/i2s.h>, do you know if this library works with a esp8266?

ESP8266 does not have I2S I/O, only the ESP32 does.
Never used I2S on an ESP32, but it should work.
Leo..

From what i gather esp8266 is able to work with the I2S protocol because of the GPIO pins


I know that ESP 32 is able to work with I2S, but why you think it wouldt work with esp8266

Seems you're right. I saw examples on the net where I2C is used with the ESP8266.
Leo..

Could you attach the links to the examples?

Not a lot out there for the ESP8266.
Most projects go straight for the 2-core ESP32.
Here you go.
Leo..