My first car telemetry prototype was a nightmare.
It worked perfectly on my desk. It would connect to the OBD-II adapter via Bluetooth, pull some data, and send it over WiFi. But in the car, under real-world conditions, it would crash. Randomly. Violently. The logs showed nothing—just a sudden, silent reboot.
For a week, I was stumped. I thought my code was bad. I thought the power from the car was unstable. The real culprit, it turned out, was hiding in plain sight: the ESP32's own radio.
The Problem: A War on a Single Chip
The ESP32 is a fantastic microcontroller, but it has one physical 2.4GHz radio. When you ask it to do two demanding wireless tasks at once, you're essentially asking a single person to have a detailed phone conversation while simultaneously shouting instructions to someone across a crowded room.
It can try, but it can't do both well. This creates a "war" for resources on three fronts:
- Radio Conflict: The antenna must rapidly switch between listening for Bluetooth packets and sending WiFi packets, causing both connections to become unstable.
- CPU Hogging: The encryption needed for a secure WiFi connection is CPU-intensive. It can starve the Bluetooth task of the processing time it needs, causing it to lose its connection to the car.
- Memory Contention: Both the WiFi and Bluetooth software stacks are memory-hungry. Running them at full tilt can exhaust the ESP32's limited RAM, leading to unpredictable crashes.
The Solution: A Tale of Two Boards
After days of frustration, the solution was surprisingly simple and cheap: I split the work between two ESP32 boards, using a protocol called ESP-NOW to link them.
ESP-NOW is like a magic, wireless data cable for ESP boards. It lets them talk to each other directly, with no router and almost zero latency.
Here is the final, rock-solid architecture:
graph LR
A["OBD Sender<br>(ESP32 #1)<br><br>- BLE only<br>- Heavy lifting"] -->|ESP-NOW| B["MQTT Receiver<br>(ESP32 #2)<br><br>- WiFi only<br>- Network tasks"]
- The "OBD Sender" ESP32 has one job: manage the demanding Bluetooth connection to the car. It dedicates 100% of its resources to this task. It doesn't know or care about WiFi.
- The "MQTT Receiver" ESP32 has one job: manage the network. It maintains the stable WiFi and secure MQTT connection to the cloud.
The first board gathers the data; the second one sends it. No more war for resources. No more random crashes.
The Takeaway
This was the most important lesson of the project: for complex IoT devices, separating concerns at the hardware level is a superpower. Instead of trying to force one cheap board to do everything, using two to do one thing each resulted in a system that was not only more reliable, but also simpler to code and debug.
[<-- Back to the Main Guide](/blog/car-telemetry-guide/)