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.
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
/***************************************************************************
* 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);
}
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.
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??
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