Analog radio is fading away in this digital world, as today everything from movies to songs is streamed directly from the internet. Let's see how you can make internet radio by utilizing some simple digital electronics, coding, and a working internet connection.
Internet radios can be created as standalone devices that run over the internet, or as software that runs through a computer connected to the internet. Here, we will make a standalone device that will connect to Wi-Fi, access the internet, and finally play audio. To build our ESP32 internet radio, we chose the ESP32 development board (obviously) and the MAX98357A I2S amplifier. If you are looking for a simple FM radio that can work offline, then you should check out the linked article.
Components needed to build an ESP32 Internet Radio
You will need the following components to build our Internet Radio using the ESP32. Most of the parts should be easily available.
ESP32 Development Kit
MAX98357A
8 ohm speakers rated at 0.5W to 1W.
USB cable
5V 1A charger
An active Internet connection
ESP32 and I2S Communication
As most of us know, ESP32 is an extremely low-cost, low-power system-on-chip microcontroller with integrated Wi-Fi and dual-mode Bluetooth. We have built many ESP32 projects before, and you can check them out if you are interested. However, we will not use the Bluetooth function of ESP32 here, but we still chose ESP32 for the reasons listed below.
It has Wi-Fi module
Low cost
It has I2S peripheral support.
Now, why is I2S important?
The Inter-IC Sound bus (I2S) is a serial bus interface standard for connecting digital audio devices. It is manufactured by Philips Semiconductors. This interface is most commonly used with audio ADC and DAC components.
Since to run the radio we need to use a speaker and need to produce an analog output, we need some kind of digital to analog converter. This is the interesting part of this project. The MAX98357A module. It provides a digital Class D amplifier that communicates with the microcontroller unit using a digital audio interface or I2S.
The advantages of the MAX98357A I2S module are as follows:
Efficiency up to 92%
Delivers 3.2W output power into 4 ohms at 5V
Click and pop noise reduction
Short circuit and thermal protection
Support left, right or (left/2 + right/2) output
The operating voltage is 2.5V to 5.5V.
The MAX98357A I2S module we are using in this project is shown in the image below.
Circuit diagram of MAX98357A I2S module interfacing with ESP32
The schematic is very simple. The MAX98357 connections are shown in the table below.
Since the gain pin is connected to GND, the gain is 12dB.
ESP32 Internet Radio Code
Well, this project uses the ESP32-audioI2S library available on GitHub. Before we get into the code, make sure you download the library from the following link and add it to your Arduino IDE.
ESP32 Audio I2S Library
The full code is provided at the bottom of this page, you can directly copy and use the code, but if you need its explanation, please read further.
First, include the libraries required for the project, as shown below.
#include "Arduino.h" #include "WiFi.h" #include "Audio.h"
Then, specify the pinout of the MAX98357A. If you are using the exact same module as shown above, you can leave it as shown below.
#define MAX98357A_I2S_DOUT 25 #define MAX98357A_I2S_BCLK 27 #define MAX98357A_I2S_LRC 26 Audio Audio;
Enter your Wi-Fi SSID and password, which allows the ESP32 to connect to the Internet.
String ssid = "your username"; String password = "your password";
In the settings, the WiFi password and SSID are being set, and WiFi is started. After connecting to Wi-Fi, the audio pin is selected and the volume is also set to maximum.
audio.setPinout(MAX98357A_I2S_BCLK, MAX98357A_I2S_LRC, MAX98357A_I2S_DOUT); audio.setVolume(100);
Set the streaming URL here, you can choose any streaming URL of your choice, you can also introduce a potentiometer to switch between multiple streaming channels if needed.
audio.connecttohost("http://vis.media-ice.musicradio.com/CapitalMP3"); }
After all of this, use the following code to play the audio continuously in a void loop.
void loop() { audio.loop(); }
Testing our ESP32 web radio player
The circuit is properly connected as per the schematic diagram and connected with Wi-Fi. Once the setup is started, it connects to the internet and starts streaming audio from the URL mentioned in the program.
#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
audio audio;
string ssid = "Sourav";
string password = "87654321";
void setup() {
WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());
while (WiFi.status() != WL_CONNECTED)
delay(1500);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(100);
audio.connectToHost(" http://vis.media-ice.musicradio.com/CapitalMP3 ");
}
Previous article:Build a simple musical doorbell using the UM66T melody generator
Next article:How to use Raspberry Pi to implement a Jarvis themed speaking alarm clock
- Popular Resources
- Popular amplifiers
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Serial LCD1602 using STM32-CUBE has pitfalls
- Classic experimental case of power amplifier (1) piezoelectric ceramic drive!
- Home heating effect tester
- Application of siwave in single board PI design
- Are the amplitudes of common-mode interference signals different? The results found online are different.
- What can China Space Day bring us?
- Data of intelligent pressure transmitter based on ADI's ADuC7061
- [Hua Diao Experience] 09 Series of tests on the hardware control pinpong library of Xingkong board (Part 2)
- September 29th Live Review: ON Semiconductor's Advanced Image Sensor Solutions for the Internet of Things (including video, speech...
- When it comes to setting up a development environment, do manufacturers need to put in more effort? Or do developers need more knowledge?