From b4e58bffc253b2f6f9e169cc3247d92fbebf1b70 Mon Sep 17 00:00:00 2001 From: Stas Sl Date: Wed, 9 Oct 2024 04:16:40 +0300 Subject: [PATCH] update readmin --- README.md | 23 +++++++++++++---------- configs/advanced-example-config.yaml | 4 ++++ configs/minimal-example-config.yaml | 2 ++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 623ef5c..f532160 100644 --- a/README.md +++ b/README.md @@ -261,26 +261,29 @@ binary_sensor: - sound_level_meter.toggle: sound_level_meter1 ``` -## Sending data to sensor.community +## 10 bands spectrum analyzer -See [sensor-community-example-config.yaml](configs/sensor-community-example-config.yaml) +Config: [10-bands-spectrum-analyzer-example-config.yaml](configs/10-bands-spectrum-analyzer-example-config.yaml) +While manually specifying IIR/SOS filters might not be the most user-friendly approach, it offers considerable flexibility. This method allows you to use any filter you need, provided you know how to customize it to meet your requirements. Originally, my intention wasn’t to go beyond standard weighting functions like A/C, however to showcase the capabilities, I created a 10-band spectrum analyzer using ten 6th-order band-pass filters, each targeting a specific frequency band - simply by writing the appropriate config file, without needing to modify the component's source code. -## Filter design (math) +For real-time visualization, I'm using web server number/slider controls to display the levels of each of the 10 bands. While this might not be the intended use of the sliders and web server - since they may not be designed for such frequent updates and it pushes the ESP32 to its limits, but it works 🤪 -Check out [filter-design notebook](math/filter-design.ipynb) to learn how those SOS coefficients were calculated. +With 10 x 6 = 60 SOS filters, the component uses about 60-70% of the CPU, and I assume the web server also consumes some CPU power to send approximately 100 messages per second. So, this is quite a CPU-intensive task. I chose 6th-order filters somewhat arbitrarily; you could experiment with lower-order filters, which might meet your needs while using less CPU power. -## 10 bands spectrum analyzer +https://github.com/user-attachments/assets/91cd7d5c-e636-4d90-b046-68bd33df8db2 -While manually specifying IIR/SOS filters might not be the most user-friendly approach, it offers considerable flexibility. This method lets you use any filter you need, as long as you know how to tailor it to your requirements. Originally, my intention wasn’t to go beyond standard weighting functions like A/C, however to showcase the capabilities, I created a 10-band spectrum analyzer using ten 6th-order filters, each targeting a specific frequency band - simply by writing the appropriate config file, without needing to modify the component's source code. +While this example serves as a stress test, you could also use it to monitor different frequencies over longer time intervals with less frequent updates. -I set the `update_interval: 100ms` for real-time visualization, displaying the data as sliders using the web server’s number/slider component. While this is probably an abuse of the sliders and web server, since they may not be designed to handle such frequent updates, it does push the ESP32 to its limits, yet it still works. The sound meter component, with 10 x 6 = 60 SOS filters, uses about 60-70% of the CPU, and I assume the web server also consumes some CPU power to send approximately 100 messages per second. So, this is quite a CPU-intensive task, and you'll need to be cautious with it. I chose 6th-order filters somewhat arbitrarily; you could experiment with lower-order filters, which might meet your needs while using less CPU power. + -While this setup serves as a stress test, you could also use it to monitor different frequency bands over longer time intervals with less frequent updates. Alternatively, you could filter only specific frequencies - you don’t have to use all 10 bands - as you can design your own IIR filters based on your needs. +## Filter design (math) -Here is the example config: [10-bands-spectrum-analyzer-example-config.yaml](configs/10-bands-spectrum-analyzer-example-config.yaml) +Check out [filter-design notebook](math/filter-design.ipynb) to learn how those SOS coefficients were calculated. - +## Sending data to sensor.community + +See [sensor-community-example-config.yaml](configs/sensor-community-example-config.yaml) ## Performance diff --git a/configs/advanced-example-config.yaml b/configs/advanced-example-config.yaml index 0ddd537..a6891ca 100644 --- a/configs/advanced-example-config.yaml +++ b/configs/advanced-example-config.yaml @@ -2,6 +2,10 @@ --- esphome: name: sound-level-meter + platformio_options: + # I would recommend increasing CPU frequency, + # especially if you have many filters/sensors. + board_build.f_cpu: 240000000 external_components: - source: github://stas-sl/esphome-sound-level-meter diff --git a/configs/minimal-example-config.yaml b/configs/minimal-example-config.yaml index 167b700..156181a 100644 --- a/configs/minimal-example-config.yaml +++ b/configs/minimal-example-config.yaml @@ -1,6 +1,8 @@ --- esphome: name: sound-level-meter + platformio_options: + board_build.f_cpu: 240000000 external_components: - source: github://stas-sl/esphome-sound-level-meter