bitluni / ULPSoundESP32

176 stars 26 forks source link

Noise when using wi-fi #1

Open SharkSharp opened 5 years ago

SharkSharp commented 5 years ago

First of all I would like to congratulate you for the work, a good idea implemented in a simple and effective way.

I'm putting some variations of the code for other applications and I ended up with a noise that arises when using the driver and the wifi library together. I could not find any reference and nothing connecting the two, but I suspect they share the same communication bus. Do you have any idea of what could be and how could be corrected or mitigated?

I'm using the Espressif ESP32 Dev Module and the Wi-Fi libraries

  1. include

  2. include

Thanks.

elshnkhll commented 4 years ago

I can confirm. Simultaneous use of WiFi connection and ULPSound creates loud "clicks". First I sought it is due to power drop since WiFi uses too mach of it. But after stabilizing power source "clicks" remained. Now I suspect that process is being interrupted.

SharkSharp commented 4 years ago

I don't believe that the noise is due to an process interruption. As the sound is managed by ULP, it works independently of the two main processors. Through my extensive tests I still believe that the problem is a lack of power supply.

w3llschmidt commented 4 years ago

I cant confirm! I have here NodeMCU-ESP32, with

works all parallel like a champ with 44100Hz ULP sound. All within own tasks, for sure.

ESP-IDF: v4.1-dev-1086-g93a8603c5-dirty

SharkSharp commented 4 years ago

Okay, I expressed myself poorly in the first message. The noise appears when there is data traffic over the wifi. I'm trying to do voice transmission from a computer to esp via wifi, and whenever there is network traffic, it produces a noise, in my case it is constant because the data transmission is constant. I did a test with a simple program that combines ULPSoundESP32 and a web server that just returns a string to me. Whenever I make a request to the web server, it introduces noise into the sound. Maybe, @w3llschmidt , you don't hear the noise because your network traffic is very low.

w3llschmidt commented 4 years ago

Hmm, even if i fire dozen of packets toward the ESP, there is no change in the sound.

https://pbs.twimg.com/media/EXrwKA8X0AEy3sJ?format=jpg&name=small

To be fair, my ULPSOUND plays out of a static wavetable.h

SharkSharp commented 4 years ago

I am using the Arduino's IDE and libraries to program. I noticed here that the arduino-esp32 library uses version IDF 3.2: https://github.com/espressif/arduino-esp32/releases Maybe that version is the cause the noise. @w3llschmidt , could you send an example of how you handle network connection in the ESP-IDF: v4.1? So that I can test using the IDF and see if this is the problem. Thank you for your help.

w3llschmidt commented 4 years ago

Quite simple. I work with the examples all the time:

https://github.com/espressif/esp-idf/tree/master/examples/wifi/getting_started/station

I put this in a wifi.c, create a wifi.h;

ifndef WIFI_H

define WIFI_H

include "esp_event.h"

void initialise_wifi();

endif // WIFI_H

And call it in main.c > initialise_wifi();

BTW: im not a fan of Arduino, i do it all with VIM an ESP IDF pure C.

SharkSharp commented 4 years ago

Unfortunately, it didn't work for me. I downloaded the development sdk from esp-idf and did everything the old school way. I used the sample codes as a base and assembled a simple firmware that has ULPSound and an httpServer, the same noise appears whenever my esp sends a network packet. I'm starting to think it might be my hardware. I am using an ESP32 DEVKIT V1, I noticed that it is already in version 4, it may be the source of the problem.

w3llschmidt commented 4 years ago

I guess this is what @bitluni uses:

https://www.ebay.com/itm/ESP32-Wemos-Mini-D1-WiFi-Bluetooth-ESP8266-CP2104-Development-Board-for-Arduino/402121006408?hash=item5da0479d48:g:vnYAAOSwdNleVhUU

bitluni commented 4 years ago

hmmmm, might be a buffer underrun. You have to make sure that fill samples is called often enough. This can be done using a priority timer. usually wifi is handled on the other core but if further data processing is done in the main loop the ULP buffer underruns and a typical stuttering might happen.

SharkSharp commented 4 years ago

@bitluni , I already made sure that the buffer was working properly. The audio flows continuously, but there is a click embedded in. I made a program that always reproduced an empty buffer (128) and that sent me a small message whenever I made an HTTP request. The result of the audio output whenever I made the http request was this: 7d465cb4-09a9-44de-a257-423f76ea6f7c I'm using this development kit: IMG_20200518_021432 IMG_20200518_021439

bitluni commented 4 years ago

That's really sketchy it would mean somehow the configuration is changed or the DAC register is set to anything != 128 temporarily.

I can only imagine the error happening while the buffer is filled OR the ULP being buggy while setting the bits.

The first one can be tested if you can still observe the clicks while not updating the buffer in the loop at all. the ULP should loop the values it already has.

SharkSharp commented 4 years ago

@bitluni , I did as suggested and removed all the buffer update code, the ULP uses only the fixed values initially set to 128, but the noise remains. Another point that makes me believe even more that it is a hardware problem, the noise decreases if i set the wifi max tx power to 10db. I have 3 development boards like this one and in all of them the problem occurs.

bitluni commented 4 years ago

I believe you could increase the dac driving strength. You could also add another decoupling cap to 3.3v and see if it's a power issue.

SharkSharp notifications@github.com schrieb am Mo., 18. Mai 2020, 20:44:

@bitluni https://github.com/bitluni , I did as suggested and removed all the buffer update code, the ULP uses only the fixed values initially set to 128, but the noise remains. Another point that makes me believe even more that it is a hardware problem, the noise decreases if i set the wifi max tx power to 10db. I have 3 development boards like this one and in all of them the problem occurs.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bitluni/ULPSoundESP32/issues/1#issuecomment-630368408, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCGI26UOFZECQJXDWY5AJLRSF6X3ANCNFSM4HIGT5JA .

ens4dz commented 3 years ago

I think it is hardware issue (06:00): https://youtu.be/pPh3_ciEmzs

kotXio commented 3 years ago

It's not related to the sound issue, but I have found this thread by searching for my problem. Actually, with active WiFi usage ESP32-CAM in my case make a lot of noises over the power line. Which even make small servos to shake. I have spent a lot of time searching for the problem, with different ESP32 modules and power supplies.