Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes loses network connection #2

Open
nopnop2002 opened this issue Mar 13, 2020 · 4 comments
Open

Sometimes loses network connection #2

nopnop2002 opened this issue Mar 13, 2020 · 4 comments

Comments

@nopnop2002
Copy link
Owner

Sometimes loses network connection.
But i don't know why.

@nopnop2002
Copy link
Owner Author

nopnop2002 commented Mar 18, 2020

There is a problem that the network connection is lost in ESP32.

I listened to the same radio station with Mplayer in a RaspberryPi to investigate the problem of loss of network connection.

As a result, i found that ESP32 reads sockets slower than RaspberryPi.

Receiving the same metadata chunk is about one minute behind the Raspberry Pi.

I think the server disconnects the network because the socket reading speed of ESP32 is slow.
If the client's socket read speed is slow, the server needs to hold a large amount of StremData.

The cache size of Mplayer is 320KByte by default.

Cache size set to 320 KBytes

It may not be possible with the ESP-IDF standard RingBuffer mechanism.

@nopnop2002
Copy link
Owner Author

nopnop2002 commented Mar 19, 2020

This was a simple reason.

ESP32 cannot play for a long time at 128K bit rate due to its low CPU Power.

ESP32 cannot follow the transmission speed of the server.
The server will try to send data more than 10 seconds ahead, but ESP32 is too slow to follow.
As a result, ESP32 is disconnected from the server.

When you start Linux mplayer with the following options, you can see when the server sends data.

mplayer -msglevel all=7 -playlist http://ice2.somafm.com:80/seventies-128-mp3

If the bit rate is 64K, ESP32 can play for a long time.

There is no fundamental solution.

As a passive solution, if the RingBuffer is large on models with PSRAM, the RingBuffer data can be played while reconnecting to the server.

For models with PSRAM, you can get up to 4M RingBuffer.

Even if you are disconnected from the server, the data stored in the 4M RingBuffer will continue to play.

The maximum value of RingBuffer for models without PSRAM is 160K bytes.
This is system limit.

@nopnop2002
Copy link
Owner Author

nopnop2002 commented Apr 9, 2020

I got ESP32-WROVER-B.

WROVER-B has PSRAM.

I can get up to 4M RingBuffer.

But PSRAM's RingBuffer is too slow to play music.

Writing to PSRAM RingBuffer requires twice as long as RAM RingBuffer.
Therefore, smooth performance cannot be performed.

Furthermore, when using PSRAM, some GPIOs cannot be used.
Click here for details
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/external-ram.html

Conclusion
To keep listening to the 128K bit rate radio, you need a fast CPU and a lot of RAM.

@nopnop2002
Copy link
Owner Author

nopnop2002 commented Apr 10, 2020

I got VS1053(Red Board)

It works very stably.

Performance is completely different from VS1003 (Blue Board).

The register setting of VS1003 may be incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant