ESP32 I2S Internet Radio. Full Tutorial & explanation of I2S. For PCM5102 & MAX98357A I2S Decoders.

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 พ.ค. 2020
  • This is a full tutorial for connecting up the PCM5102 or MAX98357A I2S decoder DAC's. With the demo's being how to use them for Internet Radio. It also includes a explanation of what I2S is and how it functions. I will build on this in future episodes which will show how to play MP3's from SD card and add in an amplifier for the PCM5102. Note I talk about 16bit audio throughout, I am aware that both the chips featured support 24 and 32 bit sound. I have simplified for simplicity!
    Time codes, if you want to skip to a relevant part without watching everything.
    00:53 I2S Explanation
    05:37 What is Internet Radio?
    06:34 Differences between MAX98357 & PCM5102
    0
    8:05 PCM5102 wiring
    11:01 MAX98357A wiring
    14:40 Libraries
    18:31 PCM5102 Demo
    20:15 MAX98375A mono demo
    21:44 MAX98357A - how to do stereo
    23:50 Round up waffle (inc. pleas to subscribe and like etc.
    - Usual Desperation...)
    Link to library Github page : github.com/schreibfaul1/ESP32...
    Affiliate links for the items shown: Clicking these costs you the same price but gives me a small commission, please consider supporting this channel by using them :)
    PCM5102 : amzn.to/3grijdT
    (This has two units, you may only need one of these)
    MAX98357A : amzn.to/3eovdrd
    (You will need two of these for stereo sound)
    ESP32 : amzn.to/2Xzhc3k
    Breadboards: amzn.to/2THZTvy
    Speakers : amzn.to/3gA2sdh
    Project Page at : www.xtronical.com/i2sinternetradio
    For other projects and ideas see :
    Web : www.xtronical.com
    If you'd like to support me via Patreon then the link is below and that would be just amazing. Patreons have access to all videos early plus can view all the posts on Patreon. There are other rewards if you're interested. If you just want to watch videos then that's also fantastic because without people viewing I wouldn't even do half of what I do. So thanks very much :)
    Patreon at : / xtronical
    I also do Kofi (Coffee) if you want to tip me for a brew! : ko-fi.com/xtronical
    Intro/Outro Music by Creo Music : www.creo-music.com
    "Bamboo Swing, B8.wav" by InspectorJ (www.jshaw.co.uk) of Freesound.org
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 94

  • @jaredgray7872
    @jaredgray7872 3 ปีที่แล้ว +6

    Thanks for this video! I've done a fair amount of searching on i2s and this is definitely one of the most detailed and informative on TH-cam. Appreciate you taking the time to put this together

    • @XTronical
      @XTronical  3 ปีที่แล้ว +1

      Thank you for the feedback

  • @90FF1
    @90FF1 2 ปีที่แล้ว +2

    Been looking for a minimalist, mono, single station, ESP32 iRadio. Others I've tried or looked into have too many bells and whistles. Results were mixed. I've ordered a Max 98357 breakout board and will give your design a try. "Everything should be made as simple as possible, but not simpler." - A Einstein. Good instructional video. Thank you.

  • @paulcastelyns8367
    @paulcastelyns8367 3 ปีที่แล้ว +2

    This internet radio guide is just great. I built it and it worked from the 1st time. Congratulations to the installer. It is a pity that there is no electronic scheme. I have extracted the connections from the video material. Thanks and keep up the good work.

    • @XTronical
      @XTronical  3 ปีที่แล้ว +1

      Thanks for the feedback

  • @EasyOne
    @EasyOne 2 ปีที่แล้ว +2

    Very well explained

  • @avieleliyahu6199
    @avieleliyahu6199 3 ปีที่แล้ว +1

    Thanks for the video! You're explaining everything clearly :)

  • @ib3974
    @ib3974 3 ปีที่แล้ว +2

    Very good video, thanks for the code.

  • @iiilllii140
    @iiilllii140 ปีที่แล้ว

    This is excellent. You've earned this sub. This is so good. 👍

  • @MrBobWareham
    @MrBobWareham ปีที่แล้ว

    Well done it sounds like it was hard work to get it all working, so top marks for sharing your hard works, thanks'

  • @ogoranumbor2777
    @ogoranumbor2777 3 ปีที่แล้ว

    Very nice tutorial! 'enjoyed it all thru!

    • @XTronical
      @XTronical  3 ปีที่แล้ว +1

      Thanks for the feedback

  • @melamrao
    @melamrao 4 ปีที่แล้ว +1

    Hello man, it's great. I have been working with Spafunk's standard library for 3 days without success.
    Now I can finally implement the web radio library in my application.
    Thanks a lot

    • @XTronical
      @XTronical  4 ปีที่แล้ว

      Brilliant glad it helped

    • @melamrao
      @melamrao 4 ปีที่แล้ว

      @@XTronical Hi,
      i have a Question.
      can you tell me plz, if it´s possible to have other Loop like a LCD-Loop to detected her Touchscreen or Blynk loop for the Connection to the Blynk Server with the Audio.loop() . !?

  • @miketony2069
    @miketony2069 3 ปีที่แล้ว

    Thumbs up only because I feel like I'm learning from Liam Neeson! Joking...well done sir.

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      Thanks, wish I had his money!

  • @prob17
    @prob17 3 ปีที่แล้ว

    Clearly explained

  • @Kaka-zs4cp
    @Kaka-zs4cp 3 ปีที่แล้ว +1

    Great video!

  • @bignadialna1374
    @bignadialna1374 2 ปีที่แล้ว

    very nice !

  • @michaelhartrey8937
    @michaelhartrey8937 3 ปีที่แล้ว +2

    Great video. I used the PCM5102A and combined it with ILI9431 touch screen. One thing I did notice was that I had to ground the FLT, DMP and SCL pins of the PCM5102A otherwise there was a lot of noise (but perfect when grounded). Not sure if anyone else has experienced this?

  • @billglass5160
    @billglass5160 ปีที่แล้ว

    Some experience with the pcm5102. Had terrible noise (on a breadboard) until adding the additional connections to GND besides what you already mentioned:
    FLT, DMP, SCL. Perfect sound now.

    • @XTronical
      @XTronical  ปีที่แล้ว

      Ahh, interesting. I didn't have any issues (well none that detected with my tone deaf ears!) but worth bearing in mind if I have issues in the future.

  • @IndianTinker
    @IndianTinker 3 ปีที่แล้ว

    I love this channel :D

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      Thank you very much

  • @pqnoicarusbr
    @pqnoicarusbr 3 ปีที่แล้ว

    excelent video! how do I set my uC as slave through class audio? audio.setDatamode ???

  • @Mystical-TEDDY_
    @Mystical-TEDDY_ ปีที่แล้ว +1

    Heyy this video has helped me SO much in understand I2S with the ESP32 in such a simple manner as well, without being 30 mins long and wasting my time and attention. Thank you
    I would like to know tho could you go into further detail about why the capacitor is there. The ESP32 I have looks exactly like that one and i'm not sure if I should use it or not when I try this for myself

    • @XTronical
      @XTronical  ปีที่แล้ว +1

      It's not needed for i2s, it's because this esp32 board has an upload fault and this solves it. It's a common issue on some types of cheap boards.

    • @Mystical-TEDDY_
      @Mystical-TEDDY_ ปีที่แล้ว

      @@XTronical I don’t think I have this issue but idk for sure will anything bad happen if it try it without the capacitor first? Or if I do try it and don’t need it?

    • @XTronical
      @XTronical  ปีที่แล้ว +1

      Nothing bad happens, just fails to upload your code. You can test with just your board. Try uploading some code if you've not already. It'll just time out if it has this issue. Some people on some boards can get away with just pressing the en button whilst uploading (I think) but that didn't work for me. I so need this hack

    • @Mystical-TEDDY_
      @Mystical-TEDDY_ ปีที่แล้ว

      @@XTronical okay thanks for the explanation

  • @F5VMJ
    @F5VMJ 3 ปีที่แล้ว +1

    Very nice vids mate...And straight to the point with no faffing. Do you know of a solution or workaround to eliminate the pops/clicks when playing an mp3 file from SPIFFS?? I'm getting this using the PCM5102 module, at start and end of play. I think it might be the Zero Data Detect function switching it on and off rather clunckily.

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      Thanks for the kind words. I don't know a fix off hand but I'm working through i2s stuff at the moment and will be adding mp3 support to my own library as part of that, so at that point I'll sort. Just a quick question, does this only happen using spiffs. Your discription sounds correct, seems like it's not bringing the speaker back to rest slowly at the end end of play or something like that.

    • @F5VMJ
      @F5VMJ 3 ปีที่แล้ว +1

      @@XTronical Ahhhh ..Just tested... yes, only happens when I read a SPIFFF file. When 'tuning' around different wifi radio stations it's sweet as a nut... no snap, crackle or pop. So, maybe a library issue? (I also notice that it cuts the the very end of off an mp3 SPIFFF file. Just a few tenths of secs but noticible. I just work around that by Audiacitizing and adding a silence period at the end.

    • @XTronical
      @XTronical  3 ปีที่แล้ว +1

      Interesting it's just spiffs, I might not have checked that, so thanks.

  • @x-rockfm92hd81
    @x-rockfm92hd81 2 ปีที่แล้ว +3

    THANKS XTronical i SUBSCRIBED ON OTHER ACCT

  • @geeuk
    @geeuk 3 ปีที่แล้ว +1

    Thanks for the video, I tested this on a pcm5102a and it worked first time. Boot time is 2 seconds which is awesome! I was wondering if i get a cat 1 lte module will it handle the stream and data receive or is it an overkill for cpu power?

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      I'm embarrassed to say I was unfamiliar with what you were talking about. I quick Google gave me some clues but I'm still not entirely sure how they would work together I'm afraid so I cannot answer your question.

    • @geeuk
      @geeuk 3 ปีที่แล้ว

      @@XTronical Thanks for your reply. I am sorry that i couldn't explain it better. Basically I can use your script to play radio streams using wifi, what I want to do is add an 4g lte module to the esp32 at the same time so it will have mobile lte connection and also incorporate the pcm5102a to play audio over the mobile network instead of wifi.

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      Ahh, sounds interesting and perhaps tricky? Let me know how you get on

  • @jayvadgama3703
    @jayvadgama3703 ปีที่แล้ว

    Great video
    I made web radio using Esp32 my oled display working fine but my i2s dac (purple coloured board one) is not working I used Esp32 and uploaded Karadio32 code.
    Any idea what problem did it have?

    • @XTronical
      @XTronical  ปีที่แล้ว

      Not sure, I would double check the connections for that board are correct. Some have pins that need to go to ground or Vcc to get the correct gain or configure them in certain ways.

  • @JerryEricsson
    @JerryEricsson 3 ปีที่แล้ว +1

    Cool, I have built a few other wifi radios they all have different features, this one is a bit basic as you have to recompile to change stations. My first attempts were with the VS1053 board and I do enjoy the ability to change stations with a rottery encoder or via PC or cellphone using a browser, but this little guy can be very compact so I guess I could select one station and use it for, say a pocket radio and run it via earphones. To bad a fellow can't activate the Bluetooth on the ESP and use that to listen to the radio stations over bluetooth enabled earphones, or in my case hearing aides. Perhaps that could be done, I shall have to look into that. Just noticed the station I have on now is in German. I have studied that language a bit as my maternal grandfather came from Germany just before WWI he well sort of took an unauthorized leave from the Kisar's army and came to America, to have transportation from the East Coast to his cousin's place in Dakota, he took his favorite horse from the Kisar's stables and rode it all the way from NYC to the Dakota's. Ah the stories he used to tell, God I do miss him, we lost him in 1959.

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      You could alter the code to support selecting different stations, perhaps even put a display on it if your feeling adventurous 😊

    • @JerryEricsson
      @JerryEricsson 3 ปีที่แล้ว

      @@XTronical Going to have to look into that. I am in a most stressful situation right now, as my wonderful wife of 51 years (tomorrow) is in hospital, not expected to live after cancer has invaded and pretty much disabled her liver. Doctor tells me to spend time with my hobby when not with her in her room to occupy my mind, it does seem to help take my mind off things, and for this I am ever grateful. I have a station playing on the device right now, I built this one up on a strip board I had forgotten to ground the FMT pin and was having a heck of a time, well I had it wired but to the wrong pin. I noticed it last night before I went to bed but didn't wish to heat up my soldering iron and leave it to cool while preparing for bed, so I left it for this morning. a storm woke me at 4:00 AM so I have had plenty of time to fix it. Fix it, I did.

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      Take care and look after yourself, it must be stressful

  • @rifqizainnugroho3955
    @rifqizainnugroho3955 4 หลายเดือนก่อน

    i tried to play audio with esp32 and max98357a but the audio is too quietly, how to make the audio loud?

  • @JerryEricsson
    @JerryEricsson 3 ปีที่แล้ว

    Very cool indeed I have built both of these now, as well as some with the VS1053B chips. I find the VS chips very succeptable to over voltage damage as well as static electricity. I have a pile of six of the blasted little DAC'S laying in a pile on my desk, most the result of my own stupidity hooking up to much voltage to the wrong pin. I guess I come by it honestly, I am still in the state of shock having lost my loving wife, the true love of my life to cancer some 4 days following our 51st wedding anniversary. It was quite a hit, sure we knew it was coming, she was diagnosed with incurable cancer only 4 months before her death, we took every chance fighting it but it was not to be. She died in my arms in hospital and my heart is still broken. So I have an excuse I guess.

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      Of course you do.

  • @nepen_
    @nepen_ ปีที่แล้ว

    Great tutorials and delivered with the right level of humour to keep it interesting but not taking over the point of the videos. Helped me sift through the vast array of possible hardware to something that I should be able to pull off with my limited electronics knowledge.
    Only, I've hit a problem almost straight away... Not able to get the SD card to successfully initialise. I have a version of the card reader with the voltage regulator, but since I want to power everything off a 5v PSU, I presumed this would work fine. And I'm using different pins on the ESP32... That shouldn't matter though, right? Do you have any tips on debugging the circuit??

    • @XTronical
      @XTronical  ปีที่แล้ว

      Thanks for the feedback. Try this video I did a while back, it explains what you might need to do
      th-cam.com/video/ZmMTr8LEa1A/w-d-xo.html

    • @nepen_
      @nepen_ ปีที่แล้ว

      @@XTronical Thanks for the pointer. I actually meant to comment on the "Quickie: Playing MP3's (and other types) on your ESP32 from an SD Card" video. My bad. Anyway, I've tried the voltage regulator bypass trick on the SD card breakout board, and I'm still having no joy.

    • @XTronical
      @XTronical  ปีที่แล้ว +1

      I can't remember but I think I will be connecting to 3.3v on ESP32, did you change to that from your 5V. Other thing to check is that the library only supports 32Gb or less cards (could by 16Gb actually) so ensure not using too big a card. If not any of them then I'd try buying another card in case you've got a duffer

    • @nepen_
      @nepen_ ปีที่แล้ว

      @@XTronical In case it helps anyone else in a similar situation (i.e. being an ESP32 / microcontroller noob) - if you want to use SPI (which is the bus protocol that the SD card uses) then you MUST use the SPI pins on the ESP32. Not all pins are created equally, and some of the pins have very specific functions. I now have it working on 5v with an unmangled SD board (I'm glad I bought two).

  • @felanino2081
    @felanino2081 ปีที่แล้ว

    Hi, may i know what spec of the speaker to get the loudest audio output when use max98357?

    • @XTronical
      @XTronical  ปีที่แล้ว

      Any 8ohm is generally OK. You can get away with quite large speakers without much of a problem. I used an approx 15cm one from an old hifi and had no problems.

  • @grennereis8977
    @grennereis8977 3 ปีที่แล้ว

    Hi, do you have a tutorial to transmit digital áudio between two esp32, one receiving áudio from source transmit to the other one and this conect to a speaker.

    • @XTronical
      @XTronical  3 ปีที่แล้ว +1

      Sorry, I've not done that yet.

  • @blikje_in_de_water
    @blikje_in_de_water 3 ปีที่แล้ว +1

    Just a question... Why would you add 5V to the output of a voltage regulator?

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      Not sure exactly what you mean. However I have seen your previous post before you deleted it and I think what you've done is connected the 5V output from the ESP32 board to the power rail of the breadboard. If you look at the video (during wiring parts) it's the 3.3v output of the ESP32 that connects to this power rail. Which if you've done this explains the smoke you had the other day.

    • @blikje_in_de_water
      @blikje_in_de_water 3 ปีที่แล้ว

      the pcm5102 has a input voltage of 5v to 10v with that it makes 3.3V (output of the voltage regulator is routed to the 3.3v pin on the pcm5102 module aswell as the pcm5102 itself) so you are adding 3.3v to an 3.3v output? I really dont see the logic of that... (no offense or what ever, I like your work a lot but i'm just wondering ..)

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      Sorry, my bad. Got confused with the 98357A which is also covered in that video. Not sure then why yours broke.

  • @gartmorn
    @gartmorn 3 ปีที่แล้ว

    How easy would it be to add channel selection?

    • @XTronical
      @XTronical  3 ปีที่แล้ว +1

      Yes, in the example you can see the commented out channels. Store these in an array and set the channel setting to whichever you want.

    • @gartmorn
      @gartmorn 3 ปีที่แล้ว

      @@XTronical thanks for the reply it's much appreciated! I'm not great at coding so having the code already there is a real bonus. Just need to get a DAC module!

    • @XTronical
      @XTronical  3 ปีที่แล้ว +1

      I may do a skeleton example in near future, as it's not a big task. That should give you a good starting point

    • @gartmorn
      @gartmorn 3 ปีที่แล้ว

      @@XTronical brilliant, that would be great.

  • @cptcrogge
    @cptcrogge 3 ปีที่แล้ว

    Is there any better "out of the box" stereo solution?

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      If you mean all on one chip with an amp? If so, I'm not sure, but haven't looked that hard.

    • @cptcrogge
      @cptcrogge 3 ปีที่แล้ว

      @@XTronical I will keep my eyes open. I really enjoy those ESP32 cam modules, its very convenient.

  • @gw33b
    @gw33b 3 ปีที่แล้ว +1

    So far i have only beeen able to connect to http servers and unable to connect to secrure https servers. has anyone else had any more luck or is this a limitation of the software library?

    • @XTronical
      @XTronical  3 ปีที่แล้ว

      I've not tried, but I bet it's a limitation, the security would need extra coding.

    • @a2311585
      @a2311585 3 ปีที่แล้ว

      make sure you use wificlientsecure

  • @reinaldohurtado3514
    @reinaldohurtado3514 3 ปีที่แล้ว

    im getting,
    intermittent sound, sometime. neither that playing from the sd card. i though maybe my router is the cause, and low buffer memory on esp32

    • @XTronical
      @XTronical  3 ปีที่แล้ว +1

      I've not had any intermittent problems, although I'm not clear, is this from sd or Web radio?

    • @reinaldohurtado3514
      @reinaldohurtado3514 3 ปีที่แล้ว

      @@XTronical , its from wed radio, mp3 sounds perfect, i am trying to add lcd and navigation button, but i dont know how program works, the code execution is not lineal apparently, how is audio_eof_mp3 call it?

    • @XTronical
      @XTronical  3 ปีที่แล้ว +1

      Once you add the audio_eof_mp3 function to your code the library will call it automatically when the end of the MP3 is reached. If you don't add this function to your code nothing happens.

  • @aderaba
    @aderaba ปีที่แล้ว

    I built a radio based on the information from this video, it works well but the audio output from MAX98357A is weak not strong enough cannot cover clearly a small room, I tried two versions of the board and got the same results, my question is if that's how supposed to be a 3 Watts audio output or anything is wrong with my circuit, or if is there to get an I2S board with stronger output more than 3 watt, I'm estimating that to hear the sound in a medium room an amplifier of 10 to 15 Watts is needed.
    I'll appreciate if someone can answer my question.
    Thanks

    • @XTronical
      @XTronical  ปีที่แล้ว

      Have you tried altering the gain with the gain pin? Also try a bigger (but same resistance) speaker. I hooked up some Sony ones that worked well. Although someone did comment how they might cause issues with the amp but I've had none. So in summary try increasing gain and try some quality speakers (if your not using some)

    • @aderaba
      @aderaba ปีที่แล้ว

      @@XTronical Thanks very much for your answer, I ordered all ready today a better quality 4 Ohm 3 watt speakers, by the way I like very much your videos I've got a lot of knowledge from them, just another question, could your explain how to work with the gain pin on the MAX98357A ? I found somewhere else to ground it with a 100K resistor to gain more volume but I'm not sure, Keep your good work Thanks.

    • @XTronical
      @XTronical  ปีที่แล้ว

      There are various gains depending on how you connect this pin, from 3 to 15. Connecting to ground via 100k gives maximum gain so your already there with that. Must be a speaker issue perhaps. I've had decent volume out of mine. Have you set the volume level in the software /library too?

    • @aderaba
      @aderaba ปีที่แล้ว +1

      @@XTronical I set the volume in the software to 20 it's closed to maximum, the 100K resistor on the gain I didn't do yet, tomorrow I supposed to get the better speakers that I ordered, so I'll let you know the results, thank you very much.

  • @rogenogueira
    @rogenogueira 11 หลายเดือนก่อน

    thanks for share, very nice project.
    I builded an internet radio using the VS1053 decoder, it works well. However, I want to use my ESP32 TTGO T-Display v1.1 but the VS1053 and the TFT uses the same SPI communication, I thought it could be better to use an I2S device instead of VS1053.
    Do you know if is it possible to build your project with PCM5102 and ESP32 TTGO T-Display?
    Another question, can PMC5102 play streams in aac?
    thank you very much.
    My radio:
    th-cam.com/video/JArV3dUWTHE/w-d-xo.html

    • @XTronical
      @XTronical  10 หลายเดือนก่อน

      5102 should work OK, just check how it's supposed to be wired. I think I@ve done a video on it (was it in this one?). Don't see why the TTGO shouldn't work unless it's missing the output (I've not got one). Not sure about the AAC, i've never looked at it.