How can I send the sensor data which is connected with esp32 to the laptop via Wifi?

How can I send the sensor data which is connected with esp32 to the laptop via Wifi?

I have tried to use serial communication between the esp32 and the laptop but it was extremely slow, the expected frequency sample is 1kHz and I was getting only 200 Hz, that is why i need to try Wifi?

Note: The sensor is connected via SPI protocol with the esp32 and the communication between esp32 and laptop is serial and I want to replace it with Wifi.

-The Speed is very important in my application

-There is another reason why I got slower sampling rate, I am using three sensors at the same time and I am losing important data.

Any suggestion please?

Show us your data protocol. You could be sending one bit, or 1000 bits at 1kHz. The data rate would be 1000 times different.

Please do us a favour, treat us like colleagues, and post details.

200Hz is 200 times per second.. that's not bad..
That's with a dedicated wire..
WiFi is a radio transmission broadcast, that has to be received and processes before you ever see it..
either way would work, but you need some serious buffering..
good luck.. ~q

This is the following code that I am using it :

/***************************************************************************
* Example sketch for the MPU9250_WE library
*
* This sketch shows how to get acceleration, gyroscocope, magnetometer and 
* temperature data from the MPU9250 using SPI.
* 
* For further information visit my blog:
*
* https://wolles-elektronikkiste.de/mpu9250-9-achsen-sensormodul-teil-1  (German)
* https://wolles-elektronikkiste.de/en/mpu9250-9-axis-sensor-module-part-1  (English)
* 
***************************************************************************/

#include <MPU9250_WE.h>
const int csPin = 15;  // Chip Select Pin
bool useSPI = true;    // SPI use flag


/* There is only one construictor for SPI: */
MPU9250_WE myMPU9250 = MPU9250_WE(&SPI, csPin, useSPI);

void setup() {
  Serial.begin(115200);
  if(!myMPU9250.init()){
    Serial.println("MPU9250 does not respond");
  }
  else{
    Serial.println("MPU9250 is connected");
  }
  if(!myMPU9250.initMagnetometer()){
    Serial.println("Magnetometer does not respond");
  }
  else{
    Serial.println("Magnetometer is connected");
  }

  /* Choose the SPI clock speed, default is 8 MHz 
     This function must be used only after init(), not before */
  myMPU9250.setSPIClockSpeed(1000000);

  Serial.println("Position you MPU9250 flat and don't move it - calibrating...");
  //delay(1000);
  myMPU9250.autoOffsets();
  Serial.println("Done!");
  
 // myMPU9250.setAccOffsets(-14240.0, 18220.0, -17280.0, 15590.0, -20930.0, 12080.0);
  //myMPU9250.setGyrOffsets(45.0, 145.0, -105.0);
 //myMPU9250.enableGyrDLPF();
  //myMPU9250.disableGyrDLPF(MPU9250_BW_WO_DLPF_8800); // bandwdith without DLPF
  //myMPU9250.setGyrDLPF(MPU9250_DLPF_6);
  //myMPU9250.setSampleRateDivider(5);
  //myMPU9250.setGyrRange(MPU9250_GYRO_RANGE_250);
  myMPU9250.setAccRange(MPU9250_ACC_RANGE_16G);
  myMPU9250.enableAccDLPF(true);
  myMPU9250.setAccDLPF(MPU9250_DLPF_6);
  //myMPU9250.enableAccAxes(MPU9250_ENABLE_XYZ);
  //myMPU9250.enableGyrAxes(MPU9250_ENABLE_XYZ);
  myMPU9250.setMagOpMode(AK8963_CONT_MODE_100HZ);
  delay(200);
}

void loop() {
 
  
  Serial.println("Starting Measurement");
    xyzFloat gValue = myMPU9250.getGValues();
 //xyzFloat gyr = myMPU9250.getGyrValues();
  //xyzFloat magValue = myMPU9250.getMagValues();
  //float temp = myMPU9250.getTemperature();
 // float resultantG = myMPU9250.getResultantG(gValue);

  //Serial.println("Acceleration in g (x,y,z):");
 // Serial.print(gValue.x);
 // Serial.print("   ");
 // Serial.print(gValue.y);
 // Serial.print("   ");
Serial.println(gValue.z);
 // Serial.print("   ");
 
 // Serial.print("Time: ");
 // myTime = millis();
 // Serial.println(myTime); // prints time since program started
  //Serial.print("Resultant g: ");
  //Serial.println(resultantG);

 //delay(10);
}
  


Did you write it? It sends values in ASCII. That is horribly inefficient. You said you need speed.

Nope, It is from github, But my question is about how can I send the data to the laptop via wifi instead of serial? and would this increase the speed?

Please respect the forum guidelines and post a link

But my question is about how can I send the data to the laptop via wifi instead of serial? and would this increase the speed?

Okay, you are fixated on your pre-concieved solution. Bye.

What research did you do? Sending data from an Arduino via wifi is a common task, there are thousands of applications that do that, tutorials and guides too.

I am questioning if that would be help or not? Do you have any other suggestion Please? Thanks @anon57585045

You never answered the other persons question about latency.. "buffering"... post #3

Generally wifi is faster, but has more delays.

Do you have any other suggestion Please?

If there is something wrong with the one I gave you, please explain...

What should I replace with to increase the speed?

Raw binary data

What did you mean in this, I didnt get you. Thanks

To properly analyze your question, it's necessary to know details of the data type 'xyzFloat'.

These are acceleration data

details of the data type
not what it represents
do you know what a data type is?

Like what?
This is what I get in the serial monitor:

1.76 1.53 1.32
1.78 1.54 1.33
1.80 1.56 1.34
1.81 1.57 1.35
1.82 1.58 1.37

think about what happens when you watch Netflix..
buffering of the data is the only way to achieve 1kHz, actually probably have to buffer to get to the 200 Hz..
but yes, also reduce your data down to the smallest size..
very complicated stuff..
why, the real time display, is there another way??

~q

What @anon57585045 is asking for is this ...

struct xyzFloat {
    float x;
    float y;
    float z;

    xyzFloat();
    xyzFloat(float const x, float const y, float const z);

    xyzFloat operator+() const;
    xyzFloat operator-() const;
    xyzFloat operator+(xyzFloat const & summand) const;
    xyzFloat operator-(xyzFloat const & subtrahend) const;
    xyzFloat operator*(float const operand) const;
    xyzFloat operator/(float const divisor) const;
    xyzFloat & operator+=(xyzFloat const & summand);
    xyzFloat & operator-=(xyzFloat const & subtrahend);
    xyzFloat & operator*=(float const operand);
    xyzFloat & operator/=(float const divisor);
};

Source: https://github.com/wollewald/MPU9250_WE/blob/main/src/xyzFloat.h

There is another reason why I got slower sampling rate, I am using three sensors at the same time and I am losing important data.

How to do that? is there any helpful link? and is this solution better than using wifi?
I am using 3 sensors at the same time, and that is affected the speed and I am losing data, that's why I am interested in the fastest way. Thanks