Problems using wifi with analog

michael899
Posts: 1
Joined: Mon May 02, 2022 5:57 am

Problems using wifi with analog

Postby michael899 » Mon May 02, 2022 7:14 am

Hi,
I am using ESP32-WROOM-32D.
So i've been trying to do some data collection with my Microphone and send it over the MQTT.
I noticed that when I enter the specific function (code below) I get alot of noises (Used a scope to check ).
So i connected the scope to the analog I(GPIO 39).
I found out, that when I comment the "setup_wifi()" (Line 30) function, the noises stop. when i uncomment it, i get alot of noises from the GPIO39.
the thing is, that the noises are very high peaks that change the whole values of the fft (+-10dB, instead of +-0.5dB) so i really need to fix it.

I attached a photo of the noises that I measure with the O-Scope

I would really appreciate your help on how to reduce the noises and make my sampling more accurate.

  1. #include <WiFi.h>
  2. #include <Wire.h>
  3. #include "arduinoFFT.h"
  4. #include "Math.h"
  5.  
  6.  
  7. const uint16_t samples = 4096; //This value MUST ALWAYS be a power of 2
  8. unsigned int sampling_period_us;
  9. const double samplingFrequency = 2500;
  10. double vReal[4096];
  11. double vImag[4096];
  12. arduinoFFT FFT = arduinoFFT(vReal, vImag, samples, samplingFrequency); /* Create FFT object */
  13. int newTime;
  14.  
  15.  
  16. char machine[] = "FVT-PCB-001";
  17. char TFS_TOPIC[50] ; char Voice_TOPIC[50]; char Request_TOPIC[50];
  18.  
  19.  
  20. const char* ssid = "ABCD";
  21. const char* password = "12345678";
  22.  
  23.  
  24. WiFiClient espClient;
  25.  
  26.  
  27. void setup() {
  28.   // put your setup code here, to run once:
  29.   Serial.begin(115200);
  30.   setup_wifi();
  31.   //pinMode(4, OUTPUT);
  32.   pinMode(36, INPUT);
  33.   digitalWrite(4, HIGH);
  34.   sampling_period_us = round(100000*(1.0/samplingFrequency));
  35. }
  36.  
  37. void loop() {
  38.   double dB[samples/2];
  39.   int x;
  40.   // put your main code here, to run repeatedly
  41.      for (int i=1;i<samples;i++)
  42.      {
  43.       newTime = micros();
  44.      vReal[i] = analogRead(39)*3.3/4095;
  45.      vImag[i] = 0;
  46.      while(micros() < (newTime + sampling_period_us));
  47.      }
  48.      //for (int i = 1;i<samples;i++)
  49.      //{
  50.      // Serial.println(vReal[i]);
  51.      //}
  52.       FFT.DCRemoval();
  53.       FFT.Windowing(FFT_WIN_TYP_HANN, FFT_FORWARD);
  54.       FFT.Compute(FFT_FORWARD); /* Compute FFT */
  55.       FFT.ComplexToMagnitude(); /* Compute magnitudes */
  56.      delay(100);
  57.    for (int i = 232 ;i<235;i++) // 1KHz
  58.   {
  59.     //dB[i] = 20*log10((vReal[i]*Cal_Val)/(EEPROM.read(Sensor)*0.001));
  60.     dB[i] = 20*log10((vReal[i]*500)/(50*0.01));
  61.     x = int(i*1000/234);
  62.     Serial.println();
  63.     Serial.print("Freq:   ");
  64.     Serial.println(x);
  65.     Serial.print("dB:     ");
  66.     Serial.println(dB[i]);
  67.     //doc["value"][String(x)] = dB[i];
  68.   }
  69.   delay(1000);
  70.  
  71.  
  72. }
  73.  
  74. void setup_wifi()
  75. {
  76.   delay(10);
  77.   // We start by connecting to a WiFi network
  78.   WiFi.begin(ssid, password);
  79.   while (WiFi.status() != WL_CONNECTED)
  80.   {
  81.     delay(500);
  82.     Serial.println("Problem in wifi");
  83.   }
  84.  
  85. }
  86.  
Attachments
Scope_Noises.jpeg
Scope_Noises.jpeg (134.35 KiB) Viewed 1919 times

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Problems using wifi with analog

Postby ESP_Sprite » Tue May 03, 2022 1:36 am

What's your schematic like? Could it be that your amp or your wires are picking up radiated noise from the antenna or power supply?

akhilchandran
Posts: 1
Joined: Thu Jun 09, 2022 10:24 am

Re: Problems using wifi with analog

Postby akhilchandran » Thu Jun 09, 2022 11:02 am

Dear friend,
I too face noise issue when connecting with wifi. I recently developed a DAQ and I noticed some points.
1. Noise is not due to any kind of interference, but due to the fluctuations of Vcc due to self consumption.
2. If you check the 3.3V pin and 5V pin, you can see these noises are there too. These voltages keep on fluctuate.
3. Putting a capacitor on 5V pin can stabilise these noises to some extent
4. Use of an ADC will be a good option.

Who is online

Users browsing this forum: No registered users and 67 guests