Internet radio ESP32 and PCM5102

Place code snippets and demo code here
User avatar
cicciocb
Site Admin
Posts: 1899
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1269 times
Contact:

Re: Internet radio ESP32 and PCM5102

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Tue Jun 29, 2021 5:51 pm Hello Fernando,

Thank you for clearing up my confusion about the I2C and I2S buses.
Now I understand that I can indeed use both the OLED on the I2C (software-emulated) bus and the I2S DAC simultaneously.

This is a great community! I only joined a few days ago and all my questions were answered quickly and in detail.

If you don't mind, I have one more:
Did you have to tie any of the pins on the DAC board to ground (FLT, DEMP, FMT) or 3.3/5V (XSMT)?

Regards,
Eric
HI Eric,
just to clarify, as you stated, the I2S and the I2C can be used at the same time BUT they cannot share the same pins (the GPIO5, in your case).
Another point to clarify is that the I2C is not software emulated in the ESP32 ( as is the case for the ESP8266) as it reles on H/W I2C internal controller.
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: Internet radio ESP32 and PCM5102

Post by Fernando Perez »

Another point to clarify is that the I2C is not software emulated in the ESP32 (as is the case for the ESP8266) as it reles on H / W I2C internal controller.

Does this mean that on the ESP32 only the GPIO21 (SDA) and GPIO22 (SCL) pins can be used to connect our I2C devices?
User avatar
cicciocb
Site Admin
Posts: 1899
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1269 times
Contact:

Re: Internet radio ESP32 and PCM5102

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Jun 30, 2021 8:43 am Another point to clarify is that the I2C is not software emulated in the ESP32 (as is the case for the ESP8266) as it relies on H / W I2C internal controller.

Does this mean that on the ESP32 only the GPIO21 (SDA) and GPIO22 (SCL) pins can be used to connect our I2C devices?
Hi Fernando,
no, the ESP32 has internally a switching matrix that can route almost any signal to any GPIO pin.
However, Some exception exists, such as the analog DAC outputs (fixed to pins 25 and 26).

So, the I2C can be routed to any GPIO pin still using the internal H/W I2C module
ebs
Posts: 14
Joined: Fri Jun 25, 2021 2:33 pm
Been thanked: 2 times

Re: Internet radio ESP32 and PCM5102

Post by ebs »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Jun 30, 2021 7:00 am HI Eric,
just to clarify, as you stated, the I2S and the I2C can be used at the same time BUT they cannot share the same pins (the GPIO5, in your case).
Another point to clarify is that the I2C is not software emulated in the ESP32 ( as is the case for the ESP8266) as it reles on H/W I2C internal controller.
Believe it or not, I did manage to use both the I2C OLED and the I2S DAC! My simple test program looks like this:

Code: [Local Link Removed for Guests]

i2c.setup 5, 4
oled.init 1
oled.cls
oled.font 2
oled.color 1

StreamName$ = "Beatles Radio"
StreamURL$ = "http://64.40.99.76:8000/"

oled.print 0, 0, StreamName$

play.setup 1, 64
play.stream StreamURL$
The program works, but there was some unexplained (until now) strange behavior - initial stuttering when the stream playback started, and the OLED seemed to operate much more slowly than normal. Given that both devices are trying to use GPIO5, I'm surprised it worked at all.
I was planning to use the OLED to show the stream and song name, but I may use an HTML interface, borrowing heavily from Fernando's code.

Thanks to both of you for all your help!

Regards,
Eric
User avatar
cicciocb
Site Admin
Posts: 1899
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1269 times
Contact:

Re: Internet radio ESP32 and PCM5102

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Jun 30, 2021 11:53 am I was planning to use the OLED to show the stream and song name, but I may use an HTML interface, borrowing heavily from Fernando's code.
You should try to flash the ESP32 device in QIO mode as this is gives a little boost in performance with a nice benefit for the MP3 player
ebs
Posts: 14
Joined: Fri Jun 25, 2021 2:33 pm
Been thanked: 2 times

Re: Internet radio ESP32 and PCM5102

Post by ebs »

You should try to flash the ESP32 device in QIO mode as this is gives a little boost in performance with a nice benefit for the MP3 player
I'm not familiar with QIO mode - can you please give me a link to explain what it is and how to do it? Thanks!

Regards,
Eric
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: Internet radio ESP32 and PCM5102

Post by Fernando Perez »

Before recording Annex on your ESP32, check the "Advanced Option" box and make sure the QIO option appears in the drop-down menu. Then proceed normally.
When you mentioned it, I remembered that I also got some nasty stuttering when I started playing a station, and sometimes during playback. However, it has not happened to me for a long time. Unfortunately, I don't remember if it was for linking GND to SCK pin, for placing the "bluetooth.delete" instruction at the beginning of the program, for using the latest version of Annex or for checking the QIO box.

image.png
You do not have the required permissions to view the files attached to this post.
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 120 times
Been thanked: 132 times

Re: Internet radio ESP32 and PCM5102

Post by AndyGadget »

I used a slightly different PCM5102A board and have finally got it working.
I had to connect FMT to Gnd and Xmt to 3v3 to get enything more than a strangled burp out of it.
Now it's working . . . It's BRILLIANT!
Love the quality on the VoiceRSS TTS.

Lots of new goodness to explore here :D :D :D
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 120 times
Been thanked: 132 times

Re: Internet radio ESP32 and PCM5102

Post by AndyGadget »

There's a good list of UK streaming stations (including the BBC) here : http://www.radiofeeds.co.uk/mp3.asp
To get the stream URL, click on the 'bitrate' button then use a text editor to examine the downloaded file and copy out the URL.
Post Reply