SpectraFog: The ESP32 Project That Gives Old Cars a Fog-Savvy Sensor Brain

A clean Arduino architecture, mmWave radar parsing, and non-blocking telemetry turn a hobbyist board into a retrofit safety stack for low-visibility driving.

8 min read • View on GitHub • More from hamedzurat

A retrofit car dashboard seen from inside the cabin, with sensor layers mapped across the windshield and front bumper. An ESP32 sits beneath the dash and feeds a tablet-style browser display, explaining how an older car can become a fog-aware sensing platform without replacing the vehicle.
SpectraFog treats the car like a modular sensing system, not a sealed appliance. Radar, ultrasonic, and humidity data flow into one browser-facing layer.
Key Takeaways

Why SpectraFog Exists

Most retrofit car projects start with a screen. SpectraFog starts with the road. Its bet is simple: if you want older hardware to behave more like a modern driver-assistance system, you need more than a dashboard and more than one sensor.

Fog is the right problem to frame that bet. Cameras degrade fast in low visibility, while cheap hobby projects often collapse the moment the environment gets messy. SpectraFog answers with a layered sensing model that pairs mmWave radar, ultrasonic ranging, and humidity sensing into one safety-minded stack.

The repo reads less like a gadget demo and more like a retrofit philosophy. It is about extending the useful life of a vehicle by adding awareness, not replacing the vehicle to get a nicer interface.

The Sensor Stack Is the Point

The core idea is not that one sensor is clever. It is that each sensor covers a different blind spot. Radar sees through low visibility better than a camera. Ultrasonic handles near-field hazards. Humidity and dew point tell you when the environment is drifting toward fog in the first place.

Three sensing layers arranged as a stacked system, with environmental humidity at the top, radar targets in the middle, and ultrasonic distance at the bottom. The illustration shows each layer feeding a shared telemetry path, making the different failure modes easy to compare at a glance.
SpectraFog does not ask one sensor to do everything. It assigns each layer a different job, then fuses the results into one structured picture.

The architecture works because each sensor has its own filter and its own failure mode. The diagram makes the fusion step visible, from raw inputs to a browser-ready telemetry bundle.

DimensionTypical hobby Arduino buildSpectraFog
Sensor strategyOne sensor or one cameraRadar, ultrasonic, and humidity each cover a different blind spot
ResponsivenessBlocking loops and delaysNon-blocking update cycles keep the system alive
Noise handlingAssumes clean readsParses noisy UART frames and filters distance samples
ExpandabilityFeatures toggled ad hoc at runtimeModular sensor files and compile-time exclusion keep the build disciplined
Binary size disciplineEverything ships, whether used or notDisabled sensors can be compiled out
Browser integrationOptional serial printoutsWebSockets stream structured telemetry to the UI

Inside the Radar Parser

The technical heart of the project is the LD2450 radar parser. That matters because radar is only useful if the software can turn a noisy byte stream into trustworthy targets. SpectraFog does not assume perfect frames. It hunts for them.

Generating illustration...

This is the kind of embedded detail that separates a toy sketch from a sensor system. Robust frame hunting is what makes radar useful in a noisy vehicle environment.
// Radar parsing idea, simplified
if (buffer_has_header(buffer)) {
  parse_frame(buffer, radar_data);
} else {
  memmove(buffer, buffer + 1, buffer_size - 1);
}

That tiny pattern is the point. In a car, bytes arrive when they arrive. Electrical noise, timing drift, and partial packets are normal. The parser keeps shifting the buffer until it finds the header sequence, then it decodes targets into structured data instead of gambling on a clean read.

This is why the radar section feels serious. It is not just consuming sensor output. It is protecting the system from the reality of serial traffic in a moving vehicle.

Why the Main Loop Stays Calm

SpectraFog uses a clean begin, update, getData rhythm. That is not a stylistic detail. It is what keeps the ESP32 responsive while multiple sensors are alive at once.

The standard Arduino trap is to let one read stall the rest of the loop. SpectraFog avoids that by polling on schedule, keeping each sensor independent, and returning the latest validated value when the UI or broadcaster asks for it. The result is a system that behaves like a small real-time stack instead of a script with wires attached.

PatternWhat happensWhy it matters
Blocking loopA sensor call can freeze everything elseRadar, ultrasonic, and networking compete for time
Non-blocking update loopEach module refreshes on its own scheduleThe board stays responsive under mixed sensor load
getData on demandThe caller reads the last validated sampleThe main loop stays simple and predictable

From Sensors to the Browser

The telemetry path is just as disciplined as the sensing path. The project aggregates active sensor structs into nested JSON, then broadcasts the result over WebSockets so the browser can render the current state without polling the board over and over.

That design has a subtle advantage: disabled sensors are not just hidden in the UI, they are removed at compile time. In a memory-tight embedded build, that is the difference between a tidy prototype and a stack that starts to creak as features grow.

The browser is not the brain here. It is the display surface. The ESP32 still does the sensing, filtering, and packaging.

Why This Feels Bigger Than a Weekend Build

The maturity signals are easy to miss if you only look for flashy hardware. There are unit tests, schema documentation, modular sensor files, and defensive filtering choices. Those details matter because they tell you the project was written to be extended, not just admired.

SpectraFog is interesting because it treats a retrofit like a system design problem. It respects noisy inputs, keeps the loop calm, and sends clean telemetry to the browser. That is a practical template for turning old hardware into something smarter without pretending the old hardware is new.