Skip to content

Commit

Permalink
Update examples for compatibility with both ESP8266 and ESP32 (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
nopnop2002 authored and baldram committed Oct 30, 2019
1 parent 7ecc51e commit aa80f2b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 26 deletions.
41 changes: 28 additions & 13 deletions examples/Mp3PlayerDemo/Mp3PlayerDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
Licensed under GNU GPL v3
The circuit (example wiring for ESP8266 based board like eg. LoLin NodeMCU V3):
---------------------
| VS1053 | ESP8266 |
---------------------
| SCK | D5 |
| MISO | D6 |
| MOSI | D7 |
| XRST | RST |
| CS | D1 |
| DCS | D0 |
| DREQ | D3 |
| 5V | VU |
| GND | G |
---------------------
--------------------------------
| VS1053 | ESP8266 | ESP32 |
--------------------------------
| SCK | D5 | IO18 |
| MISO | D6 | IO19 |
| MOSI | D7 | IO23 |
| XRST | RST | EN |
| CS | D1 | IO5 |
| DCS | D0 | IO16 |
| DREQ | D3 | IO4 |
| 5V | 5V | 5V |
| GND | GND | GND |
--------------------------------
Note: It's just an example, you may use a different pins definition.
For ESP32 example, please follow the link:
Expand All @@ -31,10 +31,17 @@
platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps =
ESP_VS1053_Library
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
ESP_VS1053_Library
*/

// This ESP_VS1053_Library
Expand All @@ -45,9 +52,17 @@
#include "SampleMp3.h"

// Wiring of VS1053 board (SPI connected in a standard way)
#ifdef ARDUINO_ARCH_ESP8266
#define VS1053_CS D1
#define VS1053_DCS D0
#define VS1053_DREQ D3
#endif

#ifdef ARDUINO_ARCH_ESP32
#define VS1053_CS 5
#define VS1053_DCS 16
#define VS1053_DREQ 4
#endif

#define VOLUME 100 // volume level 0-100

Expand Down
40 changes: 27 additions & 13 deletions examples/WebRadioDemo/WebRadioDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
Wiring:
--------------------------------
| VS1053 | ESP8266 | Other |
| VS1053 | ESP8266 | ESP32 |
--------------------------------
| SCK | D5 | - |
| MISO | D6 | - |
| MOSI | D7 | - |
| XRST | - | - |
| CS | D1 | - |
| DCS | D0 | - |
| DREQ | D3 | - |
| 5V | - | VCC |
| GND | - | GND |
| SCK | D5 | IO18 |
| MISO | D6 | IO19 |
| MOSI | D7 | IO23 |
| XRST | RST | EN |
| CS | D1 | IO5 |
| DCS | D0 | IO16 |
| DREQ | D3 | IO4 |
| 5V | 5V | 5V |
| GND | GND | GND |
--------------------------------
Dependencies:
-VS1053 library by baldram (https://github.com/baldram/ESP_VS1053_Library)
-ESP8266Wifi
-ESP8266Wifi/WiFi
To run this example define the platformio.ini as below.
Expand All @@ -30,7 +30,13 @@
board = nodemcuv2
framework = arduino
build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
lib_deps =
ESP_VS1053_Library
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
ESP_VS1053_Library
Expand All @@ -47,11 +53,19 @@
*/

#include <VS1053.h>
#ifdef ARDUINO_ARCH_ESP8266
#include <ESP8266WiFi.h>

#define VS1053_CS D1
#define VS1053_DCS D0
#define VS1053_DREQ D3
#endif

#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#define VS1053_CS 5
#define VS1053_DCS 16
#define VS1053_DREQ 4
#endif

// Default volume
#define VOLUME 80
Expand All @@ -60,7 +74,7 @@ VS1053 player(VS1053_CS, VS1053_DCS, VS1053_DREQ);
WiFiClient client;

// WiFi settings example, substitute your own
char* ssid = "TP-Link";
const char* ssid = "TP-Link";
const char* password = "xxxxxxxx";

// http://comet.shoutca.st:8563/1
Expand Down

0 comments on commit aa80f2b

Please sign in to comment.