=============================================================================== PHISUALIZE IT: THE SCIENCE - TURNING SIGNALS INTO MEANING Detailed Scientific Analysis of 10 Invisible Phenomena =============================================================================== This document explains the physics, mathematics, and signal processing behind each phenomenon detected by PHISUALIZE IT!. =============================================================================== 1. MECHANICAL VIBRATIONS (IMU - BMI270 Accelerometer) =============================================================================== PHYSICAL PRINCIPLE: Mechanical vibrations are oscillatory movements measured as acceleration variations. The device detects vibrations through dynamic changes in the acceleration vector, removing static gravity component. SENSOR: BMI270 (3-axis accelerometer) SAMPLING RATE: 90 Hz UNIT: g RMS (root-mean-square acceleration, where 1g = 9.81 m/s²) SIGNAL PROCESSING CHAIN: 1) Raw Acceleration (3D vector): a_total(t) = [ax(t), ay(t), az(t)] Where a_total includes both: - Static component: gravity (~1g constant) - Dynamic component: vibrations (AC signal) 2) High-Pass Filtering (gravity removal): Each axis filtered independently with α = 0.88: y[n] = (x[n] - x[n-1]) + α·y[n-1] Cutoff frequency: fc ≈ (1-α)·fs/(2π) = 0.12×90/6.28 ≈ 1.7 Hz This removes DC (gravity) and keeps AC (vibrations > 1.7 Hz) 3) Magnitude Vector (orientation-invariant): ||a_dyn(t)|| = √(ax_filt² + ay_filt² + az_filt²) Result: scalar representing total vibrational energy regardless of direction 4) FFT Analysis (N=128 samples): Window: 128/90 = 1.42 seconds Resolution: 90/128 ≈ 0.7 Hz per bin Spectral amplitude: A(f) = |FFT{a_dyn(t)}| Dominant frequency: f_dom = argmax(A(f)) Dominant amplitude: A_max = max(A(f)) 5) Normalization for display: Energy_normalized = A_max / 0.10g Brightness = 30 + (Energy_normalized × 225) Reference: 0.10g = strong vibration (walking, transport) TYPICAL VALUES: - Baseline noise: 0.001 - 0.005 g - Detectable vibrations: > 0.01 g - Strong impact: > 0.5 g =============================================================================== 2. AUDIO SPECTRUM (PDM Microphone MP34DT06JTR) =============================================================================== PHYSICAL PRINCIPLE: Sound waves are pressure variations in air detected by microphone membrane. Structured sounds (voice, music) have harmonic content, while electromagnetic interference produces flat/noisy spectrum. SENSOR: MP34DT06JTR (PDM digital microphone) SAMPLING RATE: 16 kHz UNIT: Arbitrary spectral amplitude (normalized 0-255 per band) SIGNAL PROCESSING CHAIN: 1) PDM to PCM Conversion: Raw PDM bitstream → 16-bit signed integers (-32768 to +32767) 2) High-Pass Filtering (DC removal): α = 0.962, fc ≈ 1 Hz @ fs=16kHz Removes DC offset and thermal drift without affecting 50 Hz mains interference (relevant for EMI detection) 3) Peak Detection (silence threshold): Peak = max(|sample[i]|) for i ∈ [0, 127] If Peak < 15 → Digital silence (below ADC noise floor ~-90 dBFS) 4) FFT Analysis (N=128 samples): Window: 128/16000 = 8 ms Resolution: 16000/128 = 125 Hz per bin Magnitude spectrum: |X(f)| = √(Re² + Im²) 5) 8-Band Harmonic Decomposition: Bands aligned with 125 Hz resolution: Band 0: 0-125 Hz (mains 50 Hz + low fundamentals) Band 1: 125-250 Hz (H1 = 125 Hz) Band 2: 250-375 Hz (H2 = 250 Hz) Band 3: 375-500 Hz (H3 = 375 Hz) Band 4: 500-625 Hz (H4 = 500 Hz) Band 5: 625-750 Hz (H5 = 625 Hz) Band 6: 750-875 Hz (H6 = 750 Hz) Band 7: 875-1000 Hz (H7 = 875 Hz) Each band: Average magnitude of corresponding FFT bins Normalization: FIXED scale (50.0) + logarithmic compression 6) Color Mapping: Rainbow spectrum: Red → Orange → Yellow → Green → Cyan → Blue → Magenta → Violet Each band gets unique color representing its frequency range TYPICAL VALUES: - Silence: < 0.002 FFT amplitude - Speech: 0.05 - 0.15 FFT amplitude - Loud music: > 0.20 FFT amplitude =============================================================================== 3. EMI INTERFERENCE (Same PDM Microphone - Dual Mode) =============================================================================== PHYSICAL PRINCIPLE: Electromagnetic interference (switching power supplies, motors, radio) induces currents in microphone circuitry, producing acoustic artifacts with flat spectrum (white/pink noise) unlike structured audio harmonics. INNOVATION: Single sensor dual classification via spectral analysis CLASSIFICATION METHOD - Spectral Flatness Measure (SFM): SFM = Geometric_Mean / Arithmetic_Mean Mathematically: exp(1/N × Σ log|X(f)|) SFM = ───────────────────────── 1/N × Σ|X(f)| Where N = number of valid frequency bins INTERPRETATION: - SFM → 1.0: Flat spectrum (all frequencies equal) = White noise = EMI - SFM → 0.0: Peaked spectrum (few harmonics) = Structured sound = Audio DECISION THRESHOLDS (with hysteresis): 1) If SFM > 0.45 → EMI (electromagnetic interference) 2) If SFM < 0.40 → AUDIO (voice, music) 3) If 0.40 ≤ SFM ≤ 0.45 → Keep previous state (prevents oscillation) AMPLITUDE THRESHOLD: If amplitude < 0.002 → Classify as EMI (thermal noise floor) VISUALIZATION: EMI displays as colored "snow" - random pixels weighted by spectral content Number of pixels proportional to total spectral energy TYPICAL EMI SOURCES: - Switching power supplies (50-150 kHz fundamental, audio harmonics) - Electric motors (brush noise) - Wi-Fi/Bluetooth (2.4 GHz with audio-range modulation artifacts) - LED drivers (PWM artifacts) =============================================================================== 4. MAGNETIC FIELD (BMM150 Magnetometer) =============================================================================== PHYSICAL PRINCIPLE: Earth's magnetic field is ~25-65 µT depending on location. Ferromagnetic objects (iron, steel) locally distort this field. Movement of permanent magnets or current-carrying conductors creates detectable variations. SENSOR: BMM150 (3-axis magnetometer) SAMPLING RATE: ~50 Hz UNIT: µT (microtesla) MEASUREMENT: 1) Raw 3D Magnetic Vector: B(t) = [Bx(t), By(t), Bz(t)] in µT 2) Total Field Magnitude: ||B|| = √(Bx² + By² + Bz²) 3) Baseline Calibration (at startup): B_baseline = ⟨||B||⟩ averaged over 100 samples (~2 seconds) Typical values: - Equator: ~25-30 µT - Mid-latitudes: ~45-55 µT - Poles: ~60-65 µT 4) Variation Detection: ΔB(t) = ||B(t)|| - B_baseline Smoothing: Low-pass filter with α=0.4 5) Normalization for Display: Range: 0-50 µT (covers typical disturbances) Energy_normalized = |ΔB| / 50 µT Brightness = 30 + (Energy_normalized × 225) 6) Compass Angle (2D projection): θ = atan2(By, Bx) [radians] Converted to degrees: θ_deg = θ × 180/π If θ_deg < 0: θ_deg += 360° TYPICAL DISTURBANCES: - Smartphone: +50 µT at 10 cm - Neodymium magnet: +500 µT at 5 cm - Steel beam: ±20 µT - Electric current (1A): ~2 µT at 10 cm (Biot-Savart law) =============================================================================== 5. INFRARED PROXIMITY (APDS9960) =============================================================================== PHYSICAL PRINCIPLE: Infrared LED emits light (~940 nm), photodiode measures reflected intensity. Closer objects reflect more light. Intensity follows inverse square law. SENSOR: APDS9960 (proximity + gesture + RGB/ambient light) SAMPLING RATE: ~10 Hz UNIT: Arbitrary units (0-255) PHYSICS: 1) IR Reflectance (simplified): I_received ∝ (ρ × P_emitted) / r² Where: - ρ = surface reflectivity (albedo) - P_emitted = IR LED power - r = distance to object 2) Sensor Output: Proximity_raw ∈ [0, 255] 0 = No object detected (>25 cm) 255 = Object very close (<3 cm) 3) Exponential Smoothing: Proximity_filtered = α × Proximity_raw + (1-α) × Proximity_filtered_prev With α = 0.2 (moderately fast response) 4) Normalization: Proximity_normalized = Proximity_filtered / 255.0 ∈ [0, 1] VISUALIZATION LOGIC: - Central IR "hotspot" (4 pixels) - If close (>0.3): Expand cross pattern (8 more pixels) - If far (<0.5): Expanding circles (inverse distance) - If near (>0.5): Multiple concentric circles (proximity levels) TYPICAL DISTANCES: - Far: 0-30 (>15 cm) - Medium: 30-100 (5-15 cm) - Near: 100-200 (3-5 cm) - Very near: 200-255 (<3 cm) =============================================================================== 6. GPS SATELLITES (GY-GPS6MV2 NEO-6M) =============================================================================== PHYSICAL PRINCIPLE: GPS satellites (24+ in orbit, ~20,000 km altitude) broadcast L1 signals (1575.42 MHz). Receiver measures time-of-flight from 4+ satellites to triangulate position via trilateration. SENSOR: NEO-6M GPS module (u-blox) SAMPLING RATE: 1 Hz (NMEA sentences) UNIT: Latitude/Longitude (degrees), Altitude (meters), Satellites (count) POSITIONING MATHEMATICS: 1) Time-of-Flight Measurement: Distance to satellite i: d_i = c × (t_receive - t_transmit) Where c = 299,792,458 m/s (speed of light) 2) Trilateration (4 satellites minimum): System of equations: (x - x_i)² + (y - y_i)² + (z - z_i)² = d_i² For i = 1, 2, 3, 4 (4 unknowns: x, y, z, clock_error) 3) NMEA GPGGA Parsing: Example: $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47 Fields: - Time: 12:35:19 UTC - Latitude: 48°07.038' N → 48 + 07.038/60 = 48.1173° - Longitude: 11°31.000' E → 11 + 31.000/60 = 11.5167° - Fix quality: 1 (GPS fix) - Satellites: 08 - Altitude: 545.4 m 4) Signal Quality Metric: Quality = min(Satellites / 12, 1.0) Optimal: 12 satellites (100% quality) Minimum for 3D fix: 4 satellites Typical urban: 6-8 satellites 5) Timeout Handling: If no NMEA data for 2 seconds → Satellites = 0 Triggers "searching" animation (4 rotating points) VISUALIZATION: - 12 positions on matrix (4 center + 8 cardinal/intercardinal) - Active satellites: Bright - Inactive satellites: Dim baseline - No fix: Rotating search animation ACCURACY: - Open sky: ±3-5 meters (CEP) - Urban canyon: ±10-20 meters - Indoor: No fix (signal too weak) =============================================================================== 7. BLUETOOTH (BLE - Nordic nRF52840) =============================================================================== PHYSICAL PRINCIPLE: Bluetooth Low Energy uses 2.4 GHz ISM band (2400-2483.5 MHz) with adaptive frequency hopping. Signal strength (RSSI) indicates link quality and approximate distance. SENSOR: nRF52840 (built-in BLE radio) SAMPLING RATE: Continuous when connected UNIT: dBm (decibel-milliwatts) RADIO PHYSICS: 1) Path Loss (Friis Transmission Equation): RSSI = P_tx + G_tx + G_rx - PL Where: - P_tx = Transmit power (typically 0 dBm = 1 mW) - G_tx, G_rx = Antenna gains - PL = Path loss (free space): PL = 20×log₁₀(d) + 20×log₁₀(f) + 20×log₁₀(4π/c) For d in meters, f in Hz, c = speed of light 2) RSSI Measurement: Typical range: -100 dBm (far) to -30 dBm (very close) Distance estimation (rough): d ≈ 10^((P_tx - RSSI)/(10×n)) Where n = path loss exponent (2.0 in free space, 2.5-4.0 indoors) 3) Normalization: RSSI_normalized = (RSSI + 100) / 70 Maps [-100, -30] dBm → [0.0, 1.0] Clamped: min(max(RSSI_normalized, 0.0), 1.0) VISUALIZATION: - No connection: Pulsing circle (breathing animation) - Connected: Concentric circles (1-4 rings based on signal strength) - Central point: Always visible (4 pixels) TYPICAL RSSI VALUES: - -30 dBm: Device touching (0-10 cm) - -50 dBm: Very close (10-50 cm) - -70 dBm: Normal range (1-5 m) - -90 dBm: Weak signal (5-10 m) - -100 dBm: Connection limit DATA STREAMING: 13 BLE characteristics transmit all sensor data to ESP32 touchscreen - IMU magnitude - Magnetic delta - Proximity - Pressure - Audio/EMI frequencies (Hz) - Temperature - Humidity - GPS coordinates - Compass angle - 8-band spectrum =============================================================================== 8. ATMOSPHERIC PRESSURE (LPS22HB Barometer) =============================================================================== PHYSICAL PRINCIPLE: Atmospheric pressure is the weight of air column above a point. Variations indicate weather changes, altitude differences, or local pressure systems. SENSOR: LPS22HB (MEMS barometer) SAMPLING RATE: ~0.5 Hz (slow, stable readings) UNIT: hPa (hectopascal) = mbar (millibar) MEASUREMENT: 1) Raw Pressure Reading: Arduino library returns kPa → Multiply by 10 for hPa P_raw [kPa] × 10 = P [hPa] 2) Baseline Calibration: P_baseline = ⟨P⟩ averaged over 100 samples (~200 seconds) Sea level standard: 1013.25 hPa Typical range: 980-1040 hPa 3) Pressure Variation: ΔP(t) = P(t) - P_baseline 4) Exponential Smoothing: α = 0.05 (very slow, ~2 second time constant) P_smooth = α × P_raw + (1-α) × P_smooth_prev 5) Altitude Estimation (barometric formula): Δh ≈ -8.3 × ΔP [meters per hPa] More accurate formula: h = 44330 × (1 - (P/P₀)^0.1903) Where P₀ = 1013.25 hPa (sea level standard) METEOROLOGICAL INTERPRETATION: - ΔP > +5 hPa: High pressure system (clear weather) - ΔP < -5 hPa: Low pressure system (storms) - Rapid drop: Weather front approaching - Stable: Settled conditions TYPICAL VARIATIONS: - Weather systems: ±10-30 hPa over days - Building floors: -1.2 hPa per 10 meters - Breathing on sensor: +0.1-0.5 hPa transient =============================================================================== 9. TEMPERATURE (HS3003) =============================================================================== PHYSICAL PRINCIPLE: Temperature measures thermal energy - average kinetic energy of molecules. HS3003 uses resistance change in sensing element (thermistor or RTD). SENSOR: HS3003 (integrated temp/humidity) SAMPLING RATE: ~0.5 Hz UNIT: °C (Celsius) RANGE: -40°C to +85°C ACCURACY: ±0.2°C typical MEASUREMENT: 1) Raw Temperature Reading: T [°C] from sensor (already calibrated) 2) Baseline Calibration: T_baseline = ⟨T⟩ averaged over 50 samples (~100 seconds) 3) Temperature Variation: ΔT(t) = T(t) - T_baseline 4) Exponential Smoothing: α = 0.05 (slow response, matches thermal mass) DERIVED METRICS: A) Heat Index (feels-like temperature): Valid for T > 20°C and RH > 40% Simplified Steadman formula: HI = -8.785 + 1.611×T + 2.339×RH - 0.146×T×RH - 0.0123×T² - 0.0164×RH² + 0.00221×T²×RH + 0.000725×T×RH² - 0.00000358×T²×RH² Where T in °C, RH in % B) Comfort Zone (ASHRAE): Comfortable: 18-24°C and 30-60% RH TYPICAL VARIATIONS: - Room temp: 18-25°C - Body heat: +2-5°C near skin - Breath: +10-20°C transient - Sunlight: +5-15°C =============================================================================== 10. HUMIDITY (HS3003) =============================================================================== PHYSICAL PRINCIPLE: Relative humidity (RH) is ratio of actual water vapor pressure to saturation vapor pressure at given temperature. Sensor uses capacitive element whose dielectric constant changes with moisture absorption. SENSOR: HS3003 (capacitive humidity sensor) SAMPLING RATE: ~0.5 Hz UNIT: % RH (relative humidity) RANGE: 0-100% RH ACCURACY: ±2% RH typical MEASUREMENT: 1) Raw Humidity Reading: RH [%] from sensor 2) Baseline Calibration: RH_baseline = ⟨RH⟩ averaged over 50 samples 3) Humidity Variation: ΔRH(t) = RH(t) - RH_baseline 4) Exponential Smoothing: α = 0.1 (slightly faster than temperature, moisture diffuses quickly) DERIVED METRICS: A) Dew Point (Magnus-Tetens Formula): Temperature at which air becomes saturated (RH=100%) Constants: a = 17.27, b = 237.7°C α = ((a×T)/(b+T)) + ln(RH/100) T_dew = (b×α) / (a-α) Physical meaning: Water vapor condenses if cooled to T_dew B) Absolute Humidity: Actual water vapor mass per volume AH = (RH × P_sat) / (R × T) Where: - P_sat = Saturation vapor pressure (function of T) - R = Gas constant - T in Kelvin TYPICAL VALUES: - Desert: 10-30% RH - Comfortable: 30-60% RH - Tropical: 70-90% RH - Breath: +20-40% RH transient - Steam: 100% RH =============================================================================== COMPOSITE ENVIRONMENTAL (ENV) VISUALIZATION =============================================================================== The ENV mode (mode 8) combines three environmental parameters into a single PHI-symbol visualization: 1) ATMOSPHERIC PRESSURE → Circle radius Normalization: |ΔP| / 5 hPa → [0, 1] Visual: Circle expands/contracts with pressure changes 2) TEMPERATURE → Vertical bar color gradient Normalization: ΔT / 10°C → [-1, 1] Visual: - Cold (ΔT < -3°C): Blue gradient - Neutral (|ΔT| < 3°C): Purple/white - Hot (ΔT > +3°C): Red/orange gradient 3) HUMIDITY → Peripheral "cloud" density Normalization: |ΔRH| / 30% → [0, 1] Visual: Number of corner pixels (6-16) representing moisture Combined Formula: ENV_composite = 2.0×|ΔP| + 1.5×|ΔT| + 0.1×|ΔRH| This creates a unified environmental "fingerprint" showing how all three atmospheric parameters deviate from baseline simultaneously. =============================================================================== VIBRO-ACOUSTIC COUPLING ANALYSIS =============================================================================== PRINCIPLE: Mechanical vibrations can couple with acoustic waves through structural resonances. Examples: speaker cone, drum membrane, building structures. COUPLING SCORE CALCULATION: Given: - f_IMU: Dominant vibration frequency (Hz) - f_AUD: Dominant audio frequency (Hz) - E_IMU: IMU spectral amplitude - E_AUD: Audio spectral amplitude 1) Frequency Correlation: Measures how close the dominant frequencies are Δf = |f_IMU - f_AUD| C_freq = exp(-Δf / σ) Where σ = 100 Hz (typical phoneme bandwidth) Result: C_freq ∈ [0, 1] - 1.0 if frequencies match exactly - 0.37 if 100 Hz apart - 0.05 if 300 Hz apart 2) Energy Correlation: Measures if both signals have significant amplitude Normalize each amplitude: E_IMU_norm = E_IMU / 0.10 (reference: strong vibration) E_AUD_norm = E_AUD / 0.10 (reference: loud sound) Geometric mean: C_energy = √(E_IMU_norm × E_AUD_norm) Saturate at 1.0: C_energy = min(C_energy, 1.0) 3) Combined Coupling Score: Coupling = C_freq × C_energy ∈ [0, 1] Interpretation: - 0.0: No coupling (different frequencies OR weak signals) - 0.5: Partial coupling - 1.0: Perfect coupling (same frequency, both strong) PHYSICAL EXAMPLES: - Speaker: High coupling (0.8-1.0) - Hand clapping: Medium coupling (0.4-0.6) - Typing + music: Low coupling (0.0-0.2) - Machine vibration + motor hum: High coupling (0.7-0.9) =============================================================================== BRIGHTNESS = REALITY PRINCIPLE =============================================================================== Core Scientific Philosophy: Every phenomenon's intensity maps LINEARLY to LED brightness: Brightness = B_min + (Energy_normalized × (B_max - B_min)) Where: - B_min = 30 (always-visible baseline) - B_max = 255 (maximum LED intensity) - Energy_normalized ∈ [0, 1] (phenomenon-specific normalization) KEY PRINCIPLE: No artificial amplification or compression - Weak signal → Dim LEDs - Strong signal → Bright LEDs This ensures scientific rigor: Visual brightness directly represents physical intensity of detected phenomenon. NORMALIZATION REFERENCES (per phenomenon): 1. IMU: 0.10g (strong vibration) 2. Audio: Fixed scale 50.0 (empirical calibration) 3. EMI: Same as audio 4. Magnetic: 50 µT (strong disturbance) 5. Proximity: 255 (sensor maximum) 6. GPS: 12 satellites (optimal) 7. BLE: 70 dBm range (-100 to -30) 8. Barometer: 5 hPa (significant variation) 9. Temperature: 10°C (noticeable change) 10. Humidity: 30% RH (significant change) =============================================================================== SIGNAL PROCESSING SUMMARY =============================================================================== COMMON TECHNIQUES USED: 1) High-Pass Filtering (DC removal): y[n] = (x[n] - x[n-1]) + α·y[n-1] Removes static components (gravity, DC offset, drift) 2) Low-Pass Filtering (smoothing): y[n] = α·x[n] + (1-α)·y[n-1] Reduces noise, creates visually stable display 3) Fast Fourier Transform (FFT): X(f) = Σ x(t)·e^(-j2πft) Converts time-domain to frequency-domain for spectral analysis 4) Hann Window (spectral leakage reduction): w(n) = 0.5 × (1 - cos(2πn/(N-1))) Applied before FFT to reduce side-lobes 5) Exponential Moving Average (EMA): y[n] = α·x[n] + (1-α)·y[n-1] Simple, efficient smoothing (α = smoothing factor) =============================================================================== END OF SCIENTIFIC DOCUMENTATION =============================================================================== This document provides the mathematical and physical foundation for understanding how PHI-SPHERE transforms raw sensor data into meaningful visualizations of invisible phenomena. For implementation details, see source code comments in respective modules: - PhiIMU.cpp: Vibration processing - PhiAudio.cpp: Audio capture & silence detection - PhiScientificModel.cpp: FFT analysis & Audio/EMI classification - PhiMagnetometer.cpp: Magnetic field measurement - PhiBarometer.cpp: Pressure sensing - PhiHumidity.cpp: Temperature & humidity - PhiProximity.cpp: IR detection - PhiGPS.cpp: NMEA parsing - PhiBLE.cpp: Wireless streaming - PhiMatrixEngine.cpp: LED visualization algorithms ===============================================================================