Complete IoT monitoring platform for Acuvim II power meters via ESP32. Firmware (Phases 1-7): - ESP32-WROVER-B (TTGO T-Call v1.4) with RS485 Modbus RTU - WiFi STA+AP concurrent mode with GSM/GPRS failover - Transport abstraction layer with 4 priority modes - MQTT protocol with 20 commands, LWT, QoS, exponential backoff - SD card offline buffering with JSONL rotation and non-blocking drain - OTA firmware updates with dual partition rollback protection - Watchdog timer, crash loop detection, Acuvim health monitoring - Captive portal provisioning with AP mode Console backend (Phase 8): - .NET 10 minimal API with PostgreSQL + EF Core - JWT authentication, SignalR real-time updates - MQTTnet 5.x bridge service with health monitoring - Device, telemetry, firmware, alert, group management - Rate limiting, security headers, Swagger/OpenAPI Frontend (Phase 9): - React 18 + TypeScript + Vite with Ant Design 5 - ECharts telemetry visualization, TanStack Query - SignalR live updates, device management UI - Dashboard, fleet management, firmware deployment Testing & Production (Phase 10): - 28 firmware unit tests (Modbus, JSON, config, version) - 23 xUnit backend tests (device, telemetry, command, alert) - Docker Compose with nginx, TLS MQTT, PostgreSQL - Production deployment, commissioning, and troubleshooting docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
247 lines
11 KiB
Markdown
247 lines
11 KiB
Markdown
# Hardware Wiring Guide
|
|
|
|
Wiring diagrams for ESP32 TTGO T-Call v1.4 with RS485 Modbus connection to Acuvim II power meter, optional SD card module, and GSM antenna.
|
|
|
|
---
|
|
|
|
## ESP32 TTGO T-Call v1.4 Pinout (Relevant Pins)
|
|
|
|
```
|
|
┌──────────────┐
|
|
│ TTGO T-Call │
|
|
│ v1.4 │
|
|
3V3 ───┤ 3V3 VIN ├─── 5V
|
|
GND ───┤ GND GND ├─── GND
|
|
┤ GPIO36 GPIO23├─── SPI MOSI (SD)
|
|
┤ GPIO39 GPIO22├───
|
|
┤ GPIO34 GPIO1 ├─── TX0 (USB Serial)
|
|
┤ GPIO35 GPIO3 ├─── RX0 (USB Serial)
|
|
┤ GPIO32 GPIO21├───
|
|
┤ GPIO33 GPIO19├─── SPI MISO (SD)
|
|
┤ GPIO25 GPIO18├─── SPI SCK (SD)
|
|
RS485 DE/RE ───┤ GPIO4 GPIO5 ├─── SD CS
|
|
┤ GPIO0 GPIO17├─── TX2 (RS485 DI)
|
|
┤ GPIO2 GPIO16├─── RX2 (RS485 RO)
|
|
┤ GPIO15 GPIO14├───
|
|
┤ GPIO13 GPIO12├───
|
|
└──────────────┘
|
|
|
|
Built-in SIM800L: GPIO26 (TX), GPIO27 (RX)
|
|
Built-in SIM slot on bottom of board
|
|
```
|
|
|
|
**Note:** The TTGO T-Call v1.4 has SIM800L built into the board. No external GSM module wiring is needed.
|
|
|
|
---
|
|
|
|
## RS485 Module Connection (MAX485 / MAX3485)
|
|
|
|
Connect the ESP32 to an RS485 transceiver module, then to the Acuvim II.
|
|
|
|
### Wiring Table
|
|
|
|
| RS485 Module Pin | ESP32 Pin | Description |
|
|
|------------------|-----------|-------------|
|
|
| DI (Data In) | GPIO17 (TX2) | UART2 transmit |
|
|
| RO (Receiver Out) | GPIO16 (RX2) | UART2 receive |
|
|
| DE (Driver Enable) | GPIO4 | Direction control |
|
|
| RE (Receiver Enable) | GPIO4 | Direction control (active low, tied to DE) |
|
|
| VCC | 3.3V | Power supply |
|
|
| GND | GND | Ground |
|
|
| A | Acuvim II A (+) | RS485 bus positive |
|
|
| B | Acuvim II B (-) | RS485 bus negative |
|
|
|
|
### Wiring Diagram
|
|
|
|
```
|
|
ESP32 TTGO T-Call MAX485 Module Acuvim II
|
|
┌─────────────────┐ ┌──────────────┐ ┌────────────┐
|
|
│ │ │ │ │ │
|
|
│ GPIO17 (TX2) ───┼──────────┤ DI A ├──────────┤ A (+) │
|
|
│ │ │ │ │ │
|
|
│ GPIO16 (RX2) ───┼──────────┤ RO B ├──────────┤ B (-) │
|
|
│ │ │ │ │ │
|
|
│ GPIO4 ──────────┼────┬─────┤ DE │ │ GND ───────┤
|
|
│ │ └─────┤ RE │ │ │
|
|
│ │ │ │ │ │
|
|
│ 3V3 ───────────┼──────────┤ VCC │ │ │
|
|
│ │ │ │ │ │
|
|
│ GND ───────────┼──────────┤ GND │ │ │
|
|
│ │ │ │ │ │
|
|
└─────────────────┘ └──────────────┘ └────────────┘
|
|
```
|
|
|
|
**DE and RE tied together:** GPIO4 drives both pins. HIGH = transmit mode, LOW = receive mode. The firmware toggles this automatically during Modbus transactions.
|
|
|
|
---
|
|
|
|
## Acuvim II RS485 Terminal Block
|
|
|
|
The Acuvim II has an RS485 terminal block on the bottom of the meter.
|
|
|
|
```
|
|
Acuvim II Bottom Terminal Block
|
|
┌─────────────────────────────────┐
|
|
│ ... │ A (+) │ B (-) │ GND │ ...│
|
|
└─────────────────────────────────┘
|
|
```
|
|
|
|
- **A (+):** Connect to MAX485 module A pin
|
|
- **B (-):** Connect to MAX485 module B pin
|
|
- **GND:** Connect to common ground with ESP32
|
|
|
|
### Acuvim II Modbus Settings
|
|
|
|
Configure on the meter's front panel:
|
|
- **Protocol:** Modbus RTU
|
|
- **Address:** 1 (default, configurable 1-247)
|
|
- **Baud Rate:** 9600 (default, configurable)
|
|
- **Parity:** None
|
|
- **Stop Bits:** 1
|
|
|
|
---
|
|
|
|
## SD Card Module Connection (Optional)
|
|
|
|
For offline buffering, connect a standard SPI SD card module.
|
|
|
|
| SD Module Pin | ESP32 Pin | Description |
|
|
|---------------|-----------|-------------|
|
|
| MOSI | GPIO23 | SPI Master Out Slave In |
|
|
| MISO | GPIO19 | SPI Master In Slave Out |
|
|
| SCK | GPIO18 | SPI Clock |
|
|
| CS | GPIO5 | Chip Select |
|
|
| VCC | 3.3V | Power (use 3.3V modules only) |
|
|
| GND | GND | Ground |
|
|
|
|
```
|
|
ESP32 TTGO T-Call SD Card Module
|
|
┌─────────────────┐ ┌──────────────┐
|
|
│ │ │ │
|
|
│ GPIO23 (MOSI) ──┼──────────┤ MOSI 3V3 ├─── 3V3
|
|
│ │ │ │
|
|
│ GPIO19 (MISO) ──┼──────────┤ MISO GND ├─── GND
|
|
│ │ │ │
|
|
│ GPIO18 (SCK) ───┼──────────┤ SCK │
|
|
│ │ │ │
|
|
│ GPIO5 (CS) ─────┼──────────┤ CS │
|
|
│ │ │ │
|
|
└─────────────────┘ └──────────────┘
|
|
```
|
|
|
|
Use a micro SD card formatted as FAT32. The firmware creates the `/telemetry/` directory on first use.
|
|
|
|
---
|
|
|
|
## SIM Card Insertion
|
|
|
|
The TTGO T-Call v1.4 has a SIM card slot on the bottom of the board.
|
|
|
|
```
|
|
Bottom of TTGO T-Call v1.4
|
|
┌─────────────────────────────┐
|
|
│ │
|
|
│ ┌─────────────────┐ │
|
|
│ │ SIM Card Slot │ │
|
|
│ │ (micro SIM) │ │
|
|
│ │ Insert with │ │
|
|
│ │ contacts DOWN │ │
|
|
│ └─────────────────┘ │
|
|
│ │
|
|
└─────────────────────────────┘
|
|
```
|
|
|
|
- Use a **micro SIM** (not nano — use adapter if needed)
|
|
- Insert with contacts facing **down** toward the PCB
|
|
- SIM must have data plan enabled
|
|
- SIM PIN must be disabled (or configure PIN in firmware)
|
|
|
|
---
|
|
|
|
## GSM Antenna
|
|
|
|
The TTGO T-Call v1.4 has an IPX (U.FL) connector for the GSM antenna.
|
|
|
|
- Attach the supplied GSM antenna to the IPX connector
|
|
- For better signal in metal enclosures, use an external antenna with SMA connector and IPX-to-SMA pigtail
|
|
- Position antenna away from the ESP32 and RS485 module to reduce interference
|
|
|
|
---
|
|
|
|
## Power Supply
|
|
|
|
### USB Power (Development)
|
|
|
|
Connect micro-USB cable to the TTGO T-Call. Provides 5V via USB.
|
|
|
|
### External Power (Production)
|
|
|
|
| Parameter | Value |
|
|
|-----------|-------|
|
|
| Input voltage | 5V DC (via VIN pin) |
|
|
| Current requirement | 500mA minimum (GSM peaks at 2A) |
|
|
| Recommended supply | 5V 2A regulated DC adapter |
|
|
|
|
For GSM operation, a supply capable of 2A peak current is required due to SIM800L transmission bursts.
|
|
|
|
```
|
|
DC Power Supply ESP32 TTGO T-Call
|
|
┌──────────────┐ ┌──────────────────┐
|
|
│ │ │ │
|
|
│ +5V ─────────┼────────────┤ VIN │
|
|
│ │ │ │
|
|
│ GND ─────────┼────────────┤ GND │
|
|
│ │ │ │
|
|
└──────────────┘ └──────────────────┘
|
|
```
|
|
|
|
**Do not power via USB and VIN simultaneously** unless the USB is only for serial monitoring.
|
|
|
|
---
|
|
|
|
## Complete Wiring Diagram
|
|
|
|
```
|
|
ESP32 TTGO T-Call v1.4
|
|
┌───────────────────────┐
|
|
│ │
|
|
┌─────────┐ GPIO17 (TX2)──┤ 3V3──┼──┐
|
|
│ MAX485 ├──DI │ │ │
|
|
│ │ │ GND──┼──┼──┐
|
|
│ ├──RO──GPIO16 (RX2)┤ │ │ │
|
|
│ │ │ [SIM800L BUILT-IN] │ │ │
|
|
│ ├──DE──GPIO4───────┤ [SIM SLOT BOTTOM] │ │ │
|
|
│ ├──RE──┘ │ │ │ │
|
|
│ │ │ GPIO23───┼──┼──┼──MOSI──┐
|
|
│ VCC───┼──────────────────┼── 3V3 │ │ │ │
|
|
│ GND───┼──────────────────┼── GND GPIO19───┼──┼──┼──MISO─┤ SD Card
|
|
│ │ │ GPIO18───┼──┼──┼──SCK──┤ Module
|
|
│ A────┼──Acuvim A (+) │ GPIO5────┼──┼──┼──CS───┤
|
|
│ B────┼──Acuvim B (-) │ │ │ │ VCC──┘
|
|
└─────────┘ │ │ └──┼──GND
|
|
│ VIN──────┼──5V │
|
|
GSM Antenna ─────IPX─┤ │ │
|
|
└───────────────────────┘ │
|
|
│
|
|
┌─────────────────┐ │
|
|
│ Acuvim II │ │
|
|
│ RS485 Terminal │ │
|
|
│ A (+) ├─ MAX485 A│
|
|
│ B (-) ├─ MAX485 B│
|
|
│ GND ├──────────┘
|
|
└─────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## Cable Recommendations
|
|
|
|
| Connection | Cable Type | Max Length |
|
|
|------------|-----------|-----------|
|
|
| RS485 (ESP32 to Acuvim) | Shielded twisted pair (STP), 22-24 AWG | 1200m |
|
|
| SPI (ESP32 to SD) | Short jumper wires | 15cm |
|
|
| USB (development) | Micro-USB data cable | 2m |
|
|
| Power (production) | 22 AWG stranded | 3m |
|
|
|
|
For RS485 runs over 10m, use 120 ohm termination resistors at each end of the bus.
|