In my previous post, I described the first stage of my DIY Active Noise Cancellation (ANC) project using an ESP32. I was able to build a basic audio pass-through system and even generate an inverted version of the microphone signal. Although the concept sounded simple, I spent a surprising amount of time dealing with hardware noise issues before I could obtain clean signals.
After solving those initial problems, I moved on to the next step: adding a reference microphone and implementing an adaptive filter.
Unfortunately, that turned out to be another lesson in debugging.
Adding a Reference Microphone

A practical feedforward ANC system typically requires two microphones:
- A reference microphone that captures the incoming noise
- An error microphone that measures the remaining noise after cancellation
My original setup only used a single microphone, which was useful for testing the audio pipeline but not sufficient for a true ANC implementation.
To move toward a more realistic system, I added a second microphone as the reference input.
Since my long-term goal is to experiment with automotive-style applications, I intentionally placed the reference microphone about one meter away from the controller. This mimics a situation where a sensor must be located near a noise source while the processing hardware is installed elsewhere.
At first, this seemed like a reasonable design choice.
I quickly discovered otherwise.
The Unexpected Noise Problem

As soon as I connected the longer microphone wiring, the signal quality degraded noticeably.
The symptoms included:
- Increased background noise
- Unstable ADC readings
- Significant signal fluctuations
My initial assumption was that I had made a mistake in software.
I checked:
- ESP32 ADC settings
- Microphone modules
- Sampling code
- Signal processing routines
Nothing obvious appeared to be wrong.
After several rounds of investigation, I shifted my attention back to the hardware.
The improvements that made the biggest difference were surprisingly simple:
- Reworking several solder joints
- Improving grounding connections
- Twisting the microphone signal wires together
The twisted-pair wiring provided a much larger improvement than I expected.
I had assumed that software and filtering would be the difficult parts of the project. Instead, I spent a considerable amount of time fighting basic signal integrity issues.
It was a good reminder that real-world engineering often starts with the physical layer.
I spent hours debugging software only to discover that the wiring itself was a major contributor to the problem.
Moving to LMS and FxLMS

Once the microphone signals became reasonably clean, I started implementing adaptive filtering.
The initial goal was to use a standard LMS (Least Mean Squares) algorithm to adaptively generate an anti-noise signal.
The algorithm itself was straightforward to implement, but the results were disappointing.
The filter weights changed, but the error signal did not decrease as expected.
After reviewing the theory, I realized that a practical ANC system requires more than a basic LMS implementation.
The speaker, air path, and microphone introduce additional dynamics between the controller output and the measured error signal. Because of this secondary path, most feedforward ANC systems use the Filtered-x LMS (FxLMS) algorithm rather than standard LMS.
I therefore modified the implementation to use FxLMS.
Current Status
At the time of writing, the FxLMS algorithm is running on the ESP32, but the system is still not producing effective noise cancellation.
My current suspicion is that the problem is related to signal scaling and normalization rather than the adaptive algorithm itself.
Some possible causes include:
- Incorrect signal normalization
- Poor scaling between reference and error signals
- Numerical precision issues
- Inaccurate secondary-path modeling
The encouraging part is that the software is now running end-to-end:
- Reference microphone input
- Error microphone input
- Adaptive filter update
- Anti-noise output generation
The challenge now is getting the adaptive filter to converge properly.
Lessons Learned So Far
One of the biggest surprises in this project has been how much time was spent on hardware details rather than control theory.
When people discuss ANC systems, the focus is usually on adaptive algorithms, DSP techniques, and filter design.
In practice, the actual development process looks more like this:
- Wiring
- Grounding
- Power supply noise
- Signal integrity
- Latency
- Signal scaling
- Adaptive filtering
Only after those earlier issues are solved does the algorithm become the primary challenge.
Interestingly, this experience reminds me of automotive control development. Even sophisticated control strategies depend on reliable sensor signals. A perfectly designed controller cannot compensate for poor measurements.
Next Steps
My next experiments will focus on:
- Signal normalization
- Filter scaling
- Secondary-path identification
- Additional FxLMS tuning
The hardware is finally in a usable state, so I can now spend more time investigating the adaptive filter itself.
Hopefully the next update will include actual noise reduction rather than another lesson in debugging.
