Implement INMP441 noise indicator with RGB LED feedback and update project configuration
This commit is contained in:
@@ -1,69 +1,32 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-H21 | ESP32-H4 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | --------- | -------- | -------- | -------- | -------- |
|
||||
# ESP32-S3 INMP441 noise indicator
|
||||
|
||||
# Blink Example
|
||||
This ESP-IDF sample reads audio from an INMP441 I2S microphone and indicates
|
||||
the smoothed sound level (RMS) using the ESP32-S3 board's onboard RGB LED. The
|
||||
microphone's left channel is used because its L/R pin is grounded.
|
||||
|
||||
(See the README.md file in the upper level 'examples' directory for more information about examples.)
|
||||
The LED fades from off to green as the smoothed RMS rises from 0 to 100,000.
|
||||
From 100,000 to 1,000,000 RMS, it smoothly changes from green to red; at or
|
||||
above 1,000,000 it remains red. These thresholds are 10 times higher than the
|
||||
previous settings to make red less likely during ordinary background noise.
|
||||
|
||||
This example demonstrates how to blink a LED by using the GPIO driver or using the [led_strip](https://components.espressif.com/component/espressif/led_strip) library if the LED is addressable e.g. [WS2812](https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf). The `led_strip` library is installed via [component manager](main/idf_component.yml).
|
||||
The thresholds are defined by `GREEN_NOISE_RMS` and `RED_NOISE_RMS` near the
|
||||
top of [main/main.c](main/main.c). Adjust them after checking the RMS values in
|
||||
the serial monitor for your microphone and environment.
|
||||
|
||||
## How to Use Example
|
||||
## Wiring
|
||||
|
||||
Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
|
||||
| Module | Pin | ESP32-S3 |
|
||||
| --- | --- | --- |
|
||||
| INMP441 | SCK / BCLK | GPIO 3 |
|
||||
| INMP441 | WS / LRCLK | GPIO 4 |
|
||||
| INMP441 | SD | GPIO 5 |
|
||||
| INMP441 | L/R | GND |
|
||||
| INMP441 | VDD | 3.3V |
|
||||
| INMP441 | GND | GND |
|
||||
| Onboard RGB LED | Data | GPIO 48 (on supported board variants) |
|
||||
|
||||
### Hardware Required
|
||||
## Build and run
|
||||
|
||||
* A development board with normal LED or addressable LED on-board (e.g., ESP32-S3-DevKitC, ESP32-C6-DevKitC etc.)
|
||||
* A USB cable for Power supply and programming
|
||||
|
||||
See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it.
|
||||
|
||||
### Configure the Project
|
||||
|
||||
Open the project configuration menu (`idf.py menuconfig`).
|
||||
|
||||
In the `Example Configuration` menu:
|
||||
|
||||
* Select the LED type in the `Blink LED type` option.
|
||||
* Use `GPIO` for regular LED
|
||||
* Use `LED strip` for addressable LED
|
||||
* If the LED type is `LED strip`, select the backend peripheral
|
||||
* `RMT` is only available for ESP targets with RMT peripheral supported
|
||||
* `SPI` is available for all ESP targets
|
||||
* Set the GPIO number used for the signal in the `Blink GPIO number` option.
|
||||
* Set the blinking period in the `Blink period in ms` option.
|
||||
|
||||
### Build and Flash
|
||||
|
||||
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
|
||||
|
||||
(To exit the serial monitor, type ``Ctrl-]``.)
|
||||
|
||||
See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
|
||||
|
||||
## Example Output
|
||||
|
||||
As you run the example, you will see the LED blinking, according to the previously defined period. For the addressable LED, you can also change the LED color by setting the `led_strip_set_pixel(led_strip, 0, 16, 16, 16);` (LED Strip, Pixel Number, Red, Green, Blue) with values from 0 to 255 in the [source file](main/blink_example_main.c).
|
||||
|
||||
```text
|
||||
I (315) example: Example configured to blink addressable LED!
|
||||
I (325) example: Turning the LED OFF!
|
||||
I (1325) example: Turning the LED ON!
|
||||
I (2325) example: Turning the LED OFF!
|
||||
I (3325) example: Turning the LED ON!
|
||||
I (4325) example: Turning the LED OFF!
|
||||
I (5325) example: Turning the LED ON!
|
||||
I (6325) example: Turning the LED OFF!
|
||||
I (7325) example: Turning the LED ON!
|
||||
I (8325) example: Turning the LED OFF!
|
||||
```
|
||||
|
||||
Note: The color order could be different according to the LED model.
|
||||
|
||||
The pixel number indicates the pixel position in the LED strip. For a single LED, use 0.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
* If the LED isn't blinking, check the GPIO or the LED type selection in the `Example Configuration` menu.
|
||||
|
||||
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.
|
||||
Open this folder as an ESP-IDF project, select the `esp32s3` target, then build,
|
||||
flash, and open the serial monitor. The firmware uses ESP-IDF's I2S driver and
|
||||
the `espressif/led_strip` component.
|
||||
|
||||
Reference in New Issue
Block a user