# hytte_link LoRa-basert sensorlink mellom hytte og hjemme. Sender temperatur (inne/ute), batterispenning og SOC fra 12V-anlegg på hytta til MQTT-broker hjemme (alu). ## Arkitektur ``` Hytte: DS18B20 (inne/ute) ──┐ Victron MPPT (BLE) ──┤ JBD BMS (BLE) ────── ESP32 (ESPHome, cabin_tech) ──WiFi──► MQTT (lokal HA) │ XIAO ESP32S3 + Wio-SX1262 ◄──MQTT────┘ (cabin_node) │ LoRa SF12 868 MHz ▼ 15–20 km Hjemme: XIAO ESP32S3 + Wio-SX1262 (cabin_gw) │ MQTT publish ▼ mosquitto (alu, 192.168.86.31) │ Home Assistant hjemme ``` ## Bygging (PlatformIO) ```bash pio run -e cabin_node # hytte-node pio run -e cabin_gw # hjemme-gateway pio run -e cabin_node -t upload pio run -e cabin_gw -t upload ``` ## ESPHome (cabin_tech) ```bash esphome run esphome/cabin_tech.yaml ``` ## Secrets Kopier `include/secrets.example.h` → `include/secrets.h` og fyll inn. Kopier `esphome/secrets.yaml.example` → `esphome/secrets.yaml` og fyll inn. ## LoRa-parametere | Parameter | Verdi | |-------------|--------| | Frekvens | 868 MHz | | SF | 12 | | BW | 125 kHz | | CR | 4/5 | | Sync word | 0xAB | | Airtime | ~1.3 s | ## Pakkeformat (CabinPacket, 12 bytes) | Felt | Type | Enhet | |--------------|---------|-----------| | magic | uint8 | 0xCA | | seq | uint8 | rullende | | temp_in_x10 | int16 | °C × 10 | | temp_out_x10 | int16 | °C × 10 | | batt_mv | uint16 | mV | | batt_pct | uint8 | 0–100 | | sig | uint32 | HMAC-SHA256 (trunkert) | ## Pinner (Wio-SX1262 på XIAO ESP32S3) Verifiser mot Seeed-skjema før flashing: - NSS: GPIO44 (D7) - RST: GPIO43 (D6) - DIO1: GPIO2 (D1) - BUSY: GPIO1 (D0) ## MQTT-topics | Topic | Retning | |------------------------|----------------------| | hytte/sensor/temp_inne | ESPHome → cabin_node | | hytte/sensor/temp_ute | ESPHome → cabin_node | | hytte/sensor/batt_mv | ESPHome → cabin_node | | hytte/sensor/batt_pct | ESPHome → cabin_node | | hytte/lora/status | cabin_gw → alu |