Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/celliesprojects/wm8978-esp32
Arduino IDE library for wm8978 dac on ESP32.
https://github.com/celliesprojects/wm8978-esp32
esp32 esp32-arduino m5stack-node wm8978
Last synced: 3 months ago
JSON representation
Arduino IDE library for wm8978 dac on ESP32.
- Host: GitHub
- URL: https://github.com/celliesprojects/wm8978-esp32
- Owner: CelliesProjects
- License: mit
- Created: 2020-04-25T17:03:21.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-13T12:04:43.000Z (about 2 years ago)
- Last Synced: 2023-02-27T01:25:59.664Z (almost 2 years ago)
- Topics: esp32, esp32-arduino, m5stack-node, wm8978
- Language: C++
- Homepage:
- Size: 39.1 KB
- Stars: 18
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# wm8978-esp32
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/7bef2c7f6e0f4103ac73b2fea5449295)](https://www.codacy.com/gh/CelliesProjects/wm8978-esp32/dashboard?utm_source=github.com&utm_medium=referral&utm_content=CelliesProjects/wm8978-esp32&utm_campaign=Badge_Grade)
Arduino IDE library for wm8978 dac on ESP32 mcu. Tested/works with a M5Stack Node.
### Example code:
#### Setup i2c and wm8978 in one call
```c++
#include /* https://github.com/CelliesProjects/wm8978-esp32 */
#include /* https://github.com/schreibfaul1/ESP32-audioI2S *//* M5Stack Node WM8978 I2C pins */
#define I2C_SDA 21
#define I2C_SCL 22/* M5Stack Node I2S pins */
#define I2S_BCK 5
#define I2S_WS 13
#define I2S_DOUT 2
#define I2S_DIN 34
#define I2S_MCLK 0Audio audio;
WM8978 dac;void setup() {
/* Setup wm8978 I2C interface */
if (!dac.begin(I2C_SDA, I2C_SCL)) {
log_e("Error setting up dac. System halted");
while (1) delay(100);
}
dac.setSPKvol(40); /* max 63 */
dac.setHPvol(32, 32);WiFi.begin("xxx", "xxx");
while (!WiFi.isConnected()) {
delay(10);
}/* set i2s pins */
audio.setPinout(I2S_BCK, I2S_WS, I2S_DOUT, I2S_DIN, I2S_MCLK);log_i("Connected. Starting MP3...");
audio.connecttohost("http://icecast.omroep.nl/3fm-bb-mp3");
}void loop() {
audio.loop();
}```
#### Setup i2c and wm8978 separately
```c++
#include
#include /* https://github.com/CelliesProjects/wm8978-esp32 */
#include /* https://github.com/schreibfaul1/ESP32-audioI2S *//* M5Stack Node WM8978 I2C pins */
#define I2C_SDA 21
#define I2C_SCL 22/* M5Stack Node I2S pins */
#define I2S_BCK 5
#define I2S_WS 13
#define I2S_DOUT 2
#define I2S_DIN 34
#define I2S_MCLK 0WM8978 dac;
Audio audio;void setup() {
if (!Wire.begin(I2C_SDA, I2C_SCL, 400000))
log_e("i2c setup error!");if (!dac.begin())
log_e("WM8978 setup error!");dac.setSPKvol(40); /* max 63 */
dac.setHPvol(32, 32);WiFi.begin("xxx", "xxx");
while (!WiFi.isConnected()) {
delay(10);
}/* set i2s pins */
audio.setPinout(I2S_BCK, I2S_WS, I2S_DOUT, I2S_DIN, I2S_MCLK);log_i("Connected. Starting MP3...");
audio.connecttohost("http://icecast.omroep.nl/3fm-bb-mp3");
}void loop() {
audio.loop();
}
```