这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 活动中心 » 板卡试用 » 【换取手持数字示波器】esp32快速搭建简易蓝牙音箱

共2条 1/1 1 跳转至

【换取手持数字示波器】esp32快速搭建简易蓝牙音箱

助工
2025-03-15 22:48:42     打赏

周末没事,找出来之前购买的max98357音频功放和小喇叭,主控还是熟悉的DFRobot Firebeetle ESP32E。

主控ESP32

image.png

工作电压:3.3V输入电压:3.3V~5.5V支持USB充电处理器:Tensilica LX6双核处理器(一核处理高速连接;一核独立应用开发)主频:240MHzSRAM:520KBFlash:32MbitWi-Fi标准:FCC/CE/TELEC/KCCWi-Fi协议:802.11 b/g/n/d/e/i/k/r (802.11n,速度高达150 Mbps),A-MPDU和A-MSDU聚合,支持0.4us防护间隔频率范围:2.4~2.5 GHz蓝牙协议:符合蓝牙V4.2 BR/EDR和BLE标准蓝牙音频:CVSD和SBC音频频率范围:2.4~2.5GHz片上时钟:40MHz晶振、32.768KHz晶振数字I/O:x18模拟输入:x11SPI x1I2C x1I2S x1RGB_LED:WS2812

功放模块MAX98357是一款高品质、低功耗的立体声音频放大器芯片,由Maxim Integrated生产(现在的ADI公司已经收购了Maxim)。该芯片具有内置的数字音频接口(I2S),可与各种数字音频设备配合使用。MAX98357能够提供高达3.2W的输出功率,并具有优秀的失真和噪声性能。

image.png

MAX98357的特点输出功率:

4欧时为3.2W,THD为10%
8欧时为 1.8W,THD为10%I2S采样率:8KHz-96kHZD类放大器 增益可选:3dB/6dB/9dB/12d B/15dl无需主控时钟 ( MCLK)即插即用:只需单电源供电,即可自动配置35种不
同的时钟和128种数字音频格式。适用于Raspberry Pi, Arduino以及ESP32等具
有I2S音频输出的微控制器或开发板系统

系统框图:

image.png

连线说明:

I2S Module VCC to ESP32-E 3V3
I2S Module GND to ESP32-E GND
I2S Module LRC to ESP32-E 26/D3
I2S Module BCLK to ESP32-E 25/D2
I2S Module DIN to ESP32-E 14/D6
I2S Module SPK+ to Speaker power +
I2S Module SPK- to Speaker power -


image.png

image.png

代码:

#include <DFRobot_MAX98357A.h>

DFRobot_MAX98357A amplifier;   // instantiate an object to control the amplifier

void setup(void)
{
  Serial.begin(115200);

  /**
   * @brief Init function
   * @param btName - The created Bluetooth device name
   * @param bclk - I2S communication pin number, serial clock (SCK), aka bit clock (BCK)
   * @param lrclk - I2S communication pin number, word select (WS), i.e. command (channel) select, used to switch between left and right channel data
   * @param din - I2S communication pin number, serial data signal (SD), used to transmit audio data in two's complement format
   * @return true on success, false on error
   */
  while( !amplifier.begin(/*btName=*/"bluetoothAmplifier", /*bclk=*/GPIO_NUM_25, /*lrclk=*/GPIO_NUM_26, /*din=*/GPIO_NUM_14) ){
    Serial.println("Initialize failed !");
    delay(3000);
  }
  Serial.println("Initialize succeed!");

}

void loop(void)
{
  String Title, Artist, Album;
  /**
   * @brief Get "metadata" through AVRC command
   * @param type - The type of metadata to be obtained, and the parameters currently supported:
   * @n     ESP_AVRC_MD_ATTR_TITLE   ESP_AVRC_MD_ATTR_ARTIST   ESP_AVRC_MD_ATTR_ALBUM
   * @return The corresponding type of "metadata"
   * @note Return "NULL" if timeout occurs when requesting metadata
   */
  Title = amplifier.getMetadata(ESP_AVRC_MD_ATTR_TITLE);
  if(0 != Title.length()){
    Serial.print("Music title: ");
    Serial.println(Title);
  }
  Artist = amplifier.getMetadata(ESP_AVRC_MD_ATTR_ARTIST);
  if(0 != Artist.length()){
    Serial.print("Music artist: ");
    Serial.println(Artist);
  }
  Album = amplifier.getMetadata(ESP_AVRC_MD_ATTR_ALBUM);
  if(0 != Album.length()){
    Serial.print("Music album: ");
    Serial.println(Album);
  }
  delay(3000);
}

编译,烧录代码。


打开蓝牙,找到名称为bluetoothamplifer的广播名称,点击配对连接。

image.png


串口打印:

image.png


歌曲可以正常播放。播放视频见附件。

485066150.zip

现在的各种资料很多,闲下来可以做一些有意思的小制作还是很有趣的。



院士
2025-03-16 11:49:00     打赏
2楼

怎么感觉这个小模块所释放的能量还不小。


共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]