How sebaubuntu/simplesimhubarduino works
Project Type and Purpose
• This is an embedded integration adapter for Arduino (SimpleSimHubArduino).
• It reads game telemetry from SimHub over the custom serial protocol, decodes it, and drives a car instrument cluster via a CAN bus (MCP2515 CAN controller).
File Structure Analysis
• Top-level files:
• SimpleSimHubArduino.ino – main Arduino sketch
• Various headers (.h) implementing serial I/O, protocol, debouncing, ring buffer, button handling, LED backpack driver, PWM frequency helper
• src/ directory – C++ modules:
• CanFuzzer (generates CAN frames)
• MessageDebouncer (debounces incoming CAN messages)
• StateHolder (holds decoded SimHub state)
• Cluster.h (abstract cluster interface)
• src/clusters/ – one subfolder per supported car cluster (Citroën C5 II, Peugeot 208 I, 3008 I, multifunction display), each with its own Cluster.h, commands.h, README
• Configuration: SHCustomProtocol.h selects which cluster to compile in
README Insights
• Explains hardware BOM (Arduino, MCP2515, cluster, wiring)
• Defines the SimHub custom protocol format (semicolon-separated telemetry values)
• Usage steps: install libraries, enable cluster, wire, upload, configure SimHub
Main Components
a. External Systems & Hardware
• PC running SimHub (sends telemetry via USB-serial)
• Arduino board (runs the sketch)
• MCP2515 CAN module (connected via SPI)
• Car instrument cluster (12 V CAN bus node)
b. Software Modules on Arduino
• Serial I/O & SHCustomProtocol parser (reads raw custom message, populates State struct)
• StateHolder (central store for all telemetry variables)
• MessageDebouncer (filters incoming CAN if two-way communication is needed)
• CanFuzzer / Cluster command generator (translates State into CAN frames using cluster’s commands.h)
• MCP2515 library interface (sends frames onto CAN bus)
• Cluster-specific logic (in src/clusters/…) selected at compile time
Architectural Patterns & Design Principles
• Modular abstraction of clusters: common interface (Cluster.h) + per-cluster commands file
• Separation of concerns: parsing, state management, message generation, hardware I/O
• Compile-time feature selection: only include one cluster implementation to reduce code size
• Debouncing filter for CAN bus noise or two-way messages
Essential Elements
• Component labels (e.g., “SHCustomProtocol Parser,” “StateHolder”)
• Notes on configuration: “Enabled via SHCustomProtocol.h”