Make a Web-Radio for Less Than $15

by techprolet in Circuits > Audio

19304 Views, 79 Favorites, 0 Comments

Make a Web-Radio for Less Than $15

DSC_4039_1200.jpg
Make a web-radio for less than $15

So, I decided to do a project I've been postponing for a while:
A homemade, fully functional web radio, complete with amplifier and speaker, for under 15€!.

You can change between predefined streaming radio stations with the push of a button and you can control volume by rotating a nice potentiometer..

Bill of Materials

esp32_variants.png
max98357a.jpg
  • ESP-WROOM32 based microcontroller board. There are actually at least two variants of interest with this microcontroller chip (see picture) - I used a WEMOS LOLIN32, which does not have an onboard button, because I wanted to use my own. If, however, you want to avoid as much soldering as possible, you can go for the other variant, which comes with a button and pins already soldered in place.
  • Adafruit I2S 3W Class D Amplifier Breakout - MAX98357A. This minute board features a miraculous chip from Maxim Electronics which is both a DAC (Digital to Analog Converter) and a 3W Class D Amplifier! You feed it digital signal from your μcontroller and drive the speakers directly, no other circuits needed.
  • Speaker 4Ω/8Ω. I used a SHARP RSP-ZA249WJZZ L, 8 Ω, 10 W, a leftover Sharp TVs part, which I bought from an online surplus store.
  • Hollow bushing 5.5/2.1 mm
  • Linear Potentiometer 120Ω. This will not completely silence the radio when turned all the way down, but you get a very usable range of speaker volume using it.
  • Miniature Button (if you follow blindly this guide, make sure that the button you use is normally in off position, and on when pressed). You may also have to modify the source code to improve the button's behaviour (see software step). Skip this, if you have a microcontroller with a button onboard.
  • Fine wire (in various colors)
  • Heat-shrink tubing
  • Power-supply 5V with 5.5/2.1 output plug
  • Case . If you manage to find a speaker of similar surface dimensions to the one I used (11cm x 4cm), then you can print a case based on the stl file I provided. Otherwise, you can improvise: A cardboard, for example, would do the job perfectly!

You can go even cheaper, by

  • scavenging a speaker from discarded electronics (I did this in my first try and then looked for something better).
  • skipping the dedicated power-supply and the 5.5/2.1bushing, and just using the microcontroller's microUSB port and a phone charger. Be sure to connect 5V/GND of the microcontroller with the Amplifier breakout and also use a powerful enough phone charger.
  • skipping the dedicated button and using the onboard one.

This way, you can drop your costs to less than $10!

Soldering the Electronics Together

DSC_4025_1200.jpg
webradio_schematic.png
IMG_20200612_162940354.jpg

You need some basic soldering skills to complete this step

Connect the power

Solder two wires on each of the 5.5/2.1 supply bushing's terminals. If you have different colors, it's not a bad idea to use red or brown for positive (5V) and black or green for negative (GND). This way, you always know which cable is voltage/positive and which is ground/negative.

Solder the other end of the cables to the ESP32 and the MAX98357A boards (see schematic).

Connect the ESP32 to the MAX98357A

as follows:

ESP pin ----------------- I2S signal
GPIO25/DAC1 --------- LRCK
GPIO26/DAC2 --------- BCLK
GPIO22 ------------------ DATA
Source: https://github.com/MrBuddyCasino/ESP32_MP3_Decode...

Miniature button

Connect the miniature button with the GPIO0 pin and GND. This is used to change between radio stations.

Speaker & Potentiometer

Connect the speaker output of MAX98357A in series with the speaker and the potentiometer.

Wrap up

After finishing, wrap everything up in heat-shrink tubing. Depending or how you plan to package your radio, you may even want to mask the back surface of the speaker with some masking tape, to avoid random electrical contacts.

Software (--> Firmware)

The software for the web radio is already available here:
https://github.com/MrBuddyCasino/ESP32_MP3_Decoder

All you have to do is:

  1. Set-up the cryptic environment for ESP development called ESP-IDF.
    The setup process varies slightly, depending on your operating system. You can find elaborate instructions here:

    https://docs.espressif.com/projects/esp-idf/en/lat...
    It's not really user-friendly, but don't let that scare you!

  2. Download or (git clone) the source code from the address above.
  3. Configure the access to your WLAN:
    make menuconfig and enter your wifi credentials.
  4. modify the Web Radios list to your preferences:
    The playlist can be found at

    ESP32_MP3_Decoder/main/playlist.pls

  5. If you have connected your own button (as opposed to using a board variant with a built-in button), you may want to replace the file web_radio.c in ESP32_MP3_Decoder/components/web_radio/ with the one provided here. I have made some modifications to prevent multiple button press events from garbling up the web radio. At least this is what happened in my case with the unmodified code.
  6. upload the whole thing to your ESP32 μcontroller:
    make and then (if build shows no errors)
    make flash. In my case, make flash did not work, but when you run make, this suggests a command (something like python ~/esp/esp-idf/components/esptool_py/esptool/esptool.py bla bla), which should work in most cases.

Downloads

Finishing

DSC_4035_1200.jpg

Put everything in the case, taking care that no conductive surfaces touch each other. For this purpose, you can use heat-shrink tubing, PVC isolating tape or even a glue pistol. A glue pistol is also needed to fix everything in position. Do this after you have tested everything and know everything is working as expected!


That was it, enjoy!