As part of the study, the IP found: when receiving packets of different lengths, the received data is not correctly displayed in the serial port. To correct after the line
Code:
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
add this
Code:
packetBuffer[packetSize]=0;