This commit is contained in:
2026-02-12 21:00:02 -08:00
parent 77f8236347
commit 8bdbf227ca
1141 changed files with 1010880 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
# Stream Analog input to A2DP Bluetooth
We can read an analog signal from a microphone and and send it to a Bluetooth A2DP device. To test the functionality I am using a MCP6022 microphone module.
![MCP6022](https://pschatzmann.github.io/Resources/img/mcp6022.jpeg)
![MCP6022](https://pschatzmann.github.io/Resources/img/mcp6022-1.jpeg)
The MCP6022 is a anlog microphone which operates at 3.3 V
We sample the sound signal with the help of the ESP32 I2S ADC input functionality.
### Pins:
| MCP6022 | ESP32
|---------|---------------
| VCC | 3.3
| GND | GND
| OUT | GPIO34
### Dependencies
- https://github.com/pschatzmann/ESP32-A2DP.git

View File

@@ -0,0 +1,47 @@
/**
* @file basic-adc-a2dp.ino
* @author Phil Schatzmann
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-communication/a2dp/basic-adc-a2dp/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "BluetoothA2DPSource.h"
/**
* @brief We use a mcp6022 analog microphone as input and send the data to A2DP
*/
AnalogAudioStream adc;
BluetoothA2DPSource a2dp_source;
// callback used by A2DP to provide the sound data
int32_t get_sound_data(Frame* frames, int32_t frameCount) {
uint8_t *data = (uint8_t*)frames;
int frameSize = 4;
size_t resultBytes = adc.readBytes(data, frameCount*frameSize);
return resultBytes/frameSize;
}
// Arduino Setup
void setup(void) {
Serial.begin(115200);
// start i2s input with default configuration
Serial.println("starting I2S-ADC...");
adc.begin(adc.defaultConfig(RX_MODE));
// start the bluetooth
Serial.println("starting A2DP...");
a2dp_source.set_auto_reconnect(false);
a2dp_source.set_data_callback_in_frames(get_sound_data);
a2dp_source.start("MyMusic");
}
// Arduino loop - repeated processing
void loop() {
delay(1000);
}