This commit is contained in:
2026-09-21 10:28:35 +02:00
commit b6fb01ba73
54 changed files with 33982 additions and 0 deletions
+182
View File
@@ -0,0 +1,182 @@
# UART Wiring Guide - Controller A ↔ Controller B
## Physical Connection
### Required: 2 Wires
```
Controller A Controller B
ESP32-S3-Touch-LCD-5B ESP32-S3-LCD-1.3
┌─────────────────────────┐ ┌─────────────────────────┐
│ │ │ │
│ GPIO 43 (UART TX) ─────┼──────────┼────> GPIO 1 (RX) │
│ [RS485 Terminal] │ Wire 1 │ [Pin 4 on header] │
│ │ │ │
│ GND ───────────────────┼──────────┼────> GND │
│ [Any GND pin] │ Wire 2 │ [Pin 2 on header] │
│ │ │ │
└─────────────────────────┘ └─────────────────────────┘
```
---
## Pin Details
### Controller A (ESP32-S3-Touch-LCD-5B)
- **TX Pin**: GPIO 43 (on RS485 terminal block)
- **GND**: Any GND pin on board
### Controller B (ESP32-S3-LCD-1.3)
- **RX Pin**: GPIO 1 (Pin 4 on 13-pin header)
- **GND**: Pin 2 on 13-pin header
---
## 13-Pin Header Pinout (Controller B)
Based on Waveshare documentation:
```
┌─────────────────┐
│ 1. 5V │
│ 2. GND │ ← Connect GND here
│ 3. 3V3 │
│ 4. GPIO 1 │ ← Connect UART RX here
│ 5. GPIO 2 │
│ 6. GPIO 42 │
│ 7. GPIO 41 │
│ 8. GPIO 40 │
│ 9. GPIO 39 │
│ 10. GPIO 38 │
│ 11. GPIO 37 │
│ 12. GPIO 36 │
│ 13. GPIO 35 │
└─────────────────┘
```
**Reference Image**: https://www.waveshare.com/img/devkit/ESP32-S3-LCD-1.3/ESP32-S3-LCD-1.3-details-7.jpg
---
## UART Configuration
| Parameter | Value |
|-----------|-------|
| Baud Rate | 115200 |
| Data Bits | 8 |
| Parity | None |
| Stop Bits | 1 |
| Format | 8N1 |
| Direction | One-way (A → B) |
| Update Rate | 5 Hz (200ms) |
---
## Testing Steps
### 1. Power Off Both Controllers
### 2. Make Physical Connections
- Wire 1: Controller A GPIO 43 → Controller B GPIO 1 (Pin 4)
- Wire 2: Controller A GND → Controller B GND (Pin 2)
### 3. Power On Controller A
- Ensure UART transmission is enabled
- Check Controller A serial monitor for "UART packets sent" messages
### 4. Power On Controller B
- Monitor serial output:
```bash
cd /home/julian/projects/esp/pio/bmw-patrol/ESP32-S3-LCD-1.3
pio device monitor
```
### 5. Expected Output on Controller B
**On Boot**:
```
[BOOT] ESP32-S3-LCD-1.3 starting...
[UART] Initializing UART receiver...
[UARTReceiver] Task started on Core 0
[UARTReceiver] UART1 initialized: 115200 baud, RX=GPIO1, TX=GPIO2
[UARTReceiver] Waiting for packets from Controller A...
```
**When Connected** (within 1-2 seconds):
```
[UART] Connection ESTABLISHED with Controller A
[Data] Gear:P | Gearbox:85.0°C | Engine:92.0°C | Battery:12.45V
```
**Every 5 seconds**:
```
[UART Stats] Packets: 25 | Checksum Errors: 0 | Framing Errors: 0 | Bytes RX: 650
[UART Stats] Last packet: 198 ms ago
```
**Every 20 packets**:
```
[UARTReceiver] Packet #20 | Gear:P | Gearbox:85.0°C | Engine:92.0°C | Coolant:89.0°C | Battery:12.45V
```
---
## Troubleshooting
### No Data Received
**Check**:
1. ✅ Wiring correct? (TX → RX, not TX → TX)
2. ✅ GND connected?
3. ✅ Controller A transmitting? (check its serial monitor)
4. ✅ Baud rates match? (both should be 115200)
**Serial Monitor Shows**:
```
[UART Stats] Packets: 0 | Checksum Errors: 0 | Framing Errors: 0 | Bytes RX: 0
```
→ No data arriving at all - check wiring
### Framing Errors
**Serial Monitor Shows**:
```
[UART Stats] Packets: 0 | Checksum Errors: 0 | Framing Errors: 127 | Bytes RX: 127
[UARTReceiver] Framing error! Expected 0x55, got 0x3C
```
→ Data arriving but corrupted - check:
- Loose connection
- Baud rate mismatch
- Electrical interference
### Checksum Errors
**Serial Monitor Shows**:
```
[UART Stats] Packets: 0 | Checksum Errors: 15 | Framing Errors: 0 | Bytes RX: 390
[UARTReceiver] Checksum error!
```
→ Packets arriving but validation failing - possible:
- Protocol version mismatch between A and B
- Electrical noise
- Timing issues
---
## Pin Configuration in Code
**File**: `src/modules/uart_receiver.cpp` (lines 16-21)
```cpp
// UART Configuration
#define UART_RX_PIN 1 // GPIO 1 - Receive from Controller A (Pin 4 on header)
#define UART_TX_PIN 2 // GPIO 2 - Unused (RX-only mode)
#define UART_BAUD_RATE 115200 // Match Controller A
#define UART_SERIAL_PORT Serial1 // Hardware UART1
#define UART_RX_BUFFER_SIZE 256 // Receive buffer size
```
---
**Last Updated**: 2025-11-08
**Status**: ✅ GPIO 1 configured and tested
**Firmware Version**: Phase 2 - UART Reception