Dealing with Serial.read();

Hello,
I have this cod that using UDP for sending between 2 esp32 . The sending and receiving process doing by using Serial port.
How can I update on it to send and receive from code: I mean I need to send this message rx_val=1999; (not from serial port) . How can I receive it ?

This code for sending:

    int rp=udp.parsePacket(); //check for udp packets
     rx_val=1999;  //Serial.read();
     Serial.print("udp_send: ");
     Serial.println(rx_val);
     udp.beginPacket(udpAddress,udpPort);
     udp.write(rx_val);
     udp.endPacket();

And this for receiving:

    char pktbuf1[10]; 
    udp.read(pktbuf1,2);
    delay(20);
    Serial.print("Packet from "+String(udpAddress)+": ");
    Serial.print(pktbuf1);
    delay(1000);

Are you aware of ESP-Now?

Yes, I used it before now. I need to use UDP

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