MiniSatellite Testbed
System Architecture
Unity C#
Magnetic Field Physical Simulation
🧲 Simulation Physics engine core
BiotSavartSolver.cs B-field from coil currents
DipoleFieldGenerator.cs Ideal dipole approximations
FieldVector3Grid.cs Discretized 3D field grid
OrbitalMagneticModel.cs IGRF/WMM orbital B-field ref
TimeStepController.cs Fixed Δt physics loop
🎨 Visualization 3D rendering & overlays
FieldLineRenderer.cs GPU instanced B-vector lines
HeatmapOverlay.cs |B| magnitude color map
SatelliteAttitudeGizmo.cs Quaternion orientation gizmo
🌐 Networking WebSocket comms
WebSocketClient.cs Connect to Python orchestrator
SimStateSerializer.cs JSON / MessagePack packing
CommandReceiver.cs Receive coil current setpoints
🖥️ UI In-editor controls
SimControlPanel.cs Play/pause, field sliders
TelemetryOverlay.cs FPS, |B| readout
IN: Coil current commands OUT: B-field vectors, torque
WebSocket
Python
Orchestrator — FastAPI + asyncio
⚙️ Core State machine & config
orchestrator.py IDLE → CONFIG → RUN → LOG
scheduler.py Periodic task dispatch
config.py YAML/TOML config loader
📡 Communication All network bridges
ws_unity_bridge.py WS server ↔ Unity
ws_arduino_bridge.py WS server ↔ ESP32s
🔌 REST API FastAPI endpoints
GET /api/telemetry Latest sensor readings
GET /api/status System health & state
POST /api/command Manual override commands
WS /ws/stream Real-time push to React
messages.py Pydantic: SensorFrame, CoilCmd
codec.py JSON / MessagePack codec
🎯 Control Attitude & field algorithms
attitude_controller.py B-dot / PD detumbling
field_mapper.py Desired B → coil currents
orbit_propagator.py SGP4 / Keplerian orbit model
safety_monitor.py Current limits, thermal WD
💾 Data Logging & sessions
logger.py InfluxDB / CSV writer
session.py Test session mgmt
models.py Pydantic ORM models
IN: B-field from Unity IN: Sensors from ESP32 OUT: Coil cmds to Arduino OUT: Telemetry to React
REST / Socket
React TS
Telemetry Display — Vite + React 18
🔗 API Layer REST + WebSocket clients
restClient.ts Axios, retry, interceptors
wsClient.ts Auto-reconnect WS hook
types.ts TS interfaces ↔ Pydantic
📦 Stores Zustand state management
telemetryStore.ts Ring-buffer SensorFrames
commandStore.ts Pending & sent commands
systemStore.ts Connection, session info
📊 Telemetry Components Real-time visualizations
AttitudeIndicator.tsx 3D quaternion globe (R3F)
MagFieldChart.tsx Bx/By/Bz line chart
AccelChart.tsx Accelerometer Ax/Ay/Az
CoilCurrentGauge.tsx 3 radial gauges
SensorTable.tsx Raw numeric table
🎛️ Controls Manual & session controls
ManualOverridePanel.tsx Coil current sliders
OrbitSelector.tsx Orbital scenario picker
SessionControls.tsx Start/stop/export session
🪝 Hooks & Utils Shared logic
useTelemetryStream.ts WS subscription hook
useChartData.ts Downsample / window data
quaternionMath.ts Quat → Euler, SLERP
IN: WS telemetry stream IN: REST snapshots OUT: Commands via REST POST
WebSocket (WiFi)
C++ Arduino
ESP32 Firmware — PlatformIO
🔧 Shared Modules Common to both firmwares
Protocol.h Packed message structs
CRC8.h Packet checksum
PinConfig.h GPIO pin mapping
WiFiManager.cpp STA connect, mDNS
WebSocketHandler.cpp WS client ↔ Python
🧲 Emulator Firmware Helmholtz cage ESP32
CoilDriver.cpp PWM → 3 coil channels
RelayController.cpp H-bridge polarity switching
CurrentSensor.cpp INA219 / ACS712 feedback
StatusLED.cpp WS2812 status indicator
🛰️ Satellite Firmware MiniSat ESP32
📡 SensorHub Aggregate all sensors
Magnetometer.cpp QMC5883L I²C → µT
Accelerometer.cpp MPU6050 I²C → m/s²
IMUFusion.cpp Madgwick → quaternion
Magnetorquer.cpp PWM coil driver + B-dot
Camera.cpp JPEG capture + MJPEG srv
Telemetry.cpp SensorFrame packing
Emulator IN: CoilCommand Emulator OUT: CurrentFeedback Satellite IN: TorquerCmd Satellite OUT: SensorFrame
⚙ Physical Layer
Magnetic Field Emulator
Helmholtz Cage — 3-Axis
📟 ESP32 DevKit V1 Main controller
WiFi 802.11 b/g/n Lab router / AP
GPIO 25, 26, 27 PWM → MOSFET drivers
GPIO 32, 33, 34 (ADC) Current sense feedback
I²C (GPIO 21/22) INA219 monitors ×3
GPIO 4 WS2812 status LED
Power Supply 30V / 10A bench PSU
+V_COIL rail Feeds 3 H-bridges
+5V / +3.3V LDO Logic & ESP32 power
🧲 Coils ×3 (X/Y/Z) Helmholtz pairs
~100 turns, 15cm radius Per pair
Max field: ~2 mT/axis At center
R ≈ 2Ω, L ≈ 5 mH Per coil
🔌 H-Bridge ×3 BTS7960 / L298N
PWM input Duty → current magnitude
Direction pins Field polarity control
Current sense output Feedback → ESP32 ADC
🛡️ Safety Systems Protection & E-stop
Thermal fuses On each coil
Software watchdog No heartbeat → shutdown
Hardware E-stop Cuts V_COIL relay
MiniSatellite
1U Test Article — Free Rotation
📟 Main ESP32 WROOM-32 controller
WiFi 802.11 b/g/n Telemetry uplink
I²C Bus Mag + Accel sensors
PWM ×3 Magnetorquer drivers
UART → ESP32-CAM Camera trigger / xfer
ADC Battery voltage monitor
📷 ESP32-CAM OV2640 — 2MP JPEG
MJPEG HTTP server LAN streamable
PSRAM 4MB Frame buffer
microSD slot On-board image storage
🧭 Magnetometer QMC5883L — I²C 0x0D
3-axis B-field sensing ±800 µT range
Resolution: 0.2 µT 12-bit ADC
Calibration Hard-iron + soft-iron matrix
📐 IMU — MPU6050 6-DOF — I²C 0x68
Accelerometer ±16g Configurable range
Gyroscope ±2000°/s Angular rate sensing
Madgwick / Mahony Attitude fusion → quat
🔄 Magnetorquer ×3 Air-core / PCB coils
N-ch MOSFET + PWM Per-axis drive
Max dipole: ~0.1 Am² Scaled for testbed
B-dot detumble On-board fallback ctrl
🔋 Power System LiPo + LDO
Li-Po 3.7V 1000mAh Main battery
3.3V LDO regulator Logic rail
Voltage divider → ADC Battery monitoring
📦 Structure ~10cm cube frame
3D-printed frame PLA / PETG
Air bearing mount Free 3-axis rotation
CoM aligned To rotation point