diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dc1f11f --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +run: + python3 simulator/app.py + +venv: + python3 -m venv .venv + +install: + . .venv/bin/activate && pip install -r simulator/requirements.txt diff --git a/README.md b/README.md index b6fe57d..02bfc09 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,4 @@ A custom monitoring and control system for a Nissan Xterra using: 3. ESP32 communications 4. Temperature sensors 5. JBD/Xiaoxiang BMS integration -6. Logging and dashboards +6. Future integrations / optional logging diff --git a/docs/api.md b/docs/api.md index a9ceb5e..2069a28 100644 --- a/docs/api.md +++ b/docs/api.md @@ -4,7 +4,7 @@ The ESP32 acts as the system controller and provides status and control endpoints. -Primary communication is RS-485. +Primary communication is UART over CAT5. WiFi HTTP API is the backup communication path. WiFi HTTP API is provided for: @@ -48,7 +48,7 @@ Example: "network": { "wifi_enabled": false, - "rs485_connected": true + "uart_connected": true } } ``` @@ -167,7 +167,7 @@ Example: ```json { "wifi_enabled": false, - "rs485_connected": true, + "uart_connected": true, "starlink_enabled": false } ``` diff --git a/docs/architecture.md b/docs/architecture.md index 96878ed..524b8ea 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -19,7 +19,7 @@ The system provides: - Raspberry Pi Pico 2 W - 3.5" SPI Capacitive Touchscreen -- RS-485 communications +- UART-over-CAT5 communications - WiFi backup communications ### Responsibilities @@ -36,7 +36,7 @@ The system provides: ### Hardware - ESP32 Relay Controller -- RS-485 Interface +- UART-over-CAT5 interface - House Battery Interface - DS18B20 Temperature Sensor Bus - Bosch Relay Drivers @@ -52,7 +52,7 @@ The system provides: ## Communications Primary: -- RS-485 +- UART over CAT5 Backup: - WiFi HTTP API diff --git a/docs/dashboard-ui.md b/docs/dashboard-ui.md index 8be8187..e59f0f4 100644 --- a/docs/dashboard-ui.md +++ b/docs/dashboard-ui.md @@ -52,14 +52,14 @@ Future: ## System Screen Displays: -- RS-485 Status +- UART Status - WiFi Status - Message Counts - Latency - Packet Loss Testing: -- RS-485 Disconnect +- UART Disconnect - Sensor Fault Simulation - Ignition Simulation diff --git a/docs/roadmap.md b/docs/roadmap.md index b057170..3a815be 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -8,7 +8,7 @@ Features: - Dashboard UI - Alarm System - Sensor Simulation -- RS-485 Simulation +- UART Communication Simulation - Protocol Layer ## Phase 2 — Pico Dashboard @@ -26,7 +26,7 @@ Status: Pending Features: - Relay Control -- RS-485 Communications +- UART Communications - Configuration Storage ## Phase 4 — DS18B20 Sensors diff --git a/firmware/esp32/xterra-controller/config.h b/firmware/esp32/xterra-controller/config.h index a61ce5a..bf287dd 100644 --- a/firmware/esp32/xterra-controller/config.h +++ b/firmware/esp32/xterra-controller/config.h @@ -12,7 +12,8 @@ // Ignition Sense #define IGNITION_PIN 34 -// Future RS485 -#define RS485_TX_PIN 21 -#define RS485_RX_PIN 22 -#define RS485_DE_PIN 23 +// UART over CAT5 to Pico dashboard +#define UART_TX_PIN 21 +#define UART_RX_PIN 22 + +// RS-485/MAX3485 fallback only; not currently planned diff --git a/firmware/esp32/xterra-controller/xterra-controller.ino b/firmware/esp32/xterra-controller/xterra-controller.ino index 93212fd..1a602e7 100644 --- a/firmware/esp32/xterra-controller/xterra-controller.ino +++ b/firmware/esp32/xterra-controller/xterra-controller.ino @@ -50,7 +50,7 @@ void handleStatus() { JsonObject network = doc.createNestedObject("network"); network["wifi_enabled"] = true; - network["rs485_connected"] = true; + network["uart_connected"] = true; String output; serializeJsonPretty(doc, output); diff --git a/hardware/bom.md b/hardware/bom.md index ca54ea2..23ff231 100644 --- a/hardware/bom.md +++ b/hardware/bom.md @@ -8,7 +8,6 @@ ## Required -- 2x MAX3485 RS-485 Modules - 4x DS18B20 Waterproof Sensors - 12V→5V Buck Converter - CAT5 Cable @@ -17,8 +16,9 @@ - Automotive Fuse Block - Assorted ATC Fuses -## Future +## Future / Optional Fallback +- 2x MAX3485 RS-485 Modules, only if UART over CAT5 proves unreliable - Pi Zero 2 W - GPS Module - ELM327 OBD-II Interface diff --git a/hardware/esp32-pinout.md b/hardware/esp32-pinout.md index 2fdc033..ac20ec6 100644 --- a/hardware/esp32-pinout.md +++ b/hardware/esp32-pinout.md @@ -5,9 +5,10 @@ GPIO 17 Relay 2 (Fridge) GPIO 4 DS18B20 Bus -GPIO 21 RS-485 TX -GPIO 22 RS-485 RX -GPIO 23 RS-485 DE/RE +GPIO 21 UART TX to Pico over CAT5 +GPIO 22 UART RX from Pico over CAT5 + +RS-485/MAX3485 is fallback only and not currently planned. GPIO 34 Ignition Sense diff --git a/simulator/app.py b/simulator/app.py index 45d3f49..304174b 100644 --- a/simulator/app.py +++ b/simulator/app.py @@ -96,16 +96,16 @@ def comms(): return jsonify(pico.get_comms()) -@app.route("/comms/rs485/disconnect", methods=["POST"]) -def disconnect_rs485(): - pico.disconnect_rs485() - return jsonify({"success": True, "rs485_connected": False}) +@app.route("/comms/uart/disconnect", methods=["POST"]) +def disconnect_uart(): + pico.disconnect_uart() + return jsonify({"success": True, "uart_connected": False}) -@app.route("/comms/rs485/restore", methods=["POST"]) -def restore_rs485(): - pico.restore_rs485() - return jsonify({"success": True, "rs485_connected": True}) +@app.route("/comms/uart/restore", methods=["POST"]) +def restore_uart(): + pico.restore_uart() + return jsonify({"success": True, "uart_connected": True}) @app.route("/comms/latency", methods=["POST"]) diff --git a/simulator/esp32_sim.py b/simulator/esp32_sim.py index bfd47f1..fbcdde8 100644 --- a/simulator/esp32_sim.py +++ b/simulator/esp32_sim.py @@ -198,7 +198,7 @@ class ESP32Simulator: "network": { "wifi_enabled": starlink_on or wifi_override_active, "wifi_override_active": wifi_override_active, - "rs485_connected": True, + "uart_connected": True, "starlink_enabled": starlink_on }, diff --git a/simulator/pico_sim.py b/simulator/pico_sim.py index 0b85bd0..57d766e 100644 --- a/simulator/pico_sim.py +++ b/simulator/pico_sim.py @@ -7,14 +7,14 @@ from protocol import ( toggle_ignition_request, toggle_sensor_fault_request, ) -from transport import RS485Transport +from transport import UARTTransport class PicoSimulator: def __init__(self, controller): - self.transport = RS485Transport(controller) + self.transport = UARTTransport(controller) self.last_status = None - self.primary_link = "rs485" + self.primary_link = "uart" self.backup_link_available = True self.messages_sent = 0 self.messages_received = 0 @@ -40,7 +40,7 @@ class PicoSimulator: if response.get("type") == "error": if self.last_status: - self.last_status["network"]["rs485_connected"] = False + self.last_status["network"]["uart_connected"] = False self.last_status["network"]["communication_lost"] = True self.add_comms_to_status(self.last_status) return self.last_status @@ -53,7 +53,7 @@ class PicoSimulator: "sensor_health": {}, "relays": {}, "network": { - "rs485_connected": False, + "uart_connected": False, "communication_lost": True, "wifi_enabled": False, "wifi_override_active": False, @@ -63,7 +63,7 @@ class PicoSimulator: } self.last_status = response["data"] - self.last_status["network"]["rs485_connected"] = self.transport.connected + self.last_status["network"]["uart_connected"] = self.transport.connected self.last_status["network"]["communication_lost"] = False self.add_comms_to_status(self.last_status) return self.last_status @@ -87,10 +87,10 @@ class PicoSimulator: def toggle_sensor_fault(self, sensor): return self.send_message(toggle_sensor_fault_request(sensor)) - def disconnect_rs485(self): + def disconnect_uart(self): self.transport.disconnect() - def restore_rs485(self): + def restore_uart(self): self.transport.restore() def set_latency(self, latency_ms): @@ -103,7 +103,7 @@ class PicoSimulator: return { "primary": self.primary_link, "backup_available": self.backup_link_available, - "rs485_connected": self.transport.connected, + "uart_connected": self.transport.connected, "messages_sent": self.messages_sent, "messages_received": self.messages_received, "last_message_time": self.last_message_time, diff --git a/simulator/templates/index.html b/simulator/templates/index.html index ef41eb9..666847f 100644 --- a/simulator/templates/index.html +++ b/simulator/templates/index.html @@ -24,7 +24,7 @@

Xterra Dashboard

-
RS-485: -- | WiFi: --
+
UART: -- | WiFi: --
@@ -82,7 +82,7 @@

System

-
RS-485 --
+
UART --
WiFi --
WiFi Override --
Ignition --
@@ -101,8 +101,8 @@
Packet Loss --
- - + +