# WiFiX-Enhanced Wiring Diagram

## 🔌 Complete Connection Map

### Visual Wiring Layout

```
┌─────────────────────────────────────────────────────────────────────┐
│                    BREADBOARD LAYOUT                               │
├─────────────────────────────────────────────────────────────────────┤
│  Top Rail: 3.3V Power                                              │
│  Bottom Rail: GND                                                 │
└─────────────────────────────────────────────────────────────────────┘

┌─────────────┐    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│   ESP32     │    │    OLED     │    │   SD CARD   │    │    BW16     │
│   DevKit    │    │  Display    │    │   Module    │    │   Module    │
└─────────────┘    └─────────────┘    └─────────────┘    └─────────────┘

┌─────────────────────────────────────────────────────────────────────┐
│                    CONNECTION DETAILS                              │
├─────────────────────────────────────────────────────────────────────┤
│ Power Connections:                                                  │
│ ├─ ESP32 3.3V → Top Rail (+)                                       │
│ ├─ ESP32 GND → Bottom Rail (-)                                     │
│ ├─ Top Rail → OLED VCC, SD VCC, BW16 VCC                           │
│ └─ Bottom Rail → OLED GND, SD GND, BW16 GND                        │
│                                                                     │
│ Signal Connections:                                                 │
│ ├─ ESP32 GPIO21 → OLED SDA (Blue Wire)                            │
│ ├─ ESP32 GPIO22 → OLED SCL (Yellow Wire)                           │
│ ├─ ESP32 GPIO23 → SD MOSI (Green Wire)                             │
│ ├─ ESP32 GPIO19 → SD MISO (Orange Wire)                            │
│ ├─ ESP32 GPIO18 → SD CLK (Purple Wire)                             │
│ ├─ ESP32 GPIO5 → SD CS (White Wire)                                 │
│ ├─ ESP32 GPIO16 → BW16 TX (Gray Wire)                              │
│ └─ ESP32 GPIO17 → BW16 RX (Brown Wire)                             │
└─────────────────────────────────────────────────────────────────────┘
```

## 🎨 Color-Coded Wiring Scheme

### Wire Color Standards
```
🔴 Red: Power (3.3V)
⚫ Black: Ground (GND)
🔵 Blue: I2C SDA
🟡 Yellow: I2C SCL
🟢 Green: SPI MOSI
🟠 Orange: SPI MISO
🟣 Purple: SPI CLK
⚪ White: SPI CS
🔘 Gray: UART TX
🟤 Brown: UART RX
```

### Physical Wiring Map

```
ESP32 DevKit (30-pin) Layout:
┌─────────────────────────────────────────────────────────────────────┐
│ 3.3V [●]──────────────────────────────┐                            │
│ GND  [●]──────────────────────────────┼──┐                         │
│      [ ] [ ] D23 (MOSI) ────────┐     │  │                         │
│      [ ] [ ] D22 (SCL) ─────────┼──┐  │  │                         │
│      [ ] [ ] D21 (SDA) ─────────┼──┼──┤  │                         │
│      [ ] [ ] D19 (MISO) ────────┼──┤  │  │                         │
│      [ ] [ ] D18 (CLK) ─────────┼──┼──┤  │                         │
│      [ ] [ ] D5 (CS) ───────────┼──┼──┼──┤                        │
│      [ ] [ ] D17 (TX) ──────────┼──┼──┼──┼──┐                     │
│      [ ] [ ] D16 (RX) ──────────┼──┼──┼──┼──┼──┐                  │
│ GND  [●]──────────────────────────┼──┼──┼──┼──┼──┐               │
│      [ ] [●] D2 (LED)             │  │  │  │  │  │               │
│      [ ] [ ]                       │  │  │  │  │  │               │
│      [ ] [ ]                       │  │  │  │  │  │               │
│      [ ] [ ]                       │  │  │  │  │  │               │
│ 3.3V [●]──────────────────────────┼──┼──┼──┼──┼──┘               │
│ EN   [●]                             │  │  │  │  │                 │
└──────────────────────────────────────┼──┼──┼──┼──┘                 │
                                       │  │  │  │                    │
                                       ▼  ▼  ▼  ▼                    ▼
OLED Connections:                    SD Card:                    BW16:
┌─────────────┐                     ┌─────────────┐            ┌─────────────┐
│ VCC [●]─────┼─── Red Wire         │ VCC [●]─────┼─── Red     │ VCC [●]─────┼─── Red
to 3.3V Rail  │                     │ to 3.3V Rail│            │ to 3.3V Rail│
│ GND [●]─────┼─── Black Wire       │ GND [●]─────┼─── Black   │ GND [●]─────┼─── Black
to GND Rail   │                     │ to GND Rail │            │ to GND Rail │
│ SDA [●]─────┼─── Blue Wire        │ MOSI[●]─────┼─── Green   │ TX  [●]─────┼─── Gray
to GPIO21     │                     │ to GPIO23   │            │ to GPIO16   │
│ SCL [●]─────┼─── Yellow Wire      │ MISO[●]─────┼─── Orange  │ RX  [●]─────┼─── Brown
to GPIO22     │                     │ to GPIO19   │            │ to GPIO17   │
└─────────────┘                     │ CLK [●]─────┼─── Purple  └─────────────┘
                                      │ to GPIO18   │
                                      │ CS  [●]─────┼─── White
                                      │ to GPIO5    │
                                      └─────────────┘
```

## 🔧 Breadboard Layout

### Recommended Breadboard Sections

```
Full-Size Breadboard (830 tie-points):
┌─────────────────────────────────────────────────────────────────────┐
│ A1-A30: ESP32 DevKit                                                │
│ B1-B30: Power distribution                                          │
│ C1-C30: OLED Display connections                                    │
│ D1-D30: SD Card connections                                         │
│ E1-E30: BW16 connections                                            │
│ F1-F30: Spare/Expansion                                             │
│ G1-G30: Spare/Expansion                                             │
│ H1-H30: Spare/Expansion                                             │
│ I1-I30: Spare/Expansion                                             │
│ J1-J30: Spare/Expansion                                             │
└─────────────────────────────────────────────────────────────────────┘

Specific Layout:
┌─────────────────────────────────────────────────────────────────────┐
│ Row 1-5: Power rails (3.3V top, GND bottom)                        │
│ Row 6-10: ESP32 main placement                                      │
│ Row 11-15: OLED display area                                        │
│ Row 16-20: SD card module area                                      │
│ Row 21-25: BW16 module area                                         │
│ Row 26-30: Status LEDs/Expansion                                   │
└─────────────────────────────────────────────────────────────────────┘
```

## 📏 Wire Length Guidelines

### Maximum Recommended Lengths
```
I2C Connections (OLED):
├─ SDA: ≤30cm (12 inches)
├─ SCL: ≤30cm (12 inches)
└─ Use twisted pairs for longer runs

SPI Connections (SD Card):
├─ MOSI: ≤15cm (6 inches)
├─ MISO: ≤15cm (6 inches)
├─ CLK: ≤15cm (6 inches)
├─ CS: ≤15cm (6 inches)
└─ Keep all SPI wires same length

UART Connections (BW16):
├─ TX: ≤50cm (20 inches)
├─ RX: ≤50cm (20 inches)
└─ Use shielded cable for long runs

Power Connections:
├─ 3.3V: ≤10cm (4 inches) recommended
├─ GND: As short as possible
└─ Use thicker wire for power (22-24 AWG)
```

## ⚡ Power Distribution

### Current Requirements by Module
```
ESP32 DevKit:
├─ Normal operation: 80-120mA
├─ WiFi active: 160-260mA
└─ Peak current: 500mA

BW16 Module:
├─ Normal operation: 60-100mA
├─ WiFi active: 120-200mA
└─ Peak current: 300mA

OLED Display:
├─ Normal operation: 15-25mA
└─ All pixels on: 40mA

SD Card Module:
├─ Idle: 5-10mA
├─ Active: 50-100mA
└─ Peak current: 150mA

Total System:
├─ Average current: 200-300mA
├─ Peak current: 800-1000mA
└─ Recommended supply: 3.3V @ 1.5A
```

## 🔍 Testing Connections

### Visual Inspection Checklist
```
✓ All power connections correct (3.3V, not 5V)
✓ Common ground established between all modules
✓ Signal wire colors match standard
✓ No loose connections or stray wire strands
✓ No short circuits between adjacent pins
✓ Wire insulation not damaged
✓ Breadboard connections firm
```

### Continuity Testing
```
Use multimeter continuity mode:
1. ESP32 3.3V → each module VCC
2. ESP32 GND → each module GND
3. ESP32 GPIO21 → OLED SDA
4. ESP32 GPIO22 → OLED SCL
5. ESP32 GPIO23 → SD MOSI
6. ESP32 GPIO19 → SD MISO
7. ESP32 GPIO18 → SD CLK
8. ESP32 GPIO5 → SD CS
9. ESP32 GPIO16 → BW16 TX
10. ESP32 GPIO17 → BW16 RX
```

### Power-On Test Sequence
```
Step 1: Power supply test
├─ Connect USB to ESP32
├─ Measure 3.3V rail: 3.2-3.4V expected
├─ Measure total current: <100mA expected
└─ Check for hot components

Step 2: Module detection
├─ Upload test sketch
├─ Check serial output
├─ Verify OLED display
├─ Test SD card detection
└─ Confirm BW16 communication

Step 3: Full system test
├─ Upload main firmware
├─ Check WiFi network appears
├─ Test captive portal
├─ Verify credential storage
└─ Confirm all features working
```

## 🚨 Common Wiring Mistakes

### Power Related
```
❌ Using 5V instead of 3.3V → WILL DAMAGE MODULES
❌ Insufficient power supply → Unstable operation
❌ Missing common ground → Communication failures
❌ Long power wires → Voltage drop issues
```

### Signal Related
```
❌ Swapped TX/RX connections → No communication
❌ I2C pull-up resistors missing → Unreliable operation
❌ SPI wires too long → Data corruption
❌ Crossed signal wires → Interference
```

### Mechanical
```
❌ Loose breadboard connections → Intermittent faults
❌ Wire strands touching → Short circuits
❌ Insufficient wire gauge → Voltage drop
❌ Poor strain relief → Broken connections
```

## 🔧 Troubleshooting Wiring Issues

### System Won't Power On
```
1. Check power supply voltage (3.3V ±5%)
2. Verify polarity (no reversed connections)
3. Test for short circuits (multimeter)
4. Check current draw (should be <100mA idle)
5. Inspect for damaged components
```

### OLED Display Not Working
```
1. Verify I2C connections (SDA/SCL not swapped)
2. Check I2C address (usually 0x3C)
3. Test with I2C scanner sketch
4. Add pull-up resistors (4.7kΩ) if needed
5. Check power supply stability
```

### SD Card Not Detected
```
1. Verify all SPI connections
2. Check CS pin configuration
3. Test with different SD card
4. Format card as FAT32
5. Check SPI speed (try slower)
```

### BW16 Not Communicating
```
1. Verify TX/RX connections (crossover)
2. Check baud rate (115200)
3. Test with serial loopback
4. Verify BW16 firmware loaded
5. Check antenna connection
```

---

**Remember**: Measure twice, cut once. Double-check all connections before powering on!