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

I didnt find a clear way to send the sensor data from esp32 to laptop via Wifi. Also, is the converting the data type to binary would be better than wifi solution. Thanks

FreeRTOS (Supplemental Features)

look for audio players, they'll use buffers too..
you got esp, more options..
good luck.. ~q

@qubits-us , Thank you for your help. But I have a question please, Does this ring buffer has a limited storage as the Arduino buffer? I want to store 7000 readings, will this buffer will store all of them without delay?

Sending data from ESP32 to a PC via Wifi or Bluetooth--Serial is not a big deal

Sending UDP on ESP32 in AP mode

Bluetooth Serial on ESP32

It is usually much easier to handle the serial wired communication.

First I suggest to

  • clearly specify the data that you want to send
  • define the necessary format for the transport based on
    • content of a single message (in byte)
    • multiplied by no of sensors
    • multiplied by messagesPerSecond

so that you know how many byte/sec have to be transmitted.

From that we can decide what to do.

E.g.: Is it limited to the x,y,z data per sensor from three sensors? Or do you want to send other information as well in future?

BTW: Which software do you use to receive the data?

I just want to receive the z data from each sensor, in the future i may increase the number of sensors to 5.

I used CoolTerm to save the data.

Based on what I have mentioned, which do you think is the best method to receive the data without losing any, and achieving the max sampling rate, is it by wifi or ring buffer?

You have what is commonly called a "Producer Consumer problem", google it..

~q

Google didnt give me which method is better to use, the buffer ring or wifi?

You're producing more than you can consume, you need to buffer regardless of connection type to achieve the rates you're shooting for..
In my opinion, you be faster on a serial line with smaller packets, less overhead..
allot of things need to be taken into consideration, exact data, how often does data change..
big job..
some light reading..
esp32-arduino-using-the-pthreads-library

do you need to display it close to your desired speed or just capture it and not lose any data??

sorry.. ~q

Capture it and not lose any data as much as possible

Ok. The good news is that the serial transmission is quite likely not the bottleneck:

=====================================================================

Requirements

The solution must

  1. be compatible with a terminal program like CoolTerm
  2. be able to handle up to 5 z-Data in one transmission
  3. transmit with a frequency of 200 Hz (or with other words every 1/200 sec = 5 msec)
Assumptions
  • z data will be sent as ASCII characters
  • Each z value is represented by a string of six characters (xxx.xx) based on:
    • The very maximum z value has two digits before the decimal point and and two decimal places (e.g. 15.99) -> xx.xx (5 characters)
    • The very minimum z value has a minus character and two digits before the decimal point and and two decimal places (e.g. -15.99) -> sxx.xx (6 characters)
  • Every z value string except the last in a message is followed by a separating character (which leads to 7 characters per z value string)
    • usually by a space character but
    • the last z value string gets a carriage return (CR)

So finally this leads to 7 ASCII characters per z value; let us call this entity z_string now

Further assumption:

  • Standard Serial configuration 1 start bit, 8 data bits, 1 stop bit, no parity bit = 10 bit per character
Calculation
  • With 7 characters per z_string and 10 bit/character we have -> 70 bit/z_string

For 3 sensors:

  • With 3 z_strings per message we have 3 * 70 bit/message = 210 bit/message
  • With a repetition rate of 200 Hz we have 200 message/sec * 210 bit/message = 42.000 bit/sec

For 5 sensors:

  • With 5 z_strings per message we have 5 * 70 bit/message = 350 bit/message
  • With a repetition rate of 200 Hz we have 200 message/sec * 350 bit/message = 70.000 bit/sec

Summary:

  • For transmission of 3 z sensor data in a non-optimized ASCII format 57.600 Bd should be sufficient.
  • For transmission of 5 z sensor data in a non-optimized ASCII format 115.200 Bd should be (more than) sufficient.

=====================================================================

I am not sure how CoolTerm and your PC behave while printing 200 lines of data per second ...

Can you switch off the screen output and solely store the data in a file?

Here a

proof of concept

Upload this sketch to your ESP32 board

String zString = "-15.99";

void setup() {
 Serial.begin(115200);
 Serial.println("Start at "+String(millis()));
 Serial.println(msg());
}

unsigned long lastMsg = 0;
unsigned long currentTime;

void loop() {
   currentTime = millis();
   if (currentTime-lastMsg >= 5) {
      lastMsg = currentTime;
     Serial.println(msg());
   }
}

String msg(){
    String t = "               "+String(millis());
    int l = t.length();
    t = t.substring(l-12)+ " ";
    return t+zString+" "+zString+" "+zString;
}

It transmits every 5 ms a dummy message string with the time in millis() in front.

Looks like this

C:\test>TYPE COM3 CON 
      845942 -15.99 -15.99 -15.99
      845947 -15.99 -15.99 -15.99
      845952 -15.99 -15.99 -15.99
      845957 -15.99 -15.99 -15.99
      845962 -15.99 -15.99 -15.99

To read and store the data just create a batch file (e.g. named esp.bat) with these lines:

(make sure to use the correct COMx for your application!!!!!!)

  mode COM3 BAUD=115200 PARITY=n DATA=8
  TYPE COM3 CON 

store it in a separate (empty) directory and call it from commandline (cmd) like this

image

After about 35 sec (200 lines per second x 35 = 7000 lines) you press CTRL-C in the cmd Window.
That stops the "download" and closes the textfile. Now you can check the file with any text editor.

Take care not to write to an important file! It may get lost then!

The milliseconds show you if you have lost data or not.

achieving the max sampling rate, is it by wifi or ring buffer?

You are mixing up transmission technology and software issues ...

  • Wifi, Bluetooth, Wired Serial, Ethernet and the like are names for different physical ways to connect two or more devices.
  • "Ring buffer" (or circular buffer) is the name for a specific software method to store and retrieve data in a storage that is "virtually" forming a ring or circle.

A buffer is usually used as a temporary storage for data to avoid that further processing blocks reception or transmission which would lead to loss of data.

See https://en.wikipedia.org/wiki/Circular_buffer

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.