Yesterday I managed to create a simple program to listen to a web radio (from Brazil, of course :D )
But, before that could happen, I had to put my non-existent soldering skills to the test! Yes, my PCM5102 board didn't have the jumpers soldered, I had to solder them myself and, of course, the header pins.

Anyway, here is the "radio" put together and its code!
I have followed this article https://www.xtronical.com/i2sinternetradio/ that uses this library https://github.com/schreibfaul1/ESP32-audioI2S but, note the PINs I had to use, they are different from the article, I guess that my ESP32 and my PCM5102 are slightly different.
#include <Arduino.h>
#include <WiFi.h>
#include <Audio.h>
#define I2S_PIN_BCLK (26) // Bit Clock (BCK)
#define I2S_PIN_WS (25) // Word Select (L/R)
#define I2S_PIN_DOUT (22) // Data Out (DOUT)
const char* ssid = "your-wifi-network";
const char* password = "***********";
const char* radioURL = "https://www.appradio.app:8010/live?1724128347016";
Audio audio;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
audio.setConnectionTimeout(5000, 5000);
audio.setPinout(I2S_PIN_BCLK, I2S_PIN_WS, I2S_PIN_DOUT);
audio.setVolume(5); // 0...21
audio.connecttohost(radioURL);
}
void loop() {
audio.loop();
}With that setup, I could hear 105.1 FM from Sao Paulo, using some headphones.
But there is more! Now it is time for the PAM8403 and speakers! Here is a demonstration:
Next step: Put the buttons back and make it sound with 4 polyphonic notes!
Bruno Campidelli
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.