ayatec logo
Home Store Blog Contact
unicontrol user guide by ayatec
Home Store Blog Contact

Topics

  1. Welcome
  2. Getting started
    1. What is unicontrol
    2. How it works
    3. Connectivity
    4. Integration options
    5. Basic I/O
    6. Special I/O
    7. Special inputs - Digital sensors
    8. Special outputs - RGB driver
    9. Special outputs - Audio driver
    10. Network API - HTTP
    11. Network API - MQTT
    12. Network security
    13. Downloads
  3. Web Interface
    1. Processes
      1. Process
      2. Name
      3. Main state
      4. Initial state
      5. Display
      6. Constraints
        1. Process timer
        2. Variable contraints
        3. Force output
      7. Input
        1. Input source
        2. Channel
        3. Control period
        4. Value
        5. Publish
        6. Frequency
        7. Subtopic
      8. Events
        1. On/Off event
        2. Condition
        3. Idle/running time
        4. Delay on/off
        5. Fade in/out
        6. High/low input
        7. Mid point/Tolerance
        8. Out on when
      9. Output
        1. Primary output
        2. Action
        3. Type
        4. Invert
        5. Duty cycle
        6. Mem value
        7. High/low output
        8. Folder/Track
        9. RGB mode
        10. RGB color
        11. RGB brightness
        12. RGB speed
        13. Publish
        14. Subtopic
        15. Secondary outputs
      10. Cycle
        1. Cycles
        2. High/Low phase
      11. On/Off button
    2. Peripheral
      1. Hardware
      2. Type
      3. Calibration
      4. Mapping (edit)
      5. IR remote (edit)
      6. Impulse_counter (edit)
      7. RGB driver (edit)
      8. DS18B20 (edit)
    3. Device
    4. Network
    5. System
    6. License
  4. Tutorials
    1. First boot
    2. First process
    3. Connect to MQTT
    4. Process sequencing

    5. DIY Project: Bath Fan

In this article

  • Introduction
advert
unicontrol > Getting Started > Special outputs - Audio driver

Special outputs - Audio Driver

Introduced in version 1.16

The Audio driver in unicontrol operates as an independent routine, serving as a controller for the DFPlayer Mini MP3 Player (MP3 Player). Each instance of unicontrol can control a single MP3 Player module connected to the ESP8266's pins D0 (GPIO16, serving as a software Tx) and D3 (GPIO0, serving as a software Rx):

DFPlayer Mini MP3 Player Wiring Diagram

The set-up is performed in the Peripheral menu by making the following selections:

  • D0 - OUT - DFPlayer mini (TX), and
  • D3 - OUT - DFPlayer mini (RX)
DFPlayer Mini peripheral set-up

As long as these selections are active (saved), the MP3 Player initializes automatically upon each boot or following a Micro SD card insertion. This initialization consists of verifying the connection with the MP3 Player and scanning the content of the inserted Micro SD card. The Audio driver can utilize up to 16 folders, each holding up to 100 audio files in the .mp3 format.

The Audio driver expects folders and tracks on the inserted MicroSD card to be named sequentially as "01", "02", ..., "16" (folders) or "001.mp3", "002.mp3", ..., "100.mp3" (tracks). Failure to follow this naming convention may lead to unexpected behavior.

Edit menu

Clicking on either of the two Edit buttons will navigate you to the Audio driver edit menu.

DFPlayer Mini Peripheral Set-up
The edit menu contains the following buttons for direct access to the MP3 Player:
Icon Folder status
Plays the first track of the folder immediately preceding the currently played folder.
Plays the track immediately preceding the currently played track.
Pauses the playback.
Resumes the playback.
Plays the track immediately following the currently played track.
Plays the first track of the folder immediately following the currently played folder.
Selects a random track from the enabled folders.

The Audio driver set-up consists of four key parameters:

  • Volume - The playback volume.
  • Equalizer - Equalizer preset used for the playback.
  • Shuffle - Change the track selection from sequential to random.
  • Directories - Selection of folders enabled for automatic track selection (individual tracks in the unselected folders can still be played when explicitly requested).
Highlighting of the individual folder buttons lets the user know if the given folder is selected and if it contains valid tracks.
Icon Folder status
The folder is selected and contains valid audio tracks.
The folder is selected, but does not contain any valid audio track (will be ignored).
The folder is not selected, but contains valid audio tracks.
The folder is neither selected, nor contains any valid audio track.

Processes

Although the Audio driver operates as an independent routine, the playback still needs to be started or stopped by the Processes (or manually). When accessing the audio tracks via a Process, the exact behavior of the Audio driver being controlled by a process is determined by the following process parameters:


Folder & Track:

Exact selection of the track to be played. These parameters are only available for the non-random playback modes.

Audio track selection in the process output.

Output:

The following output options are available for the Audio driver playback, each behaving differently when turning ON a process with the respective Play options selected as the Primary output:

  • Play from: Initiates a continuous playback of the tracks in the enabled Directories, played automatically one after another in the order determined by the Folder and Track names, starting from the provided Folder and Track number (if the respective track exists).
  • Play single: Initiates a playback of a single track based on the provided Folder and Track number (if the respective track exists).
  • Play random: Initiates a continuous playback of the tracks in the enabled Directories, played automatically one after another in a randomized order.
  • Play random single: Initiates a playback of a single track randomly picked from the enabled Directories.
Audio output selection in the process.
When turning OFF a process with any of the Play options selected as the Primary output, the playback stops.
The DFPlayer Mini has an independent processor performing the playback, and once it has started, it will continue playing the given track till its end unless explicitly instructed otherwise. Rebooting the unicontrol has no direct effect on the DFPlayer Mini.
Use the Audio driver for various sound effects like alarms, beeps, bells, and more, or for situational background music. For example, combine the thunderstorm sounds in cooperation with one of the thunderstorm effects of the RGB driver and a water pump connected to a relay to achieve a convincing storm effect.
© 2024 ayatec.eu • Found a mistake?  Let us know!