# DFPlayer Carrier Board

A compact, SMD-based motherboard for the popular [DFPlayer Mini](https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299) MP3 module, designed using the atopile hardware description language.

This board serves as a carrier for the DFPlayer, providing stable power, protection, and convenient interfaces for input and output. It is designed to be easily integrated into larger audio projects.

### Design and Manufacturing Process

This project follows a modern, code-centric workflow for electronics design. Here’s a step-by-step guide to the journey from concept to a professionally made circuit board.

#### 1. Describe the Circuit in Code
Instead of drawing a traditional schematic (an electronics blueprint) in a graphical editor, we define the circuit using the atopile language in the `main.ato` file.

*   **What this means:** You simply write text to declare components (like resistors and connectors) and describe how they connect to each other.
*   **Why it's great:** This approach is highly organized, easy to read, and allows you to reuse parts of your design. It's like building with digital LEGOs, where each block is a piece of code.

#### 2. Design the Physical Board (PCB Layout)
Our code describes *what* components are connected, but not *where* they physically go on the board. For that, we use a powerful, free tool called KiCad.

After running the command `ato: Launch KiCad`, atopile automatically generates a KiCad project for you. Your job is to:
*   **Arrange the Components:** Drag and drop the component footprints onto the virtual board.
*   **Draw the Traces:** Route the copper "wires" (called traces) that connect the components.
*   **Add Labels:** Customize the text and logos on the board's surface (the "silkscreen").

> **Quick Tip:** Before you start, import the JLCPCB manufacturer template from the `kicad_templates/JLCPCB_1-2Layer` folder. This ensures your design meets their specific requirements from the start!

<img src="media/pcb_layout.png" height="400" />

#### 3. Preview Your Board in 3D
Before spending any money, you can see exactly what your board will look like! KiCad has a built-in 3D viewer that creates a stunningly realistic preview. This is a crucial step to check if connectors are facing the right way, if parts are too close together, and if it will fit in its intended enclosure. It's your chance to catch mistakes for free!

<img src="media/3d_model.png" height="400" />

#### 4. Create the Manufacturing Files (Gerbers, BOM, Pick and Place)
Once you're happy with the design, it's time to generate the files a factory needs to build it. These are called "Gerber files." Think of them as the universal language for PCB manufacturing—a set of blueprints that tells the machines exactly where to drill holes, place copper, and print the silkscreen.

atopile makes this easy. Just run the command `ato: Generate Manufacturing Data`.

#### 5. Order the Board and Assembly
With your Gerber files in hand, you can order your board from a manufacturer like [JLCPCB](https://jlcpcb.com/). You have two main options:
*   **PCB (Printed Circuit Board):** Order the bare board, and you buy and solder all the components yourself.
*   **PCBA (PCB Assembly):** The factory manufactures both the board AND solders all the tiny surface-mount components for you. This is highly recommended for a professional result without the hassle of manual soldering.

You simply upload your files, select the components you want them to place, and place your order.

#### 6. Receive Your Finished Board!
In about a week or two, a package arrives. Inside are your professionally manufactured and assembled circuit boards, transformed from a simple text file into a functional piece of hardware, ready for your project.

<img src="media/PCBA_from_JLCPCB.jpg" height="400" />

#### 7. Order details and price
Minimum order amount of PCBs is 5 and PCBA is 2.

<img src="media/Order_details_and_price.png" height="400" />

#### 8. Board integrated in the system

<img src="media/Board_integrated.jpg" height="400" />

## Features

*   **Power Supply:** On-board diode is used to drop the input voltage to a DFPlayer-safe ~4.3V. Tantalum capacitors are included for power supply filtering, ensuring smooth operation.
*   **All SMD Components:** Designed for a low-profile, surface-mount assembly, making it suitable for compact enclosures.
*   **Simple Interfaces:** Utilizes standard (JST and 3.5mm Jack) connectors for power, data input, speaker output, and stereo line-level output.
*   **Compact Design:** A small footprint carrier board for the 2x8 pin DFPlayer Mini module.

## Interfaces

### Input

*   **Connector:** 4-pin JST PH 2.0mm
*   **Signals:**
    *   `+5V`: Power input
    *   `GND`: Ground
    *   `TX`: Serial Transmit (connects to DFPlayer RX) protected by the 1kΩ resistor
    *   `RX`: Serial Receive (connects to DFPlayer TX) 
*   **Description:** This interface provides both power and UART serial communication to the DFPlayer module. It is important to note that the DFPlayer's RX pin is not 5V tolerant, so a 1kΩ series resistor is included on the board for protection.

### Outputs

#### 1. Speaker (Mono)

*   **Connector:** 2-pin JST PH 2.0mm
*   **Signals:**
    *   `SPK+`
    *   `SPK-`
*   **Description:** A direct, amplified mono output for a small speaker (up to 3W). This connects directly to the `SPK1` and `SPK2` pins of the DFPlayer.

#### 2. Stereo Line Out

*   **Connector:** 3.5mm Stereo Audio Jack (SMD)
*   **Signals:**
    *   `L`: Left Audio Channel
    *   `R`: Right Audio Channel
    *   `GND`: Ground
*   **Description:** A line-level stereo output suitable for headphones, external amplifiers, or other audio equipment. This connects to the `DAC_R`, `DAC_L`, and `GND` pins of the DFPlayer.

## Power Supply Circuit

The motherboard is designed to be powered by a standard +5V source. To ensure the DFPlayer module receives a safe operating voltage (typically 3.2V to 5.0V, with 4.2V being ideal), the following components are included:

*   **Voltage Drop Diode:** A standard silicon diode (e.g., a 1N4001 SMD equivalent) is placed in series with the power input. This provides a forward voltage drop of approximately 0.7V, effectively reducing the 5V input to a safer ~4.3V for the DFPlayer.
*   **Filtering Capacitor:** Tantalum capacitors (e.g., 100µF, 6,3V) is placed across the DFPlayer's power pins (`VCC` and `GND`). This smooths the power supply and filters out noise, which is crucial for clean audio playback.

## Mechanical Design

*   **Mounting Holes:** The board includes four mounting holes, one in each corner.
*   **Hole Diameter:** 2,2mm, providing clearance for standard M2 screws.
*   **Compatibility:** Designed for use with M2 nylon or brass standoffs for easy mounting.

## Bill of Materials

| Component                            | Qty | Type                                           | LCSC Part #                |
| ------------------------------------ | --- | --------------------------------------------   | -------------------------- |
| Female 8-Pin Header                  | 2   | PinSocket 1x08 2.54mm Vertical                 | C48641756                  |
| Diode                                | 1   | A7                                             | C18199093                  |
| Capacitor                            | 5   | Tantalum 100uF 6.3V                            | C178529                    |
| UART Connector                       | 1   | JST PH 1x04 2.00mm Vertical                    | C160354                    |
| Speaker Connector                    | 1   | JST PH 1x02 2.00mm Vertical                    | C265003                    |
| Audio Jack                           | 1   | Jack 3,5mm Horizontal                          | C22459515                  |
| Resistor                             | 1   | 1kΩ, 0805                                      | C17513                     |

## Assembly

This project is intended to be built with surface-mount components. A soldering iron with a fine tip, solder paste, and a hot air rework station are the recommended tools for a clean assembly.

## How to Use

1.  **Prepare an SD Card:** Format a microSD card (up to 32GB) to FAT16 or FAT32. Copy your MP3 or WAV files onto the card.
2.  **Insert SD Card:** Place the microSD card into the DFPlayer module's slot.
3.  **Connect DFPlayer:** Carefully plug the DFPlayer Mini module into the female socket headers on the motherboard. Ensure the orientation is correct.
4.  **Connect Interfaces:**
    *   Plug in your +5V power source and UART controller (like an Arduino or FTDI adapter) to the 4-pin JST connector.
    *   Connect a speaker (e.g., 8Ω, 1W) to the 2-pin JST connector.
    *   (Optional) Connect headphones or an amplifier to the 3.5mm audio jack.
5.  **Power On:** Apply power to the board and begin sending serial commands to control the DFPlayer.

