ESP32 C3 Internet Radio for ESP32-C3
An ESP32 display project for ESP32-C3 involving OLED display, Speaker, Rotary encoder.
Parts and sourceBefore you start
Check the exact OLED display, Speaker, Rotary encoder configuration against the upstream wiring or parts list.
Upstream README
๐ป ESP32-C3 Internet Radio v4.6
Professional ESP32-C3 Internet Radio with OLED Display and Visualizer
Advanced internet radio with web interface, 9 real-time audio visualizers, and smart power management
โจ Features โข ๐ Quick Start โข ๐ธ Gallery โข ๐ ๏ธ Build Guide
โจ Key Features
๐ต Audio Streaming
- High-quality MP3 streaming (up to 320 kbps)
- Large 128KB buffer for smooth playback on weak WiFi
- Up to 25 radio stations with instant switching
- 32-level volume control with smooth transitions
๐จ Visual Experience
- 0.91" OLED display (128ร32) with 9 visualization modes
- Real-time audio spectrum analyzer
- Station info, time, and network status display
- Auto-dimming for power saving
๐ Web Interface
- Modern responsive web UI accessible from any device
- Station management (add/edit/delete/reorder)
- Real-time system monitoring and WiFi diagnostics
- Complete configuration without reflashing
๐ง Hardware Control
- Rotary encoder (KY-040) for volume and station selection
- Single click โ next station
- Double click โ previous station
- Long press (5s) โ power off
โก Smart Features
- Automatic WiFi reconnection with signal monitoring
- Fallback WiFi network support (optional backup credentials)
- Brownout detection and recovery
- Session-based authentication
- System logs with rotation (20KB)
- FreeRTOS task management with priorities
๐ธ Gallery
Complete Device
Assembled radio - transparent case showing internal components
Web Interface
Responsive web interface - station management and controls
System configuration page with all settings
WiFi diagnostics and signal monitoring
OLED Visualizer in Action
9 different visualization modes with smooth transitions
Build Process
|
|
|
|
๐ Wiring Diagram
Connection Table:
ESP32-C3-DevKitM-1
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 3V3 โโโโโโ OLED SSD1306 VCC โ โก 3.3V
โ โ
โ 5V โโโโฌโโโ KY-040 VCC โ โก 5V
โ โโโโ MAX98357A VIN โ โก 5V
โ โ
โ GND โโโฌโโโ OLED GND โ
โ โโโโ KY-040 GND โ
โ โโโโ MAX98357A GND โ
โ โโโโ Speaker GND โ
โ โ
โ GPIO2 โโโโ KY-040 SW (button) โ ๐ Control
โ GPIO3 โโโโ KY-040 DT โ ๐ Encoder
โ GPIO10 โโโ KY-040 CLK โ ๐ Encoder
โ โ
โ GPIO4 โโโโ MAX98357A BCLK โ ๐ I2S
โ GPIO5 โโโโ MAX98357A LRC โ ๐ I2S
โ GPIO6 โโโโ MAX98357A DIN โ ๐ I2S
โ โ
โ GPIO8 โโโโ OLED SDA (I2C) โ ๐บ 400kHz
โ GPIO9 โโโโ OLED SCL (I2C) โ ๐บ 400kHz
โ โ
โ GPIO20-21 (free for expansion) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
MAX98357A โ
โโโโโโโโโโโดโโโโโโโ
โ SPK+ โโโโโโโโ โ โโ Speaker + (4-8ฮฉ)
โ SPK- โโโโโโโโ โ โโ Speaker - (3W max)
โ GAIN โโโ GND โ โโ 6dB gain
โโโโโโโโโโโโโโโโโโ
Clean soldering and wire management
Component connections close-up
๐ Bill of Materials (BOM)
Electronic Components:
| # | Component | Specification | Qty | Notes |
|---|---|---|---|---|
| 1 | ESP32-C3-DevKitM-1 | RISC-V 32-bit, 160MHz, 4MB Flash, WiFi 2.4GHz | 1 pc | Main microcontroller |
| 2 | OLED Display | 0.91" SSD1306, 128ร32, I2C, monochrome (white) | 1 pc | I2C Address: 0x3C |
| 3 | KY-040 Encoder | Rotary encoder with button, 5V | 1 pc | 20 pulses per revolution |
| 4 | MAX98357A Amplifier | I2S Class D Audio Amplifier, 3.2W @ 4ฮฉ | 1 pc | With adjustable GAIN |
| 5 | Speaker | 3W, 8ฮฉ, 40-50mm diameter | 1 pc | Or 4ฮฉ for higher volume |
Mechanical Components:
| # | Component | Specification | Qty | Notes |
|---|---|---|---|---|
| 6 | Enclosure | Acrylic box, transparent or matte | 1 pc | Size for components (~100ร70ร40mm) |
| 7 | Wires | Copper stranded, 0.25-0.5mmยฒ, colored | set | Different colors for 3.3V/5V/GND recommended |
| 8 | Solder | 60/40 or lead-free (Sn-Ag-Cu) | - | 0.5-0.8mm diameter with flux |
Optional (Additional):
| # | Component | Specification | Qty | Purpose |
|---|---|---|---|---|
| 9 | USB Cable | USB Type-C, quality, short (0.5-1m) | 1 pc | For power and flashing |
| 10 | Power Supply | 5V 2-3A, USB output | 1 pc | Recommended for stable amplifier operation |
| 11 | Heat Shrink Tubing | Various diameters, colored | set | For connection insulation |
| 12 | Screws/Standoffs | M3, plastic or brass | 4-8 pc | For mounting board in enclosure |
| 13 | Jack 3.5mm Connector | Stereo (TRS) or mono | 1 pc | Headphone option (requires modification) |
๐ฐ Estimated Cost:
| Source | Electronics | Enclosure + Misc | Optional | Total |
|---|---|---|---|---|
| AliExpress | ~$8 | ~$1-2 | - | ~$10 |
| 1688 (Taobao) | ~$4 | ~$0.5-1 | - | ~$5 |
| Local Stores (US/EU) | ~$15-20 | ~$3-5 | ~$5-8 | ~$25-35 |
๐ก Best Value: 1688.com (Taobao) - lowest prices, requires Chinese address/agent
๐ Easy Option: AliExpress - ships worldwide, good prices
โก Fast Option: Local electronics stores - same day availability
๐ฆ Where to Buy:
China (Best Prices):
- ๐จ๐ณ 1688.com (Taobao) - lowest prices (~$5 total), requires agent/Chinese address
- ๐จ๐ณ AliExpress - ships worldwide (~$10 total), 2-4 weeks delivery
- ๐จ๐ณ Banggood - alternative to AliExpress
International:
- ๐ Mouser / DigiKey - original components, fast shipping, premium prices
- ๐ Amazon - ready-made ESP32 Development Kits
- ๐ eBay - used/new components from various sellers
Local (Fastest):
- ๐ช Local electronics stores - same day pickup, technical support
- ๐ช Maker spaces - community resources, shared tools
โ๏ธ Selection Recommendations:
ESP32-C3:
- โ Get DevKitM-1 with built-in USB (no USB-UART adapter needed)
- โ ๏ธ DON'T get ESP32-C3 Mini without USB - harder to flash
OLED Display:
- โ 0.91" 128ร32 (as in project) or 0.96" 128ร64 (more info)
- โ Must be I2C interface (4 pins: VCC, GND, SCL, SDA)
- โ ๏ธ DON'T get SPI version - different pinout
Speaker:
- โ 8ฮฉ better than 4ฮฉ for USB power (lower current)
- โ 3-5W power sufficient for room
- ๐ 40-50mm size optimal for compact enclosure
MAX98357A Amplifier:
- โ Look for ready-made module (red/blue PCB)
- โ ๏ธ Check for speaker terminal connector
โ ๏ธ Important Wiring Notes
๐ซ System Pins (DO NOT USE!):
| Pins | Purpose | Note |
|---|---|---|
| GPIO0 | Boot Mode | Held low during boot = Download Mode |
| GPIO1 | USB D- | Built-in USB-UART |
| GPIO7 | Flash SPI | โ ๏ธ CRITICAL! Do not connect anything! |
| GPIO11-17 | Flash SPI | CLK, CMD, D0-D3 for Quad SPI |
| GPIO18-19 | USB D+/D- | If native USB enabled |
โก Component Power Requirements:
| Component | Voltage | Consumption | Source |
|---|---|---|---|
| ESP32-C3 | 5V (USB) | ~80-120mA | USB port or external PSU |
| OLED SSD1306 | 3.3V | ~20mA | 3V3 pin from ESP32 |
| KY-040 Encoder | 5V | ~10mA | 5V pin from ESP32 |
| MAX98357A | 5V | up to 2.5A | 5V pin from ESP32 or external PSU |
โ ๏ธ IMPORTANT: For stable amplifier operation:
- Quality USB cable (thick, short)
- USB port with โฅ1.5A current (USB 3.0 or charger)
- Or separate 5V/2A PSU for MAX98357A VIN
๐ MAX98357A Amplifier Settings:
| GAIN Connection | Gain | Volume | Recommendation |
|---|---|---|---|
| GAIN โ GND | 6dB | Quieter | For headphones/small speakers |
| GAIN floating | 9dB | Medium | Recommended default |
| GAIN โ 3.3V | 12dB | Louder | For large speakers (>4ฮฉ) |
๐ง Free Pins for Expansion:
- GPIO20, GPIO21 - available for additional sensors/indicators
๐๏ธ Features
๐น๏ธ KY-040 Encoder Control:
| Action | Function | Description |
|---|---|---|
| ๐ Rotate clockwise | Volume + | Increase by 2% steps |
| ๐ Rotate counterclockwise | Volume - | Decrease by 2% steps |
| ๐ Single click | Next station | Switch forward |
| ๐๐ Double click | Previous station | Switch backward |
| โธ๏ธ Long hold (5s) | Shutdown | Deep Sleep with animation |
Technologies:
- Quadrature decoder in interrupts (ISR)
- Hardware debounce 5ms
- Smooth volume changes
- Auto-save after 5 seconds (Flash protection)
๐บ OLED Display (128ร32, I2C 400kHz):
Info Mode (active):
- ๐ป Current radio station name
- ๐ถ WiFi status and RSSI (in dBm)
- ๐ Volume bar with smooth animation
Visualizer Mode (after 15s inactivity):
- ๐จ 9 visualization styles for audio spectrum:
- Bars - Classic vertical bars
- Wave - Scrolling wave
- Circle - Circular equalizer
- Hexagon - Cyberpunk hexagons
- Stars - Star field
- Mirror - Mirrored bars
- Lightning - Lightning between points
- Tesseract - 4D hypercube
- Plasma - Liquid plasma
Additional:
- Display rotation 180ยฐ (configurable)
- 60 FPS update (16ms)
- Audio priority (frame skip during MP3 decoding)
๐ Audio System:
Technical Specifications:
- ๐ต Format: MP3 streaming via HTTP
- ๐ Interface: I2S digital output
- ๐ฆ Buffer: 128KB with 2-second prebuffering
- ๐ Bitrate: Up to 320kbps
- ๐ Auto-switch unavailable stations
Processing Chain:
Internet โ WiFi โ MP3 Decoder โ I2S โ MAX98357A โ Speaker
โ
Visualizer (16 spectrum bands)
๐ Web Interface (http://[IP]/)
Features:
-
๐ป Station Management:
- Add/remove (up to 25 stations)
- Drag-and-drop sorting
- Import/Export list (JSON)
- Availability check
-
โ๏ธ Settings:
- ๐ Volume control (slider)
- ๐จ Visualizer style selection
- ๐ Display rotation (0ยฐ or 180ยฐ)
- ๐ถ WiFi configuration
-
๐ Monitoring:
- ๐ System logs (last 20KB)
- ๐ System status (RAM, WiFi RSSI, uptime)
- ๐ Reboot counter
-
๐ Security:
- SHA256 password hashing
- Session token (auto-login)
- Factory reset function
First Launch:
- Device creates WiFi network:
ESP32-Radio-Setup - Connect to it
- Open http://192.168.4.1
- Register username/password
- Configure WiFi and add stations
๐ก Web API Documentation
Base URL: http://[device-ip]/
Authentication: Session-based (cookie) or Token-based (X-Session-Token header)
Content-Type: application/json for JSON requests
๐ Authentication Endpoints
POST /register
Register new user (first time only)
Request Body (form-data):
username: string (required)
password: string (required)
Response:
200 OK- Registration successful400 Bad Request- Already registered
Example:
curl -X POST http://192.168.4.1/register \
-d "username=admin&password=secret123"
POST /login
Authenticate user
Request Body (form-data):
username: string (required)
password: string (required)
Response:
200 OK+ Set-Cookie: session_token401 Unauthorized- Invalid credentials
Example:
curl -X POST http://192.168.1.100/login \
-d "username=admin&password=secret123" \
-c cookies.txt
GET /logout
Logout current user
Response:
302 Redirectto/login
POST /api/forgot-password-reset
Factory reset (for forgotten password)
Response:
200 OK- All data erased, device reboots
โ ๏ธ Warning: Deletes ALL configuration files!
๐ป Station Management API
GET /api/stations/info
Get station count and limit
Response:
{
"count": 5,
"max": 25
}
GET /api/stations
Get all radio stations
Response:
[
{
"name": "Radio Paradise",
"url": "http://stream.radioparadise.com/mp3-320"
},
{
"name": "SomaFM",
"url": "http://ice1.somafm.com/groovesalad-256-mp3"
}
]
POST /api/add
Add new radio station
Request Body (form-data):
name: string (required)
url: string (required, HTTP/HTTPS URL)
Response:
200 OK- Station added400 Bad Request- Limit reached (25 stations)
Example:
curl -X POST http://192.168.1.100/api/add \
-b cookies.txt \
-d "name=Jazz FM&url=http://example.com/stream.mp3"
POST /api/delete
Delete radio station
Request Body (form-data):
name: string (required, station name)
Response:
200 OK- Station deleted
POST /api/update
Update radio station
Request Body (form-data):
originalName: string (required, old name)
name: string (required, new name)
url: string (required, new URL)
Response:
200 OK- Station updated
POST /api/stations/order
Reorder stations (drag-and-drop)
Request Body (JSON):
[
"Station Name 1",
"Station Name 2",
"Station Name 3"
]
Response:
200 OK- Order saved400 Bad Request- Invalid data
Example:
curl -X POST http://192.168.1.100/api/stations/order \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '["Jazz FM","Radio Paradise","SomaFM"]'
GET /api/stations/export
Export stations to JSON file
Response:
200 OK+stations.jsonfile download
POST /api/stations/import
Import stations from JSON file
Request: Multipart file upload
Response:
200 OK- Import successful
Example:
curl -X POST http://192.168.1.100/api/stations/import \
-b cookies.txt \
-F "file=@stations.json"
๐ฎ Player Control API
POST /api/player/next
Switch to next station
Response:
200 OK- Switched503 Service Unavailable- Queue full
POST /api/player/previous
Switch to previous station
Response:
200 OK- Switched503 Service Unavailable- Queue full
POST /api/player/volume
Set volume level
Request Body (form-data):
volume: float (0.0 - 1.0)
Response:
200 OK- Volume set
Example:
curl -X POST http://192.168.1.100/api/player/volume \
-b cookies.txt \
-d "volume=0.75"
๐บ Display Control API
GET /api/display/rotation
Get current display rotation
Response:
{
"rotation": 0
}
Values: 0 (normal) or 2 (180ยฐ)
POST /api/display/rotation
Set display rotation
Request Body (form-data):
rotation: int (0 or 2)
Response:
200 OK- Rotation set
๐จ Visualizer API
GET /api/visualizer/style
Get current visualizer style
Response:
{
"style": 3,
"name": "Hexagon"
}
POST /api/visualizer/style
Set visualizer style
Request Body (form-data):
style: int (0-8)
Styles:
0- Bars (Classic vertical bars)1- Wave (Scrolling wave)2- Circle (Circular equalizer)3- Hexagon (Cyberpunk hexagons)4- Stars (Star field)5- Mirror (Mirrored bars)6- Lightning (Lightning between points)7- Tesseract (4D hypercube)8- Plasma (Liquid plasma)
Response:
200 OK- Style set
GET /api/visualizer/styles
Get all available styles
Response:
[
{"id": 0, "name": "Bars"},
{"id": 1, "name": "Wave"},
{"id": 2, "name": "Circle"},
{"id": 3, "name": "Hexagon"},
{"id": 4, "name": "Stars"},
{"id": 5, "name": "Mirror"},
{"id": 6, "name": "Lightning"},
{"id": 7, "name": "Tesseract"},
{"id": 8, "name": "Plasma"}
]
โ๏ธ System API
GET /api/logs
Get system logs
Response:
200 OK- Plain text logs (last 20KB)
Example:
curl http://192.168.1.100/api/logs -b cookies.txt
POST /api/system/reboot
Reboot device
Response:
200 OK- Rebooting...503 Service Unavailable- Queue full
POST /api/factory-reset
Factory reset (requires password)
Request Body (form-data):
password: string (required)
Response:
200 OK- Factory reset complete (device reboots)401 Unauthorized- Wrong password
โ ๏ธ Warning: Deletes WiFi, stations, credentials, state, logs!
๐ถ WiFi API (AP Mode Only)
Available only when device is in Access Point mode (ESP32-Radio-Setup)
GET /api/scan
Start WiFi network scan
Response:
200 OK- Scan Started
GET /api/scan-results
Get scan results
Response:
202 Accepted- Scanning... (not ready yet)200 OK- JSON array of networks
Example Response:
[
{"ssid": "MyWiFi", "rssi": -45, "encryption": "WPA2"},
{"ssid": "Neighbor WiFi", "rssi": -78, "encryption": "WPA2"}
]
POST /save
Save WiFi credentials and switch to STA mode
Request Body (form-data):
ssid: string (from scan) OR ssid_manual: string
password: string (WiFi password)
username: string (web login)
web_password: string (web password)
Response:
200 OK- Connecting to WiFi...400 Bad Request- Missing parameters
Example:
curl -X POST http://192.168.4.1/save \
-d "ssid=MyWiFi&password=wifi123&username=admin&web_password=secret"
๐ Authentication Methods
Method 1: Cookie-based (recommended for browsers)
# Login and save cookie
curl -X POST http://192.168.1.100/login \
-d "username=admin&password=secret" \
-c cookies.txt
# Use cookie for subsequent requests
curl http://192.168.1.100/api/stations -b cookies.txt
Method 2: Token-based (for scripts/apps)
# Get token from login cookie
TOKEN="your-session-token-here"
# Use token in header
curl http://192.168.1.100/api/stations \
-H "X-Session-Token: $TOKEN"
โก Rate Limiting & Best Practices
-
Queue System: Some commands (reboot, player control) use FreeRTOS queues
- If queue is full, you'll get
503 Service Unavailable - Wait 100-200ms between rapid commands
- If queue is full, you'll get
-
File Operations: Import/export may take 1-2 seconds
- Don't spam these endpoints
-
Authentication: Session tokens are checked on every request
- Tokens are cleared every 25 reboots for security
- Use
/logoutto explicitly clear session
-
Error Handling:
401 Unauthorized- Not logged in or invalid token400 Bad Request- Missing/invalid parameters503 Service Unavailable- System busy/queue full
-
Concurrent Requests: Async web server supports multiple connections
- But be careful with state-changing operations (add/delete/reorder)
๐ Complete Example: Python Script
import requests
class ESP32Radio:
def __init__(self, ip):
self.base_url = f"http://{ip}"
self.session = requests.Session()
def login(self, username, password):
r = self.session.post(f"{self.base_url}/login",
data={"username": username, "password": password})
return r.status_code == 200
def get_stations(self):
r = self.session.get(f"{self.base_url}/api/stations")
return r.json()
def add_station(self, name, url):
r = self.session.post(f"{self.base_url}/api/add",
data={"name": name, "url": url})
return r.status_code == 200
def set_volume(self, volume): # 0.0 - 1.0
r = self.session.post(f"{self.base_url}/api/player/volume",
data={"volume": volume})
return r.status_code == 200
def next_station(self):
r = self.session.post(f"{self.base_url}/api/player/next")
return r.status_code == 200
# Usage
radio = ESP32Radio("192.168.1.100")
if radio.login("admin", "secret"):
print("Stations:", radio.get_stations())
radio.set_volume(0.7)
radio.next_station()
๐ Power Management:
-
Deep Sleep Mode:
- Long button hold (5 seconds)
- Shutdown animation with progress bar
- State saving (volume, station, settings)
- Wake-up: encoder button press
- Sleep consumption: ~10ยตA
-
WiFi Optimization:
- Power save disabled (for streaming)
- Maximum transmitter power (19.5dBm)
- Automatic reconnect
- Fallback WiFi network support (optional backup credentials)
๐ก๏ธ Protection and Recovery:
WiFi Recovery (4-level system):
- Auto-reconnect (0-40s): Wait for WiFi.setAutoReconnect()
- Manual reconnect (40-90s): Force reconnection to primary network
- Fallback network (optional): Automatic switch to backup WiFi if primary fails
- Reboot (5s countdown): If all recovery attempts fail
Brown-out Detector:
- Trigger threshold: 2.51V
- Automatic reboot on power drop
- Event logging with recommendations
Flash Memory Protection:
- LittleFS filesystem
- Volume save debounce (5 seconds)
- Log rotation (max 20KB)
- Auto-clear sessions (every 25 reboots)
๐พ Technical Specifications
Microcontroller:
- Model: ESP32-C3-DevKitM-1
- Architecture: RISC-V 32-bit single-core
- CPU Frequency: 160 MHz
- RAM: ~400KB
- Flash: 4MB (partition: 2.5MB app + 1.4MB filesystem)
- WiFi: 2.4GHz 802.11 b/g/n
Filesystem:
- Type: LittleFS
- Size: 1440KB
- Files:
/wifi.json- WiFi credentials (primary + fallback)/stations.json- Radio station list (up to 25)/credentials.json- Web interface login/password (SHA256)/state.json- State (volume, station, visualizer)/log.txt- System logs (20KB rotation)
Libraries Used:
- ESP8266Audio - MP3 decoder + I2S
- Adafruit SSD1306 v2.5.9 - OLED display
- Adafruit GFX v1.11.9 - Graphics
- ArduinoJson v7.0.4 - JSON parsing
- ESPAsyncWebServer v3.2.2 - Web server
- AsyncTCP v2.1.3 - TCP stack
๐ Installation and Flashing
๐ก IMPORTANT: What needs to be uploaded to ESP32
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ESP32-C3 FLASH (4MB) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ 1๏ธโฃ PROGRAM CODE (C++) โ โ
โ โ โ โ
โ โ ๐น Application logic โ โ
โ โ ๐น Audio decoder (MP3) โ โ
โ โ ๐น WiFi connectivity โ โ
โ โ ๐น Encoder control โ โ
โ โ โ โ
โ โ ๐ฆ pio run --target upload โ โ
โ โ ๐ฆ "Upload" button โ in VS Code โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ 2๏ธโฃ FILESYSTEM (LittleFS) โ โ
โ โ โ โ
โ โ ๐น Web interface (HTML/CSS/JS) โ โ
โ โ ๐น Station management โ โ
โ โ ๐น System settings โ โ
โ โ ๐น Logs and monitoring โ โ
โ โ โ โ
โ โ ๐ฆ pio run --target uploadfs โ โ
โ โ ๐ฆ "Upload Filesystem" button ๐ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ด CRITICAL: Both parts are required for full functionality!
Without uploadfs the device will boot, but there will be no web interface.
๐ Requirements:
- VS Code - https://code.visualstudio.com/
- PlatformIO IDE extension - install from VS Code Extensions
- USB cable Type-C for ESP32-C3
- Driver (usually installs automatically)
๐ฏ Method 1: VS Code + PlatformIO IDE (RECOMMENDED)
The easiest way for beginners!
Step 1: Install Extension
- Open VS Code
- Press
Ctrl+Shift+X(Extensions) - Find "PlatformIO IDE"
- Click Install
- Restart VS Code
Step 2: Open Project
- Click
FileโOpen Folder... - Select the project folder (where
platformio.iniis) - PlatformIO will automatically install all libraries (wait 1-2 minutes)
Step 3: Flash the Device
โ ๏ธ IMPORTANT: pio commands DON'T WORK in VS Code's regular terminal!
Use PlatformIO buttons at the bottom of the screen:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ โ โ ๐๏ธ ๐ ๐บ ๐ โ๏ธ โ โ Bottom panel
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ โ โ โ โ
โ โ โ โ โ โ โโ Settings
โ โ โ โ โ โโโโโโ Serial Monitor
โ โ โ โ โโโโโโโโโโโโ Upload Filesystem (LittleFS)
โ โ โ โโโโโโโโโโโโโโโโโโโ Upload (firmware)
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโ Clean
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Build
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ PlatformIO Home
Step-by-step instructions:
-
Connect ESP32 to computer via USB
-
Click "Upload" button (arrow โ)
- Firmware flashing starts
- Takes ~30 seconds
- You'll see:
SUCCESSin terminal
-
Click "Upload Filesystem" button (folder icon ๐)
- LittleFS flashing starts (web interface)
- Takes ~20 seconds
- You'll see:
SUCCESS
-
Click "Serial Monitor" button (plug icon ๐บ)
- Console with logs will open
- You'll see the device IP address
โ
Done! Open browser: http://[IP-address]/
๐ฏ Method 2: VS Code Command Palette
If buttons are not visible:
- Press
Ctrl+Shift+P(Command Palette) - Type command:
PlatformIO: Upload โ Flash firmware
PlatformIO: Upload File System โ Flash LittleFS
PlatformIO: Serial Monitor โ Open console
PlatformIO: Clean โ Clean (if errors)
๐ฏ Method 3: Command Line (if PlatformIO already installed)
โ ๏ธ Works ONLY if PlatformIO Core is already in PATH!
# Clone repository
git clone https://github.com/makepkg/ESP32-C3-Internet-Radio.git
cd ESP32-C3-Internet-Radio
# โ ๏ธ TWO COMMANDS REQUIRED!
pio run --target upload # 1. Flash firmware (.cpp/.h)
pio run --target uploadfs # 2. Flash filesystem (data/)
# Console (optional)
pio device monitor -b 115200
๐ด CRITICALLY IMPORTANT: Device WON'T WORK if you flash only one part!
upload- program code (C++)uploadfs- web interface (HTML/CSS/JS)
Without uploadfs there will be no web control panel!
๐ฏ Method 4: Direct PlatformIO Core Installation (without VS Code)
For those who don't want VS Code but want pio commands in terminal
Step 1: Install Python 3
Linux (Ubuntu/Debian):
sudo apt update
sudo apt install python3 python3-pip python3-venv
Mac:
# Via Homebrew
brew install python3
Windows:
- Download: https://www.python.org/downloads/
- Install with "Add Python to PATH" checkbox enabled
Step 2: Install PlatformIO Core
# Installation
pip3 install platformio
# Verify
pio --version
# Should output: PlatformIO Core, version X.X.X
If pio command not found:
Linux/Mac:
# Add to ~/.bashrc or ~/.zshrc:
echo 'export PATH=$PATH:~/.local/bin' >> ~/.bashrc
source ~/.bashrc
# Or manually add line:
export PATH=$PATH:~/.local/bin
Windows:
# Add to PATH via System Environment Variables:
C:\Users\<Name>\AppData\Roaming\Python\PythonXX\Scripts
# Or reboot computer
Step 3: Flashing
# Clone project
git clone https://github.com/makepkg/ESP32-C3-Internet-Radio.git
cd ESP32-C3-Internet-Radio
# Connect ESP32 via USB
# ๐ด TWO COMMANDS REQUIRED!
# 1๏ธโฃ Flash firmware (main program)
pio run --target upload
# Takes ~30 seconds, should output: SUCCESS
# 2๏ธโฃ Flash filesystem (web interface)
pio run --target uploadfs
# Takes ~20 seconds, should output: SUCCESS
# 3๏ธโฃ Check operation (optional)
pio device monitor -b 115200
# You'll see logs and IP address
# Exit: Ctrl+C
โ
Done! Open browser: http://[IP-address]/
โ ๏ธ VERY IMPORTANT WARNING
๐ด BOTH firmware parts MUST be uploaded!
| Command / Button | What's uploaded | Why needed |
|---|---|---|
Upload โ / pio run --target upload |
Program code C++ | Logic, audio, WiFi |
Upload Filesystem ๐ / pio run --target uploadfs |
Files in data/ |
Web interface (HTML/CSS/JS) |
What happens if you skip uploadfs:
- โ No web interface
- โ Cannot add stations
- โ No browser control
- โ Only encoder works (if stations were added before)
๐ก Remember:
upload + uploadfs = COMPLETE WORKING FIRMWARE โ
๐ ๏ธ Troubleshooting
โ "Port not found" / "Device not detected"
Linux:
# Add user to dialout group
sudo usermod -a -G dialout $USER
# Reboot computer!
# Or manually:
sudo chmod 666 /dev/ttyACM0
Windows:
- Install CH340/CP2102 driver
- Check Device Manager โ Ports (COM & LPT)
Mac:
# Driver usually not needed
ls /dev/cu.* # Find port (e.g. /dev/cu.usbserial-*)
โ "Timed out waiting for packet header"
- Hold BOOT button on ESP32
- While holding, click Upload in VS Code
- Release BOOT when you see "Connecting..."
โ PlatformIO doesn't install libraries
- Press
Ctrl+Shift+P - Type:
PlatformIO: Rebuild IntelliSense Index - Wait 2-3 minutes
โ "Upload Filesystem" doesn't work
In platformio.ini must have:
board_build.filesystem = littlefs
๐ Project Structure
esp32-radio/
โโโ src/ โ Source code (.cpp/.h)
โโโ data/ โ Files for LittleFS (HTML/CSS/JS)
โโโ include/ โ Header files
โโโ lib/ โ Local libraries
โโโ platformio.ini โ PlatformIO configuration
โโโ README.md โ This guide
Important files:
data/index.html- web interfacesrc/main.cpp- main fileplatformio.ini- firmware settings
๐ Updating Firmware
After changing code:
- Changed
.cpp/.hfiles? โ Click Upload (โ) - Changed
data/files? โ Click Upload Filesystem (๐) - Changed both? โ Click both in sequence
๐ก Tip: Upload Filesystem is only needed when web interface changes!
๐ Debugging
Debug mode enabled by default:
-DCORE_DEBUG_LEVEL=3 # Verbose logging
View logs:
- Serial monitor (115200 baud)
- Web interface โ "System logs"
Check reset cause:
- Logged automatically at startup
- Includes brown-out detection
- Shows watchdog timeouts
๐ Additional Information
Performance Optimizations:
- CPU: 160 MHz (maximum)
- Flash: 80 MHz QOUT mode
- I2C: 400 kHz Fast Mode
- Task prioritization: Audio > Input > Display > WiFi > System
- IRAM attributes on critical functions
- Atomic flags for task coordination
Known Limitations:
- Maximum 25 radio stations (can increase in config.h)
- MP3 format only (AAC/FLAC not supported)
- Display 128ร32 (larger displays need code adaptation)
- Single WiFi network (no backup networks)
โค๏ธ Support the Project
If you like this project and want to support its development, you can do so in the following ways:
Cryptocurrency Donations:
-
USDT BEP-20 (Binance Smart Chain):
0xd03499C9c6100Af624603b4D6fb185A65694745C -
USDT TRC-20 (Tron):
TUAzeSrKeDYbt6HCs9PL6q1t5amHHdnnwR -
USDT SOL (Solana):
2cecCCh8pzUNmEpjLQ3aa9sfPL5KXqANrmSfiiDWubCj
Your support is very important and helps me continue working on open-source projects!
โญ Star this repository if you find it useful!
๐ Check out my other projects:
- ESP32-T-Display-TOTP - TOTP Authenticator on ESP32
Version: v4.5 (Stable Architecture)
Last Update: 2025-10-15
License: MIT
Author: makepkg
All components laid out
Assembly process animation - soldering and connections
Finished device in transparent enclosure