This is a port of my Internet Radio with the ESP32-2432S028R with resistive touchpad to the ESP32-8048S043C module with larger screen and capacitive touchpad.
The user interface should offer the following options:
- Display of time and date
- Display of metadata such as composer and music title
- Display of station number and name
- A button to mute
- Volume adjustment via slider
- Navigating through the predefined station list
- Saving and recalling the preferred station and volume
- Saving a screenshot to SD card
To be able to display umlauts in German metadata, a character set is required that also contains the characters from 128 to 255. Such a font can easily be created from any ttf font with the program fontconvert and ttf fonts are found under Windows in the font directory. But any existing copyright must be respected!
size first last destination
fontconvert c:\windows\fonts\calibri.ttf 8 32 255 > calibri.h
We need 3 GPIO pins for the external I2S decoders. However, only the following are available on the external connectors:
Connector P1 Connector P2 used for Connector P3 used for
GND GPIO_19 i2c sda GPIO_17 free
RXD GPIO_11 spi mosi SD card GPIO_18 free
TXD GPIO_12 spi sclk SD card GPIO_19 i2c sda
5V GPIO_13 spi miso SD card GPIO_20 i2c scl
Using the 3 SPI pins from port P2 for the I2S audio, we can no longer control the SD card. If we use the 2 free GPIOs from port P3, we are still missing one pin. This means we cannot operate I2S audio and the SD card at the same time.
But the following scenario works: For the I2S audio, we use the two free GPIOs from connector P3 and one GPIO from connector P2, e.g., GPIO_11, which is otherwise used for SPI. If we now want to save a screenshot to the SD card, we stop the audio, i.e., release GPIO_11, start SPI, and save the screen data to the SD card. We then stop SPI and restart the I2S audio.
To operate two speakers, I used two Max98357 PCM Class D amplifiers and equipped them with two different resistors to get the left and right stereo channel. I have described how these resistance values are calculated in my repository ESP32Internetradio.
I wired the CYD and the MAX98357 as shown in the table:
MAX98357 | ¦ | Con P1 | ¦ | Con P2 | ¦ | Con P3 |
---|---|---|---|---|---|---|
LRC | ¦ | ¦ | IO 11 | ¦ | ||
BCLK | ¦ | ¦ | ¦ | IO 17 | ||
DIN | ¦ | ¦ | ¦ | IO 18 | ||
GND | ¦ | GND | ¦ | ¦ | ||
Vin | ¦ | 5V | ¦ | ¦ |
.-----------------.
11 --> o LRC |
17 --> o BCLK MAX |
18 --> o DIN 98357 |
o Gain | Spkr right
5V Vin ---[560K]----o SD | _/|
GND --> o GND o---| |
5V --> o Vin (5V) o---|_ |
`-----------------´ \|
.-----------------.
11 --> o LRC |
17 --> o BCLK MAX |
18 --> o DIN 98357 |
o Gain | Spkr left
5V Vin ---[180K]----o SD | _/|
GND --> o GND o---| |
5V --> o Vin (5V) o---|_ |
`-----------------´ \|
When the web radio is put into operation for the first time, the
AutoConnectAP access point is started. Log in here with your cell phone
and then enter the SSID and password of your router via the web browser
at the URL 192.168.4.1. The login data is then saved permanently so that
the web radio connects automatically in future.
I use the LovyanGFX library for programming graphical elements. I programmed some components for the user interface myself and compiled them in the UiComponents library. For the audio functions, I planned to use Phil Schatzmann's AudioTools. However, I encountered problems with both libraries, namely the following:
- The LovyanGFX calls the unsupported function
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[pin], PIN_FUNC_GPIO)
which i had to replace with
gpio_iomux_out(pin, PIN_FUNC_GPIO, false)
The file in question, Bus_RGB.cpp, is located in my file hierarchy in this path
...pio\libdeps\esp32-8048S043C\LovyanGFX\src\lgfx\v1\platforms\esp32s3\Bus_RGB.cpp line 98 - The AudioTools require Arduino-ESP32 Core version 3.x, so I had to update my Platformio programming environment. To do this, I downloaded the Platformio extension pioarduino and added this line to platformio.ini platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip.