{"id":15048853,"url":"https://github.com/heaven-waves/peripheral-node","last_synced_at":"2026-01-01T23:03:42.103Z","repository":{"id":255534542,"uuid":"850929219","full_name":"Heaven-Waves/peripheral-node","owner":"Heaven-Waves","description":"Code to be run on ESP32-LyraT V4.3 boards as periheral nodes 🕹️","archived":false,"fork":false,"pushed_at":"2024-09-20T18:26:00.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T23:44:14.389Z","etag":null,"topics":["audio","c-language","esp-adf","esp32","peripheral","streaming"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Heaven-Waves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-02T05:27:49.000Z","updated_at":"2024-09-20T18:26:03.000Z","dependencies_parsed_at":"2024-11-19T16:41:17.957Z","dependency_job_id":"8b352174-4b8c-407d-b017-b2f1f5e0c228","html_url":"https://github.com/Heaven-Waves/peripheral-node","commit_stats":{"total_commits":52,"total_committers":1,"mean_commits":52.0,"dds":0.0,"last_synced_commit":"55cd7dd3a031173a81db1e2976252300a0799a96"},"previous_names":["heaven-waves/peripheral-node"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Heaven-Waves%2Fperipheral-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Heaven-Waves%2Fperipheral-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Heaven-Waves%2Fperipheral-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Heaven-Waves%2Fperipheral-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Heaven-Waves","download_url":"https://codeload.github.com/Heaven-Waves/peripheral-node/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243500771,"owners_count":20300770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","c-language","esp-adf","esp32","peripheral","streaming"],"created_at":"2024-09-24T21:16:52.179Z","updated_at":"2026-01-01T23:03:42.096Z","avatar_url":"https://github.com/Heaven-Waves.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Peripheral Node 🕹️\n\nReal-time Opus audio streaming receiver for the [ESP32-LyraT V4.3](https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/get-started-esp32-lyrat.html) development board. This peripheral node receives Opus-encoded audio streams over UDP multicast and plays them through the I2S audio output.\n\n\u003cp align=\"center\"\u003e\n\u003cimg\n    alt=\"ESP32-LyraT V4.3 board\"\n    src=\"https://raw.githubusercontent.com/Heaven-Waves/assets/main/img/ESP32-LyraT_V4.3.png\"\n    width=\"600\"\n    \u003e\n\u003c/p\u003e\n\n## Features\n\n- **Real-time Audio Streaming**: Receives UDP multicast audio packets with low latency\n- **Opus Audio Decoding**: Hardware-accelerated Opus codec decoding (48kHz stereo)\n- **RTP Protocol Support**: Parses RTP headers to extract audio payload\n- **Robust WiFi Handling**: Automatic reconnection and event-driven network management\n- **Dual-Core Utilization**: UDP receiver on core 1, I2S playback on core 0\n- **Memory Optimized**: Uses external PSRAM for extended memory allocation\n- **Configurable Parameters**: WiFi, network, and audio settings via menuconfig\n\n## Architecture\n\n```\nUDP Multicast (224.1.1.1:5005)\n    ↓\nRTP Packet Reception\n    ↓\nRTP Header Parsing\n    ↓\nOpus Payload Extraction\n    ↓\nOpus Decoder (48kHz Stereo)\n    ↓\nPCM Audio Buffer\n    ↓\nRing Buffer (8KB)\n    ↓\nI2S Writer Element\n    ↓\nES8388 Audio Codec\n    ↓\nSpeaker/Headphone Output\n```\n\n## Hardware Requirements\n\n- **Board**: ESP32-LyraT V4.3\n- **Microcontroller**: ESP32 (dual-core Xtensa)\n- **Audio Codec**: ES8388\n- **Memory**: 520KB SRAM + 4MB PSRAM\n- **Flash**: 8MB\n- **Network**: WiFi 802.11 b/g/n\n\n## Software Requirements\n\n- **ESP-IDF**: v5.3.1 (Espressif IoT Development Framework)\n- **ESP-ADF**: v2.7 (Audio Development Framework)\n- **Build Tools**: CMake, Make\n- **Compiler**: xtensa-esp32-elf-gcc (esp-13.2.0)\n\n## Getting Started\n\n### 1. Install Prerequisites\n\nFollow the [ESP-IDF installation guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html) to set up ESP-IDF v5.3.1.\n\nInstall ESP-ADF v2.7:\n```bash\ncd ~/esp\ngit clone --recursive https://github.com/espressif/esp-adf.git\ncd esp-adf\ngit checkout v2.7\n```\n\n### 2. Clone Repository\n\n```bash\ngit clone \u003crepository-url\u003e\ncd peripheral-node\n```\n\n### 3. Configure the Project\n\n```bash\nidf.py menuconfig\n```\n\nNavigate to configure:\n\n**WiFi Configuration**:\n- SSID: Your WiFi network name\n- Password: Your WiFi password\n\n**Audio Streaming Configuration**:\n- Multicast IP: Default `224.1.1.1`\n- UDP Port: Default `5005`\n- Sample Rate: Default `48000` Hz\n- Bits per Sample: Default `16`\n- Channels: Default `2` (stereo)\n\n**Opus Configuration**:\n- Frame Size: Default `960` samples (20ms at 48kHz)\n- Max Packet Size: Default `2048` bytes\n- Jitter Buffer Size: Default `2048` bytes\n\n### 4. Build and Flash\n\n```bash\n# Build the project\nidf.py build\n\n# Flash to the ESP32-LyraT board\nidf.py -p /dev/ttyUSB0 flash\n\n# Monitor output (optional)\nidf.py -p /dev/ttyUSB0 monitor\n```\n\nPress `Ctrl+]` to exit the monitor.\n\n### 5. Flash and Monitor in One Command\n\n```bash\nidf.py -p /dev/ttyUSB0 flash monitor\n```\n\n## Configuration Options\n\nAll configuration options are accessible via `idf.py menuconfig`:\n\n### WiFi Settings\n- `WIFI_SSID`: WiFi network name (default: \"YourWiFiSSID\")\n- `WIFI_PASSWORD`: WiFi password (default: \"YourWiFiPassword\")\n\n### Network Settings\n- `MULTICAST_IP`: Multicast group address (default: \"224.1.1.1\")\n- `UDP_PORT`: UDP port number (default: 5005)\n\n### Audio Settings\n- `AUDIO_SAMPLE_RATE`: Sample rate in Hz (default: 48000)\n- `BITS_PER_SAMPLE`: Bits per sample (default: 16)\n- `AUDIO_CHANNELS`: Number of channels 1-2 (default: 2)\n\n### Opus Decoder Settings\n- `OPUS_FRAME_SIZE`: Frame size in samples (default: 960)\n- `MAX_PACKET_SIZE`: Maximum packet size (default: 2048)\n- `JITTER_BUFFER_SIZE`: Jitter buffer size (default: 2048)\n\n## Project Structure\n\n```\nperipheral-node/\n├── main/\n│   ├── main.c                    # Main application logic\n│   ├── Kconfig.projbuild         # Configuration menu definitions\n│   └── idf_component.yml         # Component dependencies\n├── components/\n│   ├── logs/                     # Custom logging component\n│   │   ├── logs.h\n│   │   └── logs.c\n│   └── pipeline/                 # Audio pipeline wrapper component\n│       ├── pipeline.h\n│       └── pipeline.c\n├── partitions.csv                # Flash partition table\n├── sdkconfig.defaults            # Default build configuration\n├── CMakeLists.txt                # Root CMake file\n├── dependencies.lock             # Locked component versions\n└── README.md                     # This file\n```\n\n## Key Components\n\n### Main Application (main/main.c)\n\nThe main application orchestrates:\n- WiFi connection and management\n- UDP multicast socket setup\n- RTP packet reception and parsing\n- Opus audio decoding\n- I2S audio output via ring buffer\n\n**Key Functions**:\n- `wifi_init_sta()`: Initialize WiFi in station mode\n- `setup_udp_multicast()`: Create UDP socket and join multicast group\n- `get_rtp_payload()`: Parse RTP headers and extract Opus payload\n- `udp_receiver_task()`: Main receiver task (runs on core 1)\n- `setup_audio_pipeline()`: Initialize I2S audio output with ring buffer\n\n### Custom Components\n\n**logs**: Simplified logging interface\n- `logi()`, `loge()`, `logw()` functions\n- Consistent \"PERIPHERAL_NODE\" tag\n\n**pipeline**: Audio pipeline wrapper (ESP-ADF)\n- Simplified API for pipeline management\n- Functions for init, deinit, register, link, run, stop\n\n## Hardware Configuration\n\n### I2S Configuration\n- **Port**: I2S_NUM_0\n- **Sample Rate**: 48000 Hz (configurable)\n- **Channels**: 2 (Stereo, configurable)\n- **Bits per Sample**: 16-bit (configurable)\n- **Mode**: Slave mode, normal I2S format\n\n### Audio Codec (ES8388)\n- **Input**: LINE1\n- **Output**: All outputs enabled\n- **Mode**: Decode only (playback)\n- **Volume**: 100%\n\n### Memory Configuration\n- **PSRAM**: Enabled with malloc support\n- **Ring Buffer**: 8KB for I2S input\n- **Static Buffers**: PCM (8KB), UDP receive (512B)\n- **Stack**: Allocated in external memory\n\n### Network Configuration\n- **WiFi Buffers**: 10 static, 32 dynamic RX/TX\n- **LWIP Receive Buffer**: 8KB\n- **Multicast**: Enabled\n\n## Performance\n\n- **CPU Frequency**: 240 MHz\n- **FreeRTOS Tick Rate**: 1000 Hz\n- **Task Watchdog**: 10 seconds\n- **Latency**: Optimized for real-time streaming\n- **Memory Usage**: Monitored with heap tracking\n\n## Monitoring and Debugging\n\nThe application provides detailed logging:\n- Packet reception statistics\n- Ring buffer fill levels\n- Memory usage (heap monitoring)\n- Packet content inspection (first 8 bytes)\n- I2S element state tracking\n\nSet log level in menuconfig:\n```\nComponent config → Log output → Default log verbosity\n```\n\n## Troubleshooting\n\n### WiFi Connection Issues\n- Verify SSID and password in menuconfig\n- Check WiFi signal strength\n- Monitor logs for connection events\n\n### No Audio Output\n- Verify multicast IP and port match sender\n- Check audio codec initialization in logs\n- Ensure ring buffer is receiving data\n- Verify I2S configuration matches sender format\n\n### Memory Issues\n- Monitor heap usage in logs\n- Adjust ring buffer size if needed\n- Check PSRAM is properly initialized\n\n### Packet Loss\n- Increase WiFi buffer sizes in sdkconfig.defaults\n- Adjust jitter buffer size\n- Check network congestion\n\n## Development\n\n### VSCode Setup\n\nThe project includes VSCode configuration for ESP-IDF extension:\n- C/C++ IntelliSense configured\n- Build and flash tasks available\n- Serial monitor integration\n\n### Adding Custom Components\n\n1. Create component directory under `components/`\n2. Add `CMakeLists.txt` with `idf_component_register()`\n3. Implement your component logic\n4. Include in main application\n\n### Modifying Audio Pipeline\n\nThe audio pipeline can be customized in `setup_audio_pipeline()` in main/main.c:\n- Change sample rate/channels\n- Add audio effects\n- Modify ring buffer size\n- Add additional audio elements\n\n## Future Enhancements\n\n- Forward Error Correction (FEC) support\n- Multiple codec support (AAC, MP3)\n- Adaptive bitrate streaming\n- Web-based configuration interface\n- OTA (Over-The-Air) firmware updates\n- Multi-room synchronization\n\n## License\n\nPart of a thesis project on distributed audio systems.\n\n## References\n\n- [ESP-IDF Documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/)\n- [ESP-ADF Documentation](https://docs.espressif.com/projects/esp-adf/en/latest/)\n- [ESP32-LyraT V4.3 Guide](https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/get-started-esp32-lyrat.html)\n- [Opus Codec](https://opus-codec.org/)\n- [RTP Protocol (RFC 3550)](https://datatracker.ietf.org/doc/html/rfc3550)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheaven-waves%2Fperipheral-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheaven-waves%2Fperipheral-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheaven-waves%2Fperipheral-node/lists"}