Skip to content

Commit 375873d

Browse files
Update examples
1 parent 4a8a379 commit 375873d

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,29 @@ Use [the latest Arduino ESP32 core version](https://github.com/espressif/arduino
1818
## Example code
1919

2020
```c++
21+
#include <Arduino.h>
2122
#include <VS1053.h> /* https://github.com/baldram/ESP_VS1053_Library */
2223
#include <ESP32_VS1053_Stream.h>
2324

24-
#define VS1053_CS 5
25-
#define VS1053_DCS 21
26-
#define VS1053_DREQ 22
25+
#define SPI_CLK_PIN 18
26+
#define SPI_MISO_PIN 19
27+
#define SPI_MOSI_PIN 23
28+
29+
#define VS1053_CS 5
30+
#define VS1053_DCS 21
31+
#define VS1053_DREQ 22
2732

2833
ESP32_VS1053_Stream stream;
2934

3035
const char* SSID = "xxx";
3136
const char* PSK = "xxx";
3237

3338
void setup() {
39+
#if defined(CONFIG_IDF_TARGET_ESP32S2) && ARDUHAL_LOG_LEVEL != ARDUHAL_LOG_LEVEL_NONE
40+
delay(3000);
41+
Serial.setDebugOutput(true);
42+
#endif
43+
3444
Serial.begin(115200);
3545

3646
WiFi.begin(SSID, PSK);
@@ -41,13 +51,18 @@ void setup() {
4151
delay(10);
4252
Serial.println("wifi connected - starting decoder");
4353

44-
SPI.begin(); /* start SPI before starting decoder */
54+
SPI.setHwCs(true);
55+
SPI.begin(SPI_CLK_PIN, SPI_MISO_PIN, SPI_MOSI_PIN); /* start SPI before starting decoder */
4556

46-
stream.startDecoder(VS1053_CS, VS1053_DCS, VS1053_DREQ);
57+
if (!stream.startDecoder(VS1053_CS, VS1053_DCS, VS1053_DREQ) || !stream.isChipConnected())
58+
{
59+
Serial.println("Decoder not running");
60+
while (1) delay(100);
61+
};
4762

4863
Serial.println("decoder running - starting stream");
4964

50-
stream.connecttohost("http://icecast.omroep.nl/radio6-bb-mp3");
65+
stream.connecttohost("http://espace.tekno1.fr/tekno1.m3u");
5166

5267
Serial.print("codec: ");
5368
Serial.println(stream.currentCodec());

examples/simple/simple.ino

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1+
#include <Arduino.h>
12
#include <VS1053.h> /* https://github.com/baldram/ESP_VS1053_Library */
23
#include <ESP32_VS1053_Stream.h>
34

4-
#define VS1053_CS 5
5-
#define VS1053_DCS 21
6-
#define VS1053_DREQ 22
5+
#define SPI_CLK_PIN 18
6+
#define SPI_MISO_PIN 19
7+
#define SPI_MOSI_PIN 23
8+
9+
#define VS1053_CS 5
10+
#define VS1053_DCS 21
11+
#define VS1053_DREQ 22
712

813
ESP32_VS1053_Stream stream;
914

1015
const char* SSID = "xxx";
1116
const char* PSK = "xxx";
1217

1318
void setup() {
19+
#if defined(CONFIG_IDF_TARGET_ESP32S2) && ARDUHAL_LOG_LEVEL != ARDUHAL_LOG_LEVEL_NONE
20+
delay(3000);
1421
Serial.setDebugOutput(true);
22+
#endif
23+
1524
Serial.begin(115200);
1625

1726
WiFi.begin(SSID, PSK);
@@ -22,16 +31,26 @@ void setup() {
2231
delay(10);
2332
Serial.println("wifi connected - starting decoder");
2433

25-
SPI.begin(); /* start SPI before starting decoder */
34+
SPI.setHwCs(true);
35+
SPI.begin(SPI_CLK_PIN, SPI_MISO_PIN, SPI_MOSI_PIN); /* start SPI before starting decoder */
2636

27-
stream.startDecoder(VS1053_CS, VS1053_DCS, VS1053_DREQ);
37+
if (!stream.startDecoder(VS1053_CS, VS1053_DCS, VS1053_DREQ) || !stream.isChipConnected())
38+
{
39+
Serial.println("Decoder not running");
40+
while (1) delay(100);
41+
};
2842

2943
Serial.println("decoder running - starting stream");
3044

31-
stream.connecttohost("http://icecast.omroep.nl/radio6-bb-mp3");
45+
stream.connecttohost("http://espace.tekno1.fr/tekno1.m3u");
3246

3347
Serial.print("codec: ");
3448
Serial.println(stream.currentCodec());
49+
50+
Serial.print("bitrate: ");
51+
Serial.print(stream.bitrate());
52+
Serial.println("kbps");
53+
3554
}
3655

3756
void loop() {

0 commit comments

Comments
 (0)