Problem: I am testing the Web Radio example provided with the baldram VS1053 library. Sketch compiles without error and runs fine but puts out only static over the attached earphones (I would attach a 10 sec audio sample but forum won't let me). The datastream seems to be fine, the decoder just does not seem to be decoding the data stream.
I've tried rewiring from scratch several times. I've tried some alternate CS/DCS/DREQ ports from other people's tested sketches. Same results... static during streaming (no discernible voice or music sounds, just scratchy, static-like sounds).
IDE: Arduino 1.8.16
Board: NODE32S
Upload Speed: 115,200
Hardware:
- HiLetgo ESP-WROOM-32 ESP32 ESP-32S Development Board 2.4GHz Dual-Mode WiFi + Bluetooth Dual Cores (pinout JPG attached)
- DollaTek VS1053 MP3 Module Development Board
Libraries:
- GitHub - baldram/ESP_VS1053_Library: A library for VS1053 MP3 Codec Breakout adapted for Espressif ESP8266 and ESP32 boards. (for MP3 decoder) v1.1.4
- GitHub - espressif/arduino-esp32: Arduino core for the ESP32 (for ESP32 board) v2.0.0
Pin Connections:
Pin Connections:
VS1053 ESP32(GPIO pin number)
------ -----
XDCS 32
XCS 5
DREQ 4
MOSI 23
GND GND
5V VIN
XRST EN
SCK 18
MISO 19
ESP Board Pinout:
(upload://undCFwtVfM0jlpTmo2KDdJy7v5r.jpeg)
![HiLetgo ESP32 Pinout|375x500]
Sketch: WebRadioDemo (from Arduino IDW ESP32 VS1053 Examples from Custom Libraries)
- Only modifications to Example code are to add my WiFi network credentials, and to
set the streaming URL to a known good value of "radiostreaming.ert.gr:80/ert-kosmos"
Code:
/**
A simple stream handler to play web radio stations using ESP8266
Copyright (C) 2018 Vince Gellár (github.com/vincegellar)
Licensed under GNU GPL v3
Wiring:
--------------------------------
| 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 |
--------------------------------
Dependencies:
-VS1053 library by baldram (https://github.com/baldram/ESP_VS1053_Library)
-ESP8266Wifi/WiFi
To run this example define the platformio.ini as below.
[env:nodemcuv2]
platform = espressif8266
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
Instructions:
-Build the hardware
(please find an additional description and Fritzing's schematic here:
https://github.com/vincegellar/Simple-Radio-Node#wiring)
-Set the station in this file
-Upload the program
IDE Settings (Tools):
-IwIP Variant: v1.4 Higher Bandwidth
-CPU Frequency: 160Hz
*/
#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
VS1053 player(VS1053_CS, VS1053_DCS, VS1053_DREQ);
WiFiClient client;
// WiFi settings example, substitute your own
const char *ssid = "<your ssid goes here>";
const char *password = "<ssid password goes here>";
// http://comet.shoutca.st:8563/1
const char *host = "radiostreaming.ert.gr"; // "comet.shoutca.st";
const char *path = "/ert-kosmos"; // "/1";
int httpPort = 80; // 8563;
// The buffer size 64 seems to be optimal. At 32 and 128 the sound might be brassy.
uint8_t mp3buff[64];
void setup() {
Serial.begin(115200);
// Wait for VS1053 and PAM8403 to power up
// otherwise the system might not start up correctly
delay(3000);
// This can be set in the IDE no need for ext library
// system_update_cpu_freq(160);
Serial.println("\n\nSimple Radio Node WiFi Radio");
SPI.begin();
player.begin();
if (player.getChipVersion() == 4) { // Only perform an update if we really are using a VS1053, not. eg. VS1003
player.loadDefaultVs1053Patches();
}
player.switchToMp3Mode();
player.setVolume(VOLUME);
Serial.print("Connecting to SSID ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.print("connecting to ");
Serial.println(host);
if (!client.connect(host, httpPort)) {
Serial.println("Connection failed");
return;
}
Serial.print("Requesting stream: ");
Serial.println(path);
client.print(String("GET ") + path + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
}
void loop() {
if (!client.connected()) {
Serial.println("Reconnecting...");
if (client.connect(host, httpPort)) {
client.print(String("GET ") + path + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
}
}
if (client.available() > 0) {
// The buffer size 64 seems to be optimal. At 32 and 128 the sound might be brassy.
uint8_t bytesread = client.read(mp3buff, 64);
player.playChunk(mp3buff, bytesread);
}
}
Serial Monitor Output:
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1100
ho 0 tail 12 room 4
load:0x40078000,len:12308
load:0x40080400,len:3076
entry 0x400805ec
Simple Radio Node WiFi Radio
Connecting to SSID xxxxx-xxx
.....WiFi connected
IP address:
192.168.1.161
connecting to radiostreaming.ert.gr
Requesting stream: /ert-kosmos