Skip to content

Arun-R-S/ESP8266-ESP32-AudioSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

78 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ESP8266 / ESP32 Audio System Controller

License Stars Issues Release Downloads PlatformIO

Contributions Welcome


πŸš€ Project Status:

Under Development

⚠️Caution!! This project is currently Work in Progress (WIP).
Features, APIs, and structure may change rapidly until the first stable release.


πŸ”₯ Overview

This project is a highly modular, configurable, and extensible firmware for ESP8266/ESP32 microcontrollers designed to control audio ICs like TDA7439, PT2313, PT2322, and others via I2C. It features support for physical button control, LCD displays, web UI (future), EEPROM/Flash settings storage, and preset management β€” all following clean architecture, SOLID principles, and professional coding practices.

🎯 Features

  • βœ… Audio IC Control
    • Volume, Bass, Treble, Balance, Loudness, Input Selection
  • βœ… Hardware Abstraction Layer (HAL)
    • Abstracts I2C, EEPROM, Logging, Display, etc.
  • βœ… Drivers Layer
    • Drivers for audio ICs (e.g., TDA7439) with clean APIs
  • βœ… UI/UX Support
    • Physical buttons and 16x2 I2C LCD
    • Future-proof for Web UI
  • βœ… Configuration Management
    • No hardcoded pins, fully configurable
    • Settings stored in EEPROM/Flash with CRC validation
  • βœ… Presets Management
    • Save and switch multiple audio presets
  • βœ… Centralized Logging
    • Supports different log levels with tagged logs
  • βœ… Error Handling
    • Error codes, retries, fallback handling for I2C failures
  • βœ… Cross-Platform Support
    • Works with both ESP8266 and ESP32
  • βœ… Storage System
    • Binary data storage with integrity checks

πŸ“ Folder Structure

ESP8266-ESP32-AudioSystem/
β”‚
β”œβ”€β”€ boards/            β†’ Board-specific configurations
β”œβ”€β”€ config/            β†’ Default and custom configurations
β”œβ”€β”€ core/              β†’ Core logic (SettingsManager, Logger, I2CManager)
β”œβ”€β”€ drivers/
β”‚   └── audio/         β†’ Audio IC drivers (e.g., TDA7439.cpp)
β”œβ”€β”€ filesystem/        β†’ Persistent storage handling (EEPROM/Flash)
β”œβ”€β”€ hal/               β†’ Hardware Abstraction Layer (I2C, Display, etc.)
β”œβ”€β”€ presets/           β†’ Preset management (save, load)
β”œβ”€β”€ services/          β†’ Business logic services (AudioService, etc.)
β”œβ”€β”€ ui/
β”‚   β”œβ”€β”€ display/       β†’ LCD UI
β”‚   └── web/           β†’ Future Web UI
β”œβ”€β”€ utils/             β†’ Utilities (CRC, helpers)
β”œβ”€β”€ include/           β†’ Header files
β”œβ”€β”€ src/               β†’ Main application entry point
β”œβ”€β”€ platformio.ini     β†’ PlatformIO build configuration
└── README.md          β†’ This file

βš™οΈ Supported Hardware

Microcontroller Supported
ESP8266 (NodeMCU, Wemos D1) βœ…
ESP32 (DevKit, Wroom, Wrover) βœ…
Audio IC Status
TDA7439 βœ… Complete
PT2313 πŸ”œ Planned
PT2322 πŸ”œ Planned
UI Status
16x2 LCD (I2C) πŸ”œ (Planned)
Web UI πŸ”œ (Planned)
Push Buttons πŸ”œ (Planned)

πŸš€ Getting Started

πŸ›  Prerequisites

  • PlatformIO with VSCode (Recommended)
  • ESP8266 or ESP32 board
  • Audio IC (e.g., TDA7439) wired over I2C
  • Optional: 16x2 I2C LCD Display, push buttons

πŸ“₯ Installation

  1. Clone the repo:
git clone https://github.com/Arun-R-S/ESP8266-ESP32-AudioSystem.git
cd ESP8266-ESP32-AudioSystem
  1. Install dependencies via PlatformIO (auto resolves).

  2. Edit platformio.ini to select your board.

  3. Configure pins and settings:

// config/BoardConfig.h

#define I2C_SDA_PIN  D2
#define I2C_SCL_PIN  D1
#define LCD_ADDRESS  0x27
#define AUDIO_I2C_ADDRESS 0x44

πŸ”₯ Build & Upload

  • Build and upload:
pio run --target upload
  • Open serial monitor:
pio device monitor

🎨 Example Usage

  • Adjust Volume:
AudioService.SetVolume(10);
  • Change Bass:
AudioService.SetBass(5);
  • Switch Input:
AudioService.SetInput(2);
  • Save Preset:
PresetManager.SavePreset(1);
  • Load Preset:
PresetManager.LoadPreset(1);

πŸ“ Configuration Example

// config/SettingsStruct.h

struct AudioSettings {
    uint8_t volume;
    uint8_t bass;
    uint8_t treble;
    uint8_t balance;
    bool loudness;
    uint8_t inputSource;
};

πŸ”§ Settings Storage

  • Settings are stored in Flash/EEPROM with CRC32 validation.
  • On corruption, factory defaults are restored.
  • Supports versioning for future updates.

🚦 Logging System

  • Log Levels: DEBUG, INFO, WARN, ERROR
  • Usage:
Logger(INFO, "Audio", "Volume set to %d", volume);

πŸ’‘ Error Handling

  • Retry mechanism on I2C failures.
  • Return error codes for hardware failures.
  • Fallback to defaults if storage fails.

πŸ›‘οΈ Coding Principles

  • βœ… Clean Code
  • βœ… SOLID Principles
  • βœ… No hardcoded pins β€” fully configurable
  • βœ… Modular architecture
  • βœ… Separation of concerns
  • βœ… Extensible for new ICs, UIs, or features

πŸ—οΈ Architecture Diagram

+------------------------+
|       Main App         |
+-----------+------------+
            ↓
+-----------+------------+
|         Services        |
+-----------+------------+
            ↓
+------+    +------+    +------+
| HAL  |    | Drivers|  | UI   |
+------+    +------+    +------+
            ↓
       +-----------+
       | Hardware   |
       +-----------+

πŸ—ΊοΈ Roadmap

  • TDA7439 Driver
  • LCD + Button UI
  • Web UI Interface
  • PT2313 and PT2322 Drivers
  • MQTT/HTTP API
  • OTA Update Support

🀝 Contribution

Contributions are welcome!

  1. Fork this repository
  2. Create your feature branch (git checkout -b feature/awesome)
  3. Commit your changes (git commit -m 'Add awesome feature')
  4. Push to the branch (git push origin feature/awesome)
  5. Open a Pull Request

πŸ›‚ Contributors

Contributors

πŸ“œ License

This project is licensed under the MIT License β€” see the LICENSE file for details.

πŸ’– Acknowledgements

  • Inspired by Tasmota's robust configuration and storage mechanism.
  • Thanks to the open-source community for drivers and libraries.

πŸš€ Let's Build Something Awesome Together!


⭐ If you like this project, don’t forget to star it on GitHub!

About

Modular firmware for ESP8266/ESP32 to control audio ICs like TDA7439 via I2C with presets & UI.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages