ESP32 Internet Radio II
<-ESP32 Internet Radio
<-Internet Radio Player based on MOC

Here is the ESP32 Internet radio version mark II.

What has changed from the first incarnation of that "minimalist" Internet radio in just a few days? The addition of a display is rather obvious. The other is the addition of an IR receiver. The mark II is now a four device Internet Radio. The third which cannot be seen is a partial integration of the radio in the home automation system. Before presenting some details about these changes, here is their justification: general indifference to the mark I version of the Web radio. Much to my chagrin, as soon as my spouse heard that a Web radio station could be selected from the web interface, she made it clear it was too complicated. Using just a couple of buttons, she had no problems getting a station with the sound system, why could it not be just as simple when it came to the Internet radio? Valid point!

Table of contents

  1. Display
  2. IR Remote
  3. Domoticz
  4. Future

Display toc

Quite a number of displays can be used with ESP32-Radio including the LCD1602, which is a 32 character LCD display arranged as two lines of 16 characters, hence the name. A "bare" LCD which has an 8-bit parallel data bus cannot be used. The software can interface with the display over an I²C serial connection. I²C interface boards based on the PCF8574 Remote 8-Bit I/O Expander are easily found. I had such an adapter on hand, and after some tedious desoldering to remove the pin header on the adapter, I was able to solder it directly on the LCD1602 header. If ever I purchase of another LCD1602, I will try very much to find one with the I²C adapter already in place. The serial connections needs I/O pins for the SDL and SCL signals, a ground connection and a connection to 3.3V. This was all easily done. Adding the following in the configuration file on the ESP32Radio web page was all that was needed to activate the display.

pin_tft_scl = 22 pin_tft_sda = 21

Don't forget to save and restart the radio for the change to take effect.

Unfortunately, the display is almost useless. The viewing angle of the LCD1602 is so narrow that it is basically unreadable. Furthermore, two lines of 16 characters are not enough to display metadata obtained from web radio stations. Ed Smallenburg (Edzelf), the author of ESP32-Radio, anticipated that problem. Metadata, such as song titles, or web radio URLs scroll horizontally if too long, just as CD titles are scrolled by the car's CD player. Nevertheless, the result is not that satisfactory and a upgrade in the display may be worthwhile.

IR Remote toc

Again, ESP32-Radio support for an infrared receiver is already in place. And quite luckily, the IR remote for the sound system uses the NEC protocol which the ESP32-Radio recognizes, and it has a number of keys that have no effect when the system gets its input from the AUX connection used by the Internet radio. Activating the IR interface was a simple matter of connecting power (3.3V) and ground to the IR module and to connect the later's data signal to an ESP32 GPIO. Once that was done, I added the following to the configuration file of the Internet radio using its web server.

pin_ir = 35 # GPIO pin connected IR receiver data signal ir_20DF = downpreset = 1 #left ir_40BF = downvolume = 2 #down ir_837C = uppreset = 99 #enter ir_C03F = uppreset = 1 #right ir_F906 = upvolume = 2 #up

The tricky part is getting the IR codes for the buttons on the remote. The simple way is to connect the ESP32 by USB cable to a desktop and to open a terminal with the serial port. As the buttons on the IR remote are pressed, ESP32Radio will report the IR codes. I have something resembling very much the BlitzWolf BW-RC1 Mini Infrared Remote Controller on which TASMOTA-IR was installed following the instructions in two articles: Flashing the BlitzWolf BW-RC1 Infrared Blaster with Tasmota at Mat's Hideout, and Flashing the BlitzWolf BW-RC1 with Tasmota by Matthew Harrold. The modified "IR-blaster" publishes MQTT messages reporting received IR codes. All I had to do was to subscribe to the MQTT broker and record the messages noting which button on the sound system IR remote was being pushed.

michel@hp:~$ mosquitto_sub -h domo.local -t 'tele/teleman/RESULT' {"IrReceived":{"Protocol":"NEC","Bits":32,"Data":"0x1EE120DF","DataLSB":"0x788704FB","Repeat":0}} {"IrReceived":{"Protocol":"NEC","Bits":32,"Data":"0x1EE140BF","DataLSB":"0x788702FD","Repeat":0}} {"IrReceived":{"Protocol":"NEC","Bits":32,"Data":"0x1EE1837C","DataLSB":"0x7887C13E","Repeat":0}} {"IrReceived":{"Protocol":"NEC","Bits":32,"Data":"0x1EE1C03F","DataLSB":"0x788703FC","Repeat":0}} {"IrReceived":{"Protocol":"NEC","Bits":32,"Data":"0x1EE1F906","DataLSB":"0x78879F60","Repeat":0}}

The added highlighting makes it clear how to identify IR code needed in the ESP32Radio configuration. Note that when the Enter button on the remote is pressed the uppreset=99 command is executed. Given that there are at most 100 presets (numbered 0 to 99) that should bring us to the first preset no matter which is being played at the time.

Domoticz toc

Adding a couple of virtual sensors in Domoticz, the home automation system used for about three years now was a simple matter. I decided to implement only the equivalent of the station preset navigation buttons on the IR remote. They are set up as push-on buttons.

The selection of the type of button and the action to be performed when activating the virtual sensor is done in its Edit screen.

Of course, the On Action of the other button is http://esp32radio.local/?downpreset=1. The URL can be a problem on some systems. Recall that esp32radio assigned in the firmware to the ESP32. Currently, this is not configurable and must be changed in the source code. Care will be needed if more than one Internet radio is installed on the local network. Because of possible name conflicts, it is not possible to know with certainty which ESP32 will be assigned the esp32radio.local URL and which will be named esp32radio-2.local by the mDNS system. Indeed some operating systems may not even have Zeroconf running. The obvious solution would be to use the radio IP address. But again the firmware uses dynamic IP addressing (DHCP) which means that either the source code will have to be modified for each radio or the network DHCP service (usually, but not always, a router service) will have to assign fixed IP addresses based on the ESP32 MAC addresses.

The interesting thing here is that Alexa can now be used to switch to the next or previous web radio preset. My spouse does not want to use her smart phone to select presets, but she does use voice commands to turn some lights on or off. I wonder what she will think of this addition.

Future toc

This is not the end of this topic. I will come back to using a Raspberry Pi for this function. And there's already a second Internet Radio running in my office. In this version, the ESP32, just like the Pi, does the MP3 decoding and sends the digital output to an I²S DAC (digital to analogue converter). A TTGO-T-DISPLAY is being used and that has an on-board colour 135x240 colour display. Since the DAC and the ESP boards are almost the same size, it could be a very compact device. Right now it is still at the breadboard stage, sitting on top of a Realistic S150 amplifier connected to a pair of Realistic Minimus-0.5 speakers. It might be old equipment (circa 1986), but the sound is better than what is coming out of the speakers built into the HDMI monitor.

<-ESP32 Internet Radio
<-Internet Radio Player based on MOC