Comments (18)
Hmm not really sure. All the stream urls above work ok for me.
I think you are trying the example with only changed pins?
from esp32_vs1053_stream.
I try my best give more detailed feedback. Here is the actual code, maybe something missing.
I have the newest esp32 firmware in arduino ide and this is the actual code what still giving this in serial monitor:
17:59:39.603 -> Simple vs1053 Streaming example.
17:59:41.967 -> wifi connected - starting decoder
17:59:45.185 -> decoder running - starting stream
17:59:45.279 -> codec: UNKNOWN
#include <VS1053.h> /* https://github.com/baldram/ESP_VS1053_Library */
#include <ESP32_VS1053_Stream.h>
#define VS1053_CS 5
#define VS1053_DCS 16
#define VS1053_DREQ 4
ESP32_VS1053_Stream stream;
const char* SSID = "xxxx";
const char* PSK = "xxxx";
void setup() {
Serial.begin(115200);
WiFi.begin(SSID, PSK);
Serial.println("\n\nSimple vs1053 Streaming example.");
while (!WiFi.isConnected())
delay(10);
Serial.println("wifi connected - starting decoder");
SPI.begin(); /* start SPI before starting decoder */
stream.startDecoder(VS1053_CS, VS1053_DCS, VS1053_DREQ);
Serial.println("decoder running - starting stream");
stream.connecttohost("http://mp3.ffh.de/ffhchannels/hqeurodance.mp3");
Serial.print("codec: ");
Serial.println(stream.currentCodec());
}
void loop() {
stream.loop();
}
void audio_showstation(const char* info) {
Serial.printf("showstation: %s\n", info);
}
void audio_showstreamtitle(const char* info) {
Serial.printf("streamtitle: %s\n", info);
}
void audio_eof_stream(const char* info) {
Serial.printf("eof: %s\n", info);
}
And here is the original example, whats currently working well by me, i have used this example pins:
/*
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 |
--------------------------------
*/
#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 = "xxxx";
const char *password = "xxxx";
// http://comet.shoutca.st:8563/1
const char *host = "live.topfm.hu";
const char *path = "/radio.mp3";
int httpPort = 8000;
// 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();
}
Serial.println("Chip version:");
Serial.println(player.getChipVersion());
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);
}
}
from esp32_vs1053_stream.
I just compiled with esp32 core version 2.0.3 and then I can reproduce your problem.
With 2.0.2 it works for me. Could you please try to compile and flash with 2.0.2?
from esp32_vs1053_stream.
You have right, thats was the problem, now working well:) You need notice this in description to prevent this issue or check what is the problem with the new core.
Thank you for investigation, have a nice day.
from esp32_vs1053_stream.
Just a question - this is not issue, because im not pro developer, how can i display on serial monitor just one function, not the full function loop? example if i want see just the audio_showstreamtitle?
from esp32_vs1053_stream.
Thanks for checking out the problem. Something has changed between 2.0.2 and 2.0.3 that does not agree with this lib.
For now just use 2.0.2, until I debug this issue.
About audio_showstreamtitle
, audio_showstation
and audio_eof_stream
:
You can use these routines, but you don't have to, as they are weakly linked so optional.
from esp32_vs1053_stream.
I try simple make this, using your included example, but im unable to compile.
I dont know what a parameter i need give for audioshowstreamtitle:
#include <VS1053.h>
#include <ESP32_VS1053_Stream.h>
#define VS1053_CS 5
#define VS1053_DCS 16
#define VS1053_DREQ 4
ESP32_VS1053_Stream stream;
const char* SSID = "xxxx";
const char* PSK = "xxxx";
void setup() {
Serial.begin(115200);
WiFi.begin(SSID, PSK);
while (!WiFi.isConnected())
delay(10);
SPI.begin();
stream.startDecoder(VS1053_CS, VS1053_DCS, VS1053_DREQ);
stream.connecttohost("http://mp3.ffh.de/ffhchannels/hqeurodance.mp3");
}
void loop() {
audio_showstreamtitle(); //?
}
Possible to run in this form and/or impossible or i have forget something?
from esp32_vs1053_stream.
The three audio_xxx
functions are called automatically when stream data becomes available. (And you have an instance of that particular function)
The data becomes available through const char* info
.
If you want to use that data later on in your program you will have to save it.
In the example below the station name is saved as String currentStation
and can be used throughout the rest of the code.
And to proccess the stream stream.loop()
has to be called every couple of milliseconds.
#include <VS1053.h>
#include <ESP32_VS1053_Stream.h>
#define VS1053_CS 5
#define VS1053_DCS 16
#define VS1053_DREQ 4
ESP32_VS1053_Stream stream;
const char* SSID = "xxxx";
const char* PSK = "xxxx";
String currentSong = "";
void setup() {
Serial.begin(115200);
WiFi.begin(SSID, PSK);
while (!WiFi.isConnected())
delay(10);
SPI.begin();
stream.startDecoder(VS1053_CS, VS1053_DCS, VS1053_DREQ);
stream.connecttohost("http://mp3.ffh.de/ffhchannels/hqeurodance.mp3");
}
void loop() {
stream.loop();
}
void audio_showstreamtitle(const char* info) {
currentSong = info;
Serial.printf("currently playing: %s\n", currentSong.c_str());
}
from esp32_vs1053_stream.
This loop call method was for me new, never seen before.
Translate to my basic language this stream.loop(); call a collection of functions:
audio_showstation(const char* info)
audio_showstreamtitle(const char* info)
audio_eof_stream(const char* info)
and i can remove what i dont need.
Also this sream.loop() dont call any other functions what is not part of this library.
I have checked also the sound (ealier i have just want see the decoded url) and i need report, i dont have sound from the vs1053 jack decoder. Please check this too if you have time.
from esp32_vs1053_stream.
It looks like a bug in HTTPClient -or some underlying code- causes this issue.
The http.begin() call has some weird behaviour after setting http.setConnectTimeout() as in timing out before the set time has elapsed.
See https://gitter.im/espressif/arduino-esp32?at=6288f01367db9a59dbdde996
from esp32_vs1053_stream.
And should be fixed 26 days ago in master with espressif/arduino-esp32#6633
from esp32_vs1053_stream.
Ok thanks for the information, i will re check later.
from esp32_vs1053_stream.
If im good understand, after the fix, we can use your library with the new esp32 core too, but we still need wait for the fix.
Currently i have tested your library working well with esp32 core 2.0.2, i have just a question, and one notice/small issue
What if somebody try play a bad url? There is any error handling? Or normaly simple will not start the stream and i can catch this issue with stream.isRunning() and if i dont receive station name?
And i have noticed durint testing trouble with handling special characters - not typical use case, but can generate weird result if somebody try play not only english streams, example in my case hungarian. I dont know library can handle UTF8 characters, but currently if showstation or streamtitle have spacial characters like áéűúőöüóí and/or uppercase variants user will receive like this:
TOP FM r⸮di⸮ >> 90s, 00s what looks originaly TOP FM rádió >> 90s, 00s.
I dont know this need hard work to handle or do you want handle this, but i dont opened currenly new issue.
And realy just a update request, not issue, can we get the actual bitrate of the stream? or this can generate more touble example if have the stream variable bitrate?
from esp32_vs1053_stream.
also a url for the special character using station:
http://live.topfm.hu:8000/radio.mp3
another one:
http://live.topfm.hu:8000/comedy.mp3
Both showstation have special characters.
from esp32_vs1053_stream.
What if somebody try play a bad url? There is any error handling? Or normaly simple will not start the stream and i can catch this issue with stream.isRunning() and if i dont receive station name?
connecttohost() has a boolean result you can check. Or use isRunning(). Or currentCodec().
And i have noticed durint testing trouble with handling special characters - not typical use case, but can generate weird result if somebody try play not only english streams, example in my case hungarian. I dont know library can handle UTF8 characters, but currently if showstation or streamtitle have spacial characters like áéűúőöüóí and/or uppercase variants user will receive like this:
The character encoding upstream can be a real pita.
I 'solved' that issue with https://github.com/CelliesProjects/eStreamPlayer32_VS1053/blob/main/percentEncode.h.
There are probably better solutions you can find on github.
from esp32_vs1053_stream.
Thank you for the help:) If im add this header + in code:
const String urlEncode(const String& s) {
//https://en.wikipedia.org/wiki/Percent-encoding
String encodedstr{""};
for (int i = 0; i < s.length(); i++) {
switch (s.charAt(i)) {
case ' ' : encodedstr.concat("%20");
break;
case '!' : encodedstr.concat("%21");
break;
case '&' : encodedstr.concat("%26");
break;
case 39 : encodedstr.concat("%27"); //39 == single quote '
break;
default : encodedstr.concat(s.charAt(i));
}
}
ESP_LOGD(TAG, "encoded url: %s", encodedstr.c_str());
return encodedstr;
}
and calling url with so, request encode the url:
stream.connecttohost(urlEncode(station[currentstation].url));
im receiving same non encoded stationname:)
But as workaround (by my wifi radio), im just simple adding manual the station name (using Serial monitor input feature) and im display this without using the stationname decoding. The oled driver what im using have special character support and so looking better.
from esp32_vs1053_stream.
In github impossible to write directly to a developer, but thank you for the ogg stream fix, now i have a ogg stream and i hear sound:)
Now looks almost perfect, i just dont know when will possible to update the esp32 core, when will be fixed in drivers.
Another, not truly important question or feature request, when we write out the codec type there is any coding issue why we wont receive with library the stream bitrate?
from esp32_vs1053_stream.
Maybe i was blind, in external example code was not included the bitrate display section, but was included in readme section:)
I have tryed somehow make usable the spectrum analyser plugin for vs1053, but with my programing skill almost impossible. Because i saw only one example (with direct register commands) by one of the edzelf webradio variant what using this plugin. Im not sure this will be using in any future projects (with register commands realy hard) or maybe this just slowing down the working.
https://github.com/blotfi/ESP32-Radio-with-Spectrum-analyzer
Also i have make a mod (or try my best) on the library localy, i have found a command in original vs1053 library, what with users possible to set bass/trebble but currently not in using in vs1053 stream:
if (!_vs1053) {
ESP_LOGE(TAG, "could not initialize vs1053");
return false;
}
_vs1053->begin();
_vs1053->loadDefaultVs1053Patches();
_vs1053->switchToMp3Mode();
uint8_t rtoneCustom[4] = { 7, 15, 13, 8 } ;
_vs1053->setTone(rtoneCustom); //bass treble custom values
setVolume(_volume);
return true;
}
This can be a nice (not a must have required) feature also in vs1053 stream library too.
from esp32_vs1053_stream.
Related Issues (20)
- Stream name not decoded by one station, reason currently unknow HOT 18
- ICY name problem? HOT 3
- The high-bitrate web radio is not working HOT 1
- Is there way to listen to radios using HLS (.ts files)? HOT 3
- I am using this library to listen to my favorite radios, from time to time (about 30-60min) the Esp32 reboots and then keeps rebooting for a few minutes immediately after the first sounds from the station comes out, then it functions normally again. Any ideas? HOT 13
- How to use an existing buffer HOT 3
- 'class VS1053' has no member named 'getChipVersion' HOT 2
- Error compiling simple.ino HOT 2
- lot of compilation errors with arduino Arduino ESP32 pre-release version 3.0.0-aplha 3
- stream stop when call setvolume(), Buffer is zero HOT 1
- error: 'StaticRingbuffer_t' does not name a type HOT 3
- Compiler errors HOT 5
- Watchdog HOT 2
- On https chunked stream, stream->available() returns 31 or less and hangs , but stream unblocks if we read these bytes HOT 4
- ESP Core 3.0.4 - tcpip_adapter_* to esp_netif_`*
- WifiClient not declared HOT 3
- How to use other DAC chip type NS4168? HOT 16
- Unable to play ogg streams, flac ogg playing but no sound HOT 4
- ESP32 core 2.0.4 most of the stations do not play anymore HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp32_vs1053_stream.