Initial KiCad project

This commit is contained in:
2026-01-04 01:19:56 +02:00
commit cf6e6e3baf
45 changed files with 133173 additions and 0 deletions

441
DESIGN_SPEC.md Normal file
View File

@@ -0,0 +1,441 @@
# Custom PCB Design Specification: Midea AC Controller with BLE Beacon
## Recommended ESP Module
### 🏆 **Best Choice: ESP32-WROOM-32E or ESP32-WROOM-32**
**Why ESP32 (not ESP8266 or ESP32-C6)?**
-**Bluetooth BLE Support**: Required for beacon functionality
-**Midea Component Compatibility**: Works with Arduino framework (ESP32-C6 uses ESP-IDF, incompatible)
-**Excellent ESPHome Support**: Most mature and well-documented
-**Dual Core**: Can handle WiFi + BLE + Midea communication simultaneously
-**Multiple UARTs**: Can use hardware UART for Midea, software UART for debugging
-**Good Memory**: 520KB SRAM, sufficient for both features
### Module Options
| Module | Size | Flash | RAM | Price | Recommendation |
|--------|------|-------|-----|-------|----------------|
| **ESP32-WROOM-32E** | 18×25.5mm | 4MB | 520KB | $$ | ⭐ **Best for custom PCB** |
| **ESP32-WROOM-32** | 18×25.5mm | 4MB | 520KB | $$ | ⭐ Good alternative |
| **ESP32-MINI-1** | 13.2×16.6mm | 4MB | 520KB | $$ | Compact option |
| ESP32-C3 | 18×25.5mm | 4MB | 400KB | $ | RISC-V, less support |
| ESP32-C6 | 18×25.5mm | 4MB | 512KB | $$ | ESP-IDF only, no Midea |
**Recommended**: **ESP32-WROOM-32E** (most common, best support)
---
## PCB Design Requirements
### Core Components
1. **ESP32-WROOM-32E Module**
- 38 pins (19 per side)
- Requires 3.3V power
- Built-in antenna
2. **Logic Level Shifter (3.3V ↔ 5V)**
- **TXB0104** (4-channel) or **74LVC245** (8-channel)
- Required for Midea AC communication (5V logic)
- Bidirectional for TX/RX
3. **Power Supply**
- **AMS1117-3.3** or **LD1117-3.3** (3.3V regulator)
- Input: 5V (USB or external)
- Output: 3.3V @ 1A (ESP32 needs ~500mA peak)
- Decoupling capacitors: 10µF + 100nF
4. **USB-to-Serial (Optional but Recommended)**
- **CP2102** or **CH340C** for programming/debugging
- Allows OTA updates via USB
- Auto-reset circuit for easy flashing
5. **Midea AC Connector**
- **JST-XH 4-pin** or **USB Type-A** (depending on AC dongle)
- Pins: VCC (5V), GND, TX, RX
6. **Status LEDs**
- Power LED (3.3V)
- WiFi status LED
- BLE status LED (optional)
- Midea communication LED (optional)
7. **Reset Button**
- Reset ESP32
- Boot button (GPIO0) for flashing
### Pin Assignment
#### ESP32-WROOM-32E Pinout
```
Power:
VDD (Pin 1, 3, 14, 21, 22, 27, 28, 33, 42) → 3.3V
GND (Pin 2, 4, 13, 15, 20, 23, 26, 29, 34, 38, 40) → GND
Midea UART (via Level Shifter):
GPIO17 (TX) → Level Shifter LV1 → HV1 → AC Dongle RX
GPIO16 (RX) → Level Shifter LV2 → HV2 → AC Dongle TX
GND → AC Dongle GND
USB-to-Serial (if included):
GPIO1 (TX) → CP2102 RX
GPIO3 (RX) → CP2102 TX
GPIO0 (Boot) → CP2102 DTR (auto-reset)
Status LEDs:
GPIO2 → WiFi Status LED
GPIO4 → BLE Status LED (optional)
GPIO5 → Midea Communication LED (optional)
Buttons:
GPIO0 → Boot/Flash Button
EN → Reset Button
Bluetooth:
Built-in (no external pins needed)
```
### Schematic Design
#### Power Section
```
USB 5V → AMS1117-3.3 → 3.3V → ESP32 VDD
GND → Common Ground
```
#### Midea Communication Section
```
ESP32 GPIO17 (TX) → TXB0104 LV1 → HV1 → AC Dongle RX
ESP32 GPIO16 (RX) → TXB0104 LV2 → HV2 → AC Dongle TX
ESP32 GND → TXB0104 GND → AC Dongle GND
ESP32 3.3V → TXB0104 LV
External 5V → TXB0104 HV → AC Dongle VCC (if needed)
```
#### Level Shifter Configuration (TXB0104)
- **VCCA (LV)**: 3.3V from ESP32
- **VCCB (HV)**: 5V from USB or external
- **OE (Output Enable)**: Connect to 3.3V (always enabled)
- **A1 (LV1)**: ESP32 GPIO17 (TX)
- **B1 (HV1)**: AC Dongle RX
- **A2 (LV2)**: ESP32 GPIO16 (RX)
- **B2 (HV2)**: AC Dongle TX
---
## PCB Layout Considerations
### Layer Stackup (2-layer minimum, 4-layer recommended)
**2-Layer:**
- Top: Components, signal traces
- Bottom: Ground plane, power traces
**4-Layer (Recommended):**
- Top: Components, signal traces
- Layer 2: Ground plane
- Layer 3: Power plane (3.3V)
- Bottom: Ground plane, remaining signals
### Design Rules
1. **Power Traces**
- 3.3V: Minimum 0.5mm (20mil) width
- 5V: Minimum 0.5mm (20mil) width
- GND: Use ground planes where possible
2. **Signal Traces**
- UART: 0.2mm (8mil) minimum
- Keep UART traces short (<50mm)
- Avoid crossing power traces
3. **Component Placement**
- ESP32 module: Center of board
- Level shifter: Close to ESP32 and AC connector
- Power regulator: Near USB input
- Decoupling caps: Close to power pins (<5mm)
4. **Antenna Clearance**
- Keep 15mm clearance around ESP32 antenna area
- No ground plane under antenna
- No components or traces near antenna
5. **Thermal Considerations**
- Add thermal vias under power regulator
- Ensure adequate copper for heat dissipation
### Board Size Recommendation
- **Minimum**: 40mm × 50mm (fits ESP32 + essential components)
- **Recommended**: 50mm × 60mm (comfortable spacing, room for connectors)
- **With USB**: 50mm × 70mm (includes USB connector)
---
## Bill of Materials (BOM)
### Essential Components
| Component | Part Number | Quantity | Notes |
|-----------|-------------|----------|-------|
| ESP32 Module | ESP32-WROOM-32E | 1 | 4MB flash, built-in antenna |
| Level Shifter | TXB0104PWR | 1 | 4-channel, TSSOP-14 |
| 3.3V Regulator | AMS1117-3.3 | 1 | SOT-223 or SOT-89 |
| USB-to-Serial | CP2102N | 1 | Optional, QFN-24 |
| USB Connector | USB-B Micro | 1 | Optional, for programming |
| AC Connector | JST-XH 4-pin | 1 | Or USB Type-A female |
| Reset Button | Tactile Switch | 1 | 6×6mm |
| Boot Button | Tactile Switch | 1 | 6×6mm (optional) |
| Status LED | LED 0603 | 2-3 | Red/Green/Blue |
| Resistors | 10kΩ 0603 | 2 | Pull-up for buttons |
| Resistors | 220Ω 0603 | 2-3 | LED current limiting |
| Capacitors | 10µF 0805 | 2 | Power decoupling |
| Capacitors | 100nF 0603 | 5-10 | Decoupling |
### Optional Components
- **BLE Status LED**: Additional LED for Bluetooth status
- **Midea Status LED**: LED to show AC communication
- **Crystal**: 32.768kHz (if using RTC features)
- **EEPROM**: For storing settings (ESP32 has built-in)
---
## ESPHome Configuration Template
```yaml
esphome:
name: midea-ac-controller
friendly_name: Midea AC Controller
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging (can use software serial or disable)
logger:
baud_rate: 115200 # Or 0 to disable
# Enable Home Assistant API
api:
encryption:
key: !secret api_encryption_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
min_auth_mode: WPA2
ap:
ssid: "Midea AC Controller"
password: !secret fallback_password
captive_portal:
# Status LEDs
binary_sensor:
- platform: status
name: "WiFi Status"
output:
- platform: gpio
pin: GPIO2
id: wifi_led
- platform: gpio
pin: GPIO4
id: ble_led
light:
- platform: monochromatic
output: wifi_led
name: "WiFi Status LED"
- platform: monochromatic
output: ble_led
name: "BLE Status LED"
# UART for Midea AC communication
uart:
id: uart_midea
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 9600
stop_bits: 1
data_bits: 8
parity: NONE
# Midea AC Control
climate:
- platform: midea
name: "AC Controller"
uart_id: uart_midea
autoconf: true
beeper: false
period: 2s
timeout: 5s
num_attempts: 3
supported_modes:
- COOL
- HEAT
- DRY
- FAN_ONLY
supported_swing_modes:
- VERTICAL
- HORIZONTAL
- BOTH
supported_presets:
- ECO
- BOOST
- SLEEP
visual:
min_temperature: 17 °C
max_temperature: 30 °C
temperature_step: 0.5 °C
# Bluetooth Low Energy Beacon
esp32_ble_beacon:
type: iBeacon
uuid: 'c29ce823-e67a-4e71-bff2-abaa32e77a98' # Change to unique UUID
major: 1
minor: 1
tx_power: 0dBm
# Beeper control switch
switch:
- platform: template
name: "AC Beeper"
icon: "mdi:volume-source"
optimistic: true
turn_on_action:
- midea_ac.beeper_on:
turn_off_action:
- midea_ac.beeper_off:
```
---
## Design Checklist
### Schematic Design
- [ ] ESP32-WROOM-32E module placed
- [ ] Power supply circuit (5V 3.3V)
- [ ] Logic level shifter (TXB0104) connected
- [ ] Midea AC connector (JST-XH or USB)
- [ ] USB-to-Serial (optional but recommended)
- [ ] Status LEDs with current limiting resistors
- [ ] Reset and Boot buttons
- [ ] Decoupling capacitors (10µF + 100nF per power pin)
- [ ] Pull-up resistors for buttons
### PCB Layout
- [ ] ESP32 antenna clearance (15mm no-ground zone)
- [ ] Power traces adequate width (0.5mm minimum)
- [ ] Ground planes on bottom layer
- [ ] UART traces kept short and away from power
- [ ] Decoupling caps close to power pins
- [ ] Thermal vias under regulator
- [ ] Component labels and reference designators
- [ ] Test points for debugging
### Testing
- [ ] Power supply verification (3.3V stable)
- [ ] ESP32 boot and WiFi connection
- [ ] UART communication test
- [ ] Logic level shifter functionality (3.3V 5V)
- [ ] Midea AC communication
- [ ] BLE beacon transmission
- [ ] OTA update capability
---
## Manufacturing Notes
### PCB Specifications
- **Layers**: 2-layer minimum, 4-layer recommended
- **Thickness**: 1.6mm standard
- **Copper Weight**: 1oz (35µm)
- **Surface Finish**: HASL or ENIG (ENIG for better quality)
- **Solder Mask**: Green (standard) or custom color
- **Silkscreen**: White or black
### Assembly
- **Component Package**: 0603 or 0805 (hand-solderable)
- **ESP32 Module**: Can be hand-soldered or reflow
- **Level Shifter**: TSSOP-14 (requires careful soldering or stencil)
### Recommended PCB Manufacturers
- **JLCPCB**: Good for prototypes, low cost
- **PCBWay**: Good quality, reasonable price
- **OSHPark**: US-based, good for small batches
---
## Cost Estimation
### PCB Only (10 pieces)
- 2-layer 50×60mm: ~$5-10
- 4-layer 50×60mm: ~$20-30
### Components (per unit)
- ESP32-WROOM-32E: $2-3
- TXB0104: $0.50
- AMS1117-3.3: $0.20
- CP2102N: $1-2 (optional)
- Other components: $1-2
- **Total per unit**: ~$5-8
### Total Cost (10 units)
- PCB: $10-30
- Components: $50-80
- **Total**: ~$60-110 for 10 units
---
## Next Steps
1. **Create KiCad Schematic**
- Add ESP32-WROOM-32E module
- Design power supply
- Add level shifter circuit
- Connect all components
2. **Design PCB Layout**
- Place components
- Route traces
- Add ground planes
- Verify design rules
3. **Order Prototype**
- Generate Gerber files
- Order PCBs (start with 5-10 pieces)
- Order components
- Assemble and test
4. **Test and Iterate**
- Test power supply
- Test ESP32 functionality
- Test Midea communication
- Test BLE beacon
- Fix any issues
---
## References
- [ESP32-WROOM-32E Datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32e_esp32-wroom-32ue_datasheet_en.pdf)
- [TXB0104 Datasheet](https://www.ti.com/lit/ds/symlink/txb0104.pdf)
- [ESPHome Midea Component](https://esphome.io/components/climate/midea/)
- [ESPHome BLE Beacon](https://esphome.io/components/esp32_ble_beacon.html)
- [KiCad ESP32 Footprints](https://github.com/KiCad/kicad-footprints)
---
**Last Updated**: December 2025
**Design Status**: Specification Complete - Ready for Schematic Design