How do I send data from a laptop to ESP32 (NodeMCU-32s) through WiFi?

Hi,
I want to send a string of integers to my NodeMCU-32s module through WiFi. Before this, I was using an Arduino Uno and sent the data over the USB port. I have programmed my NodeMCU-32s with the same code in Arduino IDE. I tried to understand how to do it from the examples that came with installing the board on Arduino IDE, but I can't understand them. The examples are titled WiFi Server, Accesspoint, client, WPS, etc. I don't even know what these mean and what I should look into.
Can you please tell me where to start, or maybe give a link to an example?

"The examples are titled WiFi Server, Accesspoint, client, WPS, etc. I don't even know what these mean and what I should look into."

You probably want the wifi server, as servers typically receive incoming data and do something with it.

zoomkat:
You probably want the wifi server, as servers typically receive incoming data and do something with it.

That example sends data from web. I don’t want to go on the internet to send the data. I just want to directly send the data between my laptop and NodeMCU directly.
Here’s the example:

/*
 WiFi Web Server LED Blink

 A simple web server that lets you blink an LED via the web.
 This sketch will print the IP address of your WiFi Shield (once connected)
 to the Serial monitor. From there, you can open that address in a web browser
 to turn on and off the LED on pin 5.

 If the IP address of your shield is yourAddress:
 http://yourAddress/H turns the LED on
 http://yourAddress/L turns it off

 This example is written for a network using WPA encryption. For
 WEP or WPA, change the Wifi.begin() call accordingly.

 Circuit:
 by Tom Igoe

ported for sparkfun esp32 
31.01.2017 by Jan Hendrik Berlin
 * WiFi shield attached
 * LED attached to pin 5

 created for arduino 25 Nov 2012
 
 */

#include <WiFi.h>

const char* ssid     = "yourssid";
const char* password = "yourpasswd";

WiFiServer server(80);

void setup()
{
    Serial.begin(115200);
    pinMode(5, OUTPUT);      // set the LED pin mode

    delay(10);

    // We start by connecting to a WiFi network

    Serial.println();
    Serial.println();
    Serial.print("Connecting to ");
    Serial.println(ssid);

    WiFi.begin(ssid, password);

    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }

    Serial.println("");
    Serial.println("WiFi connected.");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
    
    server.begin();

}

int value = 0;

void loop(){
 WiFiClient client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,
    Serial.println("New Client.");           // print a message out the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        if (c == '\n') {                    // if the byte is a newline character

          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println();

            // the content of the HTTP response follows the header:
            client.print("Click <a href=\"/H\">here</a> to turn the LED on pin 5 on.
");
            client.print("Click <a href=\"/L\">here</a> to turn the LED on pin 5 off.
");

            // The HTTP response ends with another blank line:
            client.println();
            // break out of the while loop:
            break;
          } else {    // if you got a newline, then clear currentLine:
            currentLine = "";
          }
        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }

        // Check to see if the client request was "GET /H" or "GET /L":
        if (currentLine.endsWith("GET /H")) {
          digitalWrite(5, HIGH);               // GET /H turns the LED on
        }
        if (currentLine.endsWith("GET /L")) {
          digitalWrite(5, LOW);                // GET /L turns the LED off
        }
      }
    }
    // close the connection:
    client.stop();
    Serial.println("Client Disconnected.");
  }
}

"I don't want to go on the internet to send the data. I just want to directly send the data between my laptop and NodeMCU directly."

You might connect both to a wireless router, or set the NodeMCU up as an access point and connect to it.

zoomkat:
“I don’t want to go on the internet to send the data. I just want to directly send the data between my laptop and NodeMCU directly.”

You might connect both to a wireless router, or set the NodeMCU up as an access point and connect to it.

I have included the Accesspoint example below. From what I understand, the board would be the access point and my computer would be a client and to send data, I will need to go to my web browser, but this doesn’t need an internet connection, right? But what if I want to constantly send data back and forth between MATLAB and the ESP board?

/*
  WiFiAccessPoint.ino creates a WiFi access point and provides a web server on it.

  Steps:
  1. Connect to the access point "yourAp"
  2. Point your web browser to http://192.168.4.1/H to turn the LED on or http://192.168.4.1/L to turn it off
     OR
     Run raw TCP "GET /H" and "GET /L" on PuTTY terminal with 192.168.4.1 as IP address and 80 as port

  Created for arduino-esp32 on 04 July, 2018
  by Elochukwu Ifediora (fedy0)
*/

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiAP.h>

#define LED_BUILTIN 2   // Set the GPIO pin where you connected your test LED or comment this line out if your dev board has a built-in LED

// Set these to your desired credentials.
const char *ssid = "yourAP";
const char *password = "yourPassword";

WiFiServer server(80);


void setup() {
  pinMode(LED_BUILTIN, OUTPUT);

  Serial.begin(115200);
  Serial.println();
  Serial.println("Configuring access point...");

  // You can remove the password parameter if you want the AP to be open.
  WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.begin();

  Serial.println("Server started");
}

void loop() {
  WiFiClient client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,
    Serial.println("New Client.");           // print a message out the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        if (c == '\n') {                    // if the byte is a newline character

          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println();

            // the content of the HTTP response follows the header:
            client.print("Click <a href=\"/H\">here</a> to turn ON the LED.
");
            client.print("Click <a href=\"/L\">here</a> to turn OFF the LED.
");

            // The HTTP response ends with another blank line:
            client.println();
            // break out of the while loop:
            break;
          } else {    // if you got a newline, then clear currentLine:
            currentLine = "";
          }
        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }

        // Check to see if the client request was "GET /H" or "GET /L":
        if (currentLine.endsWith("GET /H")) {
          digitalWrite(LED_BUILTIN, HIGH);               // GET /H turns the LED on
        }
        if (currentLine.endsWith("GET /L")) {
          digitalWrite(LED_BUILTIN, LOW);                // GET /L turns the LED off
        }
      }
    }
    // close the connection:
    client.stop();
    Serial.println("Client Disconnected.");
  }
}

"But what if I want to constantly send data back and forth between MATLAB and the ESP board?"

If you want a constant connection, then you may want to look at a telnet connection between the two.

zoomkat:
"But what if I want to constantly send data back and forth between MATLAB and the ESP board?"

If you want a constant connection, then you may want to look at a telnet connection between the two.

Would that work with MATLAB and Arduino IDE?

I don't know about MATLAB, but the below might have telnet info.

https://www.google.com/search?ie=UTF-8&oe=UTF-8&q=telnet&domains=https%3A%2F%2Fforum.arduino.cc&sitesearch=https%3A%2F%2Fforum.arduino.cc

Mylaiza:
I have included the Accesspoint example below. From what I understand, the board would be the access point and my computer would be a client and to send data, I will need to go to my web browser, but this doesn't need an internet connection, right?

Correct. But you should understand that the webserver example also doesn't require an Internet connection.

The difference is that with the webserver example, your computer is connected to your router, the ESP32 is connected to your router, and they communicate over the local network. The access point example is creating a direct connection between the ESP32 and your computer, with no router required.