Need Help

Hi,
I am using NodeMcu with RFID Reader and another one (NodeMcu) conected with LCD display.
And I found this code to conected two NodeMcu

the client

#include <WiFiUdp.h>
 
const char *ssid = "MyWifi";
const char *pass = "password";
 
unsigned int localPort = 2000; // local port to listen for UDP packets
 
IPAddress ServerIP(192,168,4,1);
IPAddress ClientIP(192,168,4,2);
 
// A UDP instance to let us send and receive packets over UDP
WiFiUDP udp;
 
char packetBuffer[9];   //Where we get the UDP data
//=======================================================================
//                Setup
//=======================================================================
void setup()
{
    Serial.begin(9600);
    Serial.println();
    WiFi.softAP(ssid, pass);    //Create Access point
 
    //Start UDP
    Serial.println("Starting UDP");
    udp.begin(localPort);
    Serial.print("Local port: ");
    Serial.println(udp.localPort());
}
//======================================================================
//                MAIN LOOP
//======================================================================
void loop()
{
    int cb = udp.parsePacket();
    if (!cb)
    {
      //If serial data is recived send it to UDP
      if(Serial.available()>0)
        {
        udp.beginPacket(ClientIP, 2000);
        //Send UDP requests are to port 2000
       
        char a[1];
        a[0]=char(Serial.read()); //Serial Byte Read
        udp.write(a,1); //Send one byte to ESP8266
        udp.endPacket();
        }
    }
    else {
      // We've received a UDP packet, send it to serial
      udp.read(packetBuffer, 1); // read the packet into the buffer, we are reading only one byte
      Serial.print(packetBuffer);
      delay(20);
    }
}

The server

#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
LiquidCrystal_I2C lcd(0x3F, 20, 4);
 
const char *ssid = "MyWifi";
const char *pass = "password";
 
unsigned int localPort = 2000; // local port to listen for UDP packets
 
IPAddress ServerIP(192,168,4,1);
IPAddress ClientIP(192,168,4,2);
 
// A UDP instance to let us send and receive packets over UDP
WiFiUDP udp;
 
char packetBuffer[9];   //Where we get the UDP data
//=======================================================================
//                Setup
//=======================================================================
void setup()
{
    Serial.begin(9600);
    Serial.println();
    WiFi.softAP(ssid, pass);    //Create Access point
 
    //Start UDP
    Serial.println("Starting UDP");
    udp.begin(localPort);
    Serial.print("Local port: ");
    Serial.println(udp.localPort());
     lcd.init();
  lcd.backlight();
  //lcd.begin();
  lcd.home();
  lcd.setCursor(0, 0);
  lcd.print(" Scanning...    ");
  Serial.print("starting");
}
//======================================================================
//                MAIN LOOP
//======================================================================
void loop()
{
    int cb = udp.parsePacket();
    if (!cb)
    {
      //If serial data is recived send it to UDP
      if(Serial.available()>0)
        {
        udp.beginPacket(ClientIP, 2000);
        //Send UDP requests are to port 2000
       
        char a[1];
        a[0]=char(Serial.read()); //Serial Byte Read
        udp.write(a,1); //Send one byte to ESP8266
        udp.endPacket();
        }
    }
    else {
      // We've received a UDP packet, send it to serial
      udp.read(packetBuffer, 1); // read the packet into the buffer, we are reading only one byte
      Serial.print(packetBuffer);
      delay(20);
    }

and I want to send the reads to the NodeMcu that with the LCD , to shows the IDU of the RFID chip .
where the wrong ?

Thank You.

where the wrong ?

There is no code to write to the LCD.

If you have more questions, provide a wiring diagram and links to the used hardware! And learn to use code tags (</> button in the editor), not quote tags.

To make it easy for people to help you please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

The text editor shows line numbers, identifies matching brackets and allows me to search for things like all instances of a particular variable or function.

...R

So I Modify it .

So atm you have 2 sketches that transfer data from the serial into a UDP packet and vice-versa, you could for the 2nd sketch have the received data print on the lcd, (step 1) then for the first sketch receive data from the RFID reader and send this as a UDP packet (step 2) take one step at a time.

Deva_Rishi:
So atm you have 2 sketches that transfer data from the serial into a UDP packet and vice-versa, you could for the 2nd sketch have the received data print on the lcd, (step 1) then for the first sketch receive data from the RFID reader and send this as a UDP packet (step 2) take one step at a time.

How I can do it ?
and can I send the data to website ?
when the NodeMcu Togther conected ?

HENDABED:
How I can do it ?

you have code for sending and receiving UDP packet :

void loop()
{
    int cb = udp.parsePacket();
    if (!cb)
    {
      //If serial data is recived send it to UDP
      if(Serial.available()>0)
        {
        udp.beginPacket(ClientIP, 2000);
        //Send UDP requests are to port 2000
       
        char a[1];
        a[0]=char(Serial.read()); //Serial Byte Read
        udp.write(a,1); //Send one byte to ESP8266
        udp.endPacket();
        }
    }
    else {
      // We've received a UDP packet, send it to serial
      udp.read(packetBuffer, 1); // read the packet into the buffer, we are reading only one byte
      Serial.print(packetBuffer);
      delay(20);
    }
}

all you need to do is modify origin of the data for the RFID sketch and modify the destination for the LCD sketch

HENDABED:
and can I send the data to website ?
when the NodeMcu Togther conected ?

I'd say so, you'd have to either let the access-point act as a station also (and connect to your wifi) or connect both to your wifi (preferred choice i think) and send the UDP-packet via the router, this will change the IP-address setup (either static or dynamic, but they will be determined by the router gate-way)

Hi ,

I have question ,
I want to conecte two NodeMCU togher one as a server and the other as clinet
the clinet conected to RFID reader , and the Server conected with LCD .
the LCD showes the number of the Tags .

I want after that the server sends the RFID ID to Blynk .
can I do that ?