# Quick Start: Building the Schematic

## Step-by-Step Guide

### 1. Start with Power Supply (Page 1 or Top Left)

**Add Components:**
1. Press `A` → Search `Midea_ESP:AMS1117-3.3` → Place as **U1**
2. Press `A` → Search `Device:C` → Place 4 capacitors: **C1, C2, C3, C4**

**Set Values:**
- C1, C2: 10µF
- C3, C4: 100nF

**Add Power Symbols:**
- Press `P` → Select `+3V3` → Place near U1 output
- Press `P` → Select `+5V` → Place near where J1 will connect (on Page 3)
- Press `P` → Select `GND` → Place multiple times

**Connect:**
- **Net Label `+5V_POWER`** → **U1 Pin 3 (IN)** (this connects to J1 Pin 1 on Page 3)
- **Net Label `+5V_POWER`** → **C1 (one terminal)** (parallel - connect directly to +5V net)
- **Net Label `+5V_POWER`** → **C3 (one terminal)** (parallel - connect directly to +5V net)
- **C1 (other terminal)** → **GND**
- **C3 (other terminal)** → **GND**
- **U1 Pin 2 (OUT)** → **+3V3 power symbol** (connect to +3V3 net)
- **U1 Pin 2 (OUT)** → **C2 (one terminal)** (parallel - connect directly to +3V3 net)
- **U1 Pin 2 (OUT)** → **C4 (one terminal)** (parallel - connect directly to +3V3 net)
- **C2 (other terminal)** → **GND**
- **C4 (other terminal)** → **GND**
- **U1 Pin 1 (GND)** → **GND**
- **U1 Pin TAB (GND)** → **GND**

**Note:** 
- Power comes from J1 Pin 1 (+5V) on Page 3. Use net labels to connect between pages.
- **C1 and C3 are in PARALLEL** (both connected between +5V and GND for input filtering)
- **C2 and C4 are in PARALLEL** (both connected between +3V3 and GND for output filtering)

---

### 2. Add ESP32 (Page 2 or Center)

**Add Components:**
1. Press `A` → Search `Midea_ESP:ESP32-WROOM-32E` → Place as **U2**
2. Press `A` → Search `Device:C` → Place 2 capacitors: **C5** (100nF), **C6** (10µF)
3. Press `A` → Search `Button_Switch_SMD:SW_PUSH` → Place 2 buttons: **SW1, SW2**
4. Press `A` → Search `Device:R` → Place 4 resistors: **R1, R2, R3, R4**
5. Press `A` → Search `Device:LED` → Place 2 LEDs: **LED1, LED2**

**Set Values:**
- R1, R2: 220Ω
- R3, R4: 10kΩ
- C5: 100nF
- C6: 10µF

**Connect Power:**
- **U2 Pin 2 (VDD)** → **+3V3** (only exposed VDD pin on your module)
- **U2 Pin 2 (VDD)** → **C5 (one terminal)** → **+3V3**, **C5 (other terminal)** → **GND** (100nF decoupling)
- **U2 Pin 2 (VDD)** → **C6 (one terminal)** → **+3V3**, **C6 (other terminal)** → **GND** (10µF bulk capacitor)
- **All exposed U2 GND pins** → **GND** (typically Pin 1 and other exposed GND pins)

**Connect Buttons:**
- SW1 Pin 1 → U2.EN, R3 → +3V3
- SW1 Pin 2 → GND
- SW2 Pin 1 → U2.GPIO0, R4 → +3V3
- SW2 Pin 2 → GND

**Connect LEDs:**
- LED1 Anode → R1 → U2.GPIO2
- LED1 Cathode → GND
- LED2 Anode → R2 → U2.GPIO4
- LED2 Cathode → GND

**Add Net Labels:**
- Press `L` → Type `ESP32_TX` → Attach to wire from U2.GPIO17
- Press `L` → Type `ESP32_RX` → Attach to wire from U2.GPIO16

---

### 3. Add Level Shifter and AC Connector (Page 3 or Right)

**Add Components:**
1. Press `A` → Search `Midea_ESP:TXB0104PWR` → Place as **U3**
2. Press `A` → Search `Connector_JST:JST_XH_B4B-XH-A` → Place as **J1**

**Connect Power:**
- U3 Pin 12 (VCCA) → +3V3
- U3 Pin 11 (VCCB) → +5V
- U3 Pin 10 (OE) → +3V3
- U3 Pins 5, 13, 14 (GND) → GND

**Connect Signals:**
- U3 Pin 1 (A1) → Net Label `ESP32_TX` (connects to U2.GPIO17)
- U3 Pin 2 (A2) → Net Label `ESP32_RX` (connects to U2.GPIO16)
- U3 Pin 9 (B1) → Net Label `AC_RX` → J1 Pin 2
- U3 Pin 8 (B2) → Net Label `AC_TX` → J1 Pin 3
- **J1 Pin 1 → Net Label `+5V_POWER` → Connect to Page 1 (U1 input via capacitors)**
- **J1 Pin 4 → GND**

**Note:** J1 is a JST-XH connector on the PCB. This connector provides:
- **Power input** (Pin 1: +5V) - Powers the entire PCB
- **AC communication** (Pins 2-3: UART signals)
- **Ground** (Pin 4: GND)

Connect a cable with matching JST-XH connector to your AC unit.

---

### 4. Add Programming Header (Required - Page 4 or Bottom)

**Add Components:**
1. Press `A` → Search `Connector_PinHeader_2.54mm:PinHeader_2x04_P2.54mm_Vertical` → Place as **J2**
2. Press `A` → Search `Device:R` → Place 2 resistors: **R5, R6** (optional)

**Set Values:**
- R5, R6: 10kΩ (optional - for pull-ups)

**Connect:**
- J2 Pin 1 → +3V3 (optional - for powering from programmer)
- J2 Pin 2 → GND
- J2 Pin 3 → Net Label `UART_TX` (connects to U2.GPIO1)
- J2 Pin 4 → Net Label `UART_RX` (connects to U2.GPIO3)
- J2 Pin 5 → Net Label `DTR` → U2.GPIO0 (auto-reset)
- J2 Pin 6 → Net Label `RTS` → U2.EN (auto-reset)

**Optional Pull-ups (for reliability):**
- J2 Pin 5 (DTR) → R5 → +3V3
- J2 Pin 6 (RTS) → R6 → +3V3

**Add Net Labels on Page 2:**
- Press `L` → Type `UART_TX` → Attach to wire from U2.GPIO1
- Press `L` → Type `UART_RX` → Attach to wire from U2.GPIO3
- Press `L` → Type `DTR` → Attach to wire from U2.GPIO0
- Press `L` → Type `RTS` → Attach to wire from U2.EN

**Programming Header Pinout (J2) - 2x4 Header:**
```
Top Row:    Pin 1: VCC  Pin 2: GND  Pin 3: TX   Pin 4: RX
Bottom Row: Pin 5: DTR  Pin 6: RTS  Pin 7: NC   Pin 8: NC
```
```
Pin 1: +3V3 (optional)
Pin 2: GND
Pin 3: UART_TX (ESP32 TX → Programmer RX)
Pin 4: UART_RX (ESP32 RX ← Programmer TX)
Pin 5: DTR (Auto-reset)
Pin 6: RTS (Auto-reset)
```

**External USB-to-Serial Adapter Connection:**
When flashing, connect your USB-to-Serial adapter (CP2102, CH340, FT232, etc.):
- Adapter VCC → J2 Pin 1 (optional - only if powering ESP32 from adapter)
- Adapter GND → J2 Pin 2
- Adapter RX → J2 Pin 3 (receives TX from ESP32)
- Adapter TX → J2 Pin 4 (sends to RX of ESP32)
- Adapter DTR → J2 Pin 5 (auto-reset)
- Adapter RTS → J2 Pin 6 (auto-reset)

---

## Keyboard Shortcuts

- `A` - Add Symbol
- `W` - Add Wire
- `P` - Add Power Port
- `L` - Add Net Label
- `E` - Edit Component
- `M` - Move Component
- `R` - Rotate Component
- `Delete` - Delete Selected
- `Ctrl+Z` - Undo
- `Ctrl+S` - Save

---

## Verification Checklist

After completing the schematic:

- [ ] All components have reference designators (U1, U2, etc.)
- [ ] All components have values set
- [ ] All power pins connected to appropriate power rails
- [ ] All ground pins connected to GND
- [ ] Net labels match between pages (if using multiple pages)
- [ ] No unconnected pins (except NC pins)
- [ ] Run ERC: Tools → Electrical Rules Checker
- [ ] Fix any ERC warnings/errors

---

## Common Issues

1. **"Unconnected pin" warning**: Check if pin should be connected or marked as NC
2. **"Power pin not driven"**: Ensure power symbols are connected
3. **"Multiple net names"**: Check for duplicate net labels or conflicting connections
4. **"Pin connected to multiple nets"**: Check for wiring errors

