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.
- SpectraFog treats fog as a sensing problem with overlapping layers, not a single camera problem.
- The project’s real strength is its non-blocking embedded architecture, which keeps radar, ultrasonic, and environmental sensing responsive at once.
- Its radar parser is built for noisy serial traffic, which is exactly what a retrofit environment needs.
- The browser dashboard is only the final step in a pipeline that is designed to filter, fuse, and stream reliable telemetry.
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.
| Dimension | Typical hobby Arduino build | SpectraFog |
|---|---|---|
| Sensor strategy | One sensor or one camera | Radar, ultrasonic, and humidity each cover a different blind spot |
| Responsiveness | Blocking loops and delays | Non-blocking update cycles keep the system alive |
| Noise handling | Assumes clean reads | Parses noisy UART frames and filters distance samples |
| Expandability | Features toggled ad hoc at runtime | Modular sensor files and compile-time exclusion keep the build disciplined |
| Binary size discipline | Everything ships, whether used or not | Disabled sensors can be compiled out |
| Browser integration | Optional serial printouts | WebSockets 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...
// 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.
| Pattern | What happens | Why it matters |
|---|---|---|
| Blocking loop | A sensor call can freeze everything else | Radar, ultrasonic, and networking compete for time |
| Non-blocking update loop | Each module refreshes on its own schedule | The board stays responsive under mixed sensor load |
| getData on demand | The caller reads the last validated sample | The 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.





