1. Executive Overview
This technical blueprint documents the production architecture for OurSiamDream's distributed solar microgrids deployed across rural and peri-urban hubs in Thailand (including demonstration sites in Hua Hin, Chiang Mai, and Krabi). The system combines off-grid and hybrid photovoltaic (PV) arrays, lithium iron phosphate (LiFePO4) battery energy storage systems (BESS), and an edge telemetry gateway delivering real-time energy accounting.
The edge architecture solves three recurring rural operational challenges:
- Unstable Cellular Backhaul: Intermittent 4G/LTE coverage during monsoon seasons.
- Multi-Vendor Inverter Protocols: Disparate proprietary registers from Deye, Growatt, and Victron hardware.
- Severe Power Spikes: Tropical lightning strikes and grid surge transients.
2. High-Level Architectural Topology
+-------------------------------------------------------+
| Rooftop PV Arrays |
| (48V String / 8.5 kWp Peak) |
+---------------------------+---------------------------+
|
v
+-------------------------------------------------------+
| Hybrid Inverter / MPPT Charge Controller |
| (Modbus RTU over RS-485 2-Wire Half-Duplex) |
+---------------------------+---------------------------+
|
Isolated RS-485 Bus (9600 baud, 8N1)
v
+-------------------------------------------------------+
| OurSiamDream Edge Gateway (CM4 / ESP32-S3) |
| - Modbus Poller Daemon (1 Hz Sample Rate) |
| - SQLite FIFO Ring Buffer (14-Day Offline Storage) |
| - Local OLED Status Display & Modbus Gateway |
| - MQTT Publisher Engine (mTLS v1.3 Auth) |
+---------------------------+---------------------------+
|
Cellular 4G LTE / LoRaWAN Uplink / Starlink
v
+-------------------------------------------------------+
| Central OurSiamDream Telemetry Mesh |
| (EMQX Broker -> InfluxDB v3 -> Grafana Dashboard) |
+-------------------------------------------------------+
3. Hardware Bill of Materials (BOM) & Specifications
| Component | Part Number | Purpose | Operating Range |
|---|---|---|---|
| Industrial Compute Gateway | RPi CM4 eMMC / ESP32-S3-WROOM | Edge polling and data transformation | -20°C to +75°C, 5V DC |
| Isolated RS-485 Transceiver | ADM2483BRWZ (Galvanic Isolation) | High-voltage noise rejection & Modbus | 2.5 kV RMS isolation |
| Current & Voltage Sensor | PZEM-016 Modbus AC / LEM DC Shunt | Dual-channel bidirectional metering | 0-100A, 80-260V AC |
| Cellular Modem | Quectel EC25-E Mini PCIe | 4G/LTE Cat-4 fall-back communication | B1/B3/B5/B7/B8/B20 |
| Surge Protection Device (SPD) | Type 1+2 DC 600V DIN Surge Arrester | Lightning protection on PV inputs | Up to 40 kA discharge |
4. Edge Telemetry Polling Implementation
Below is the verified production Python daemon running as a systemd service on the edge gateway, querying inverter registers via pymodbus and buffering metrics into SQLite.
import time
import sqlite3
import json
import ssl
import paho.mqtt.client as mqtt
from pymodbus.client import ModbusSerialClient
# Configuration
MODBUS_PORT = "/dev/ttyUSB0"
MODBUS_BAUD = 9600
INVERTER_SLAVE_ID = 0x01
MQTT_BROKER = "telemetry.oursiamdream.com"
MQTT_PORT = 8883
DEVICE_ID = "OSD-SOLAR-HH-04"
# Local SQLite Ring-Buffer
conn = sqlite3.connect('/var/lib/oursiamdream/telemetry.db', check_same_thread=False)
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS metrics_queue (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp INTEGER NOT NULL,
payload TEXT NOT NULL,
synced INTEGER DEFAULT 0
)
''')
conn.commit()
def poll_inverter():
client = ModbusSerialClient(
port=MODBUS_PORT,
baudrate=MODBUS_BAUD,
stopbits=1,
bytesize=8,
parity='N',
timeout=1.0
)
if not client.connect():
return None
# Read Input Registers: [0x0001: PV Voltage, 0x0002: PV Current, 0x0003: Batt SOC %]
result = client.read_input_registers(address=0x0001, count=3, slave=INVERTER_SLAVE_ID)
client.close()
if result.isError():
return None
pv_voltage = result.registers[0] * 0.1
pv_current = result.registers[1] * 0.1
battery_soc = result.registers[2]
power_watts = pv_voltage * pv_current
return {
"device_id": DEVICE_ID,
"timestamp": int(time.time()),
"pv_voltage_v": round(pv_voltage, 2),
"pv_current_a": round(pv_current, 2),
"power_w": round(power_watts, 2),
"battery_soc_pct": battery_soc
}
5. Deployment Verification Checklist
- Verify DC disconnect switch isolates inverter from solar string under open circuit voltage (V_{oc}).
- Ensure RS-485 termination resistor (120 \Omega) is activated at the furthest bus endpoint.
- Confirm ground resistance measurement is under 5\,\Omega using digital earth tester.
- Test physical disconnect of 4G antenna to ensure queue buffers locally without RAM leaks.
- Validate TLS 1.3 handshake with client certificate authentication against central EMQX broker.
- Verify automatic reconnection back-off interval (exponential: 2s, 4s, 8s... max 60s).