UDP packet strange characters

I successfully transmit UDP packet from d1 mini to another d1 mini, however in serial monitor, I am seeing other random characters and numbers (:urn 1) I did not call for. What is this and how to avoid?

78

Code for Server Side

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

#define WIFI_SSID "XXXX"
#define WIFI_PASS "XXXX"

// Set AP credentials
#define AP_SSID "XXXX"
#define AP_PASS "XXXX"
#define AP_CHANNEL 1
#define AP_HIDDEN true
#define AP_MAX_CON 8
 
// UDP
WiFiUDP UDP;
IPAddress local_IP(192,168,4,1);
IPAddress gateway(192,168,4,1);
IPAddress subnet(255,255,255,0);
#define UDP_PORT 4010
 
// UDP Buffer
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];

ESP8266WebServer server(80);

/* Just a little test message.  Go to http://192.168.4.1 in a web browser
   connected to this access point to see it.
*/

void handleRoot() {
  server.send(200, "text/html", "<h1>You are connected</h1>");
}

void setup() {
 
  // Setup LED pin
   pinMode(LED_BUILTIN, OUTPUT);
   digitalWrite(LED_BUILTIN, LOW);
   
  // Setup serial port
  Serial.begin(115200);
  Serial.println();
  
  // Begin WiFi
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  
  // Connecting to WiFi...
  Serial.print("Connecting to ");
  Serial.print(WIFI_SSID);
  // Loop continuously while WiFi is not connected
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(100);
    Serial.print(".");
  }
  
  // Connected to WiFi
  Serial.println();
  Serial.print("Connected! IP address: ");
  Serial.println(WiFi.localIP());

  
  // Begin Access Point
  Serial.println("Starting access point...");
  WiFi.softAPConfig(local_IP, gateway, subnet);
  WiFi.softAP(AP_SSID, AP_PASS, AP_CHANNEL, AP_HIDDEN, AP_MAX_CON);
  Serial.println(WiFi.localIP());

  // Connected to WiFi
  Serial.println();
  Serial.println("Connected!");
  Serial.print("IP address for network ");
  Serial.print(WIFI_SSID);
  Serial.print(" : ");
  Serial.println(WiFi.localIP());
  Serial.print("IP address for network ");
  Serial.print(AP_SSID);
  Serial.print(" : ");
  Serial.print(WiFi.softAPIP());
  Serial.print('\n');
 
  // Begin listening to UDP port
  UDP.begin(UDP_PORT);
  Serial.print("Listening on UDP port ");
  Serial.println(UDP_PORT);

  //
  server.on("/", handleRoot);
  server.begin();
  Serial.println("HTTP server started");
 
}
 
void loop() {
  server.handleClient();
  
   int packetSize = UDP.parsePacket();
   int atm =  UDP.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
   Serial.println(atm);
   digitalWrite(LED_BUILTIN,LOW);
  if(packetSize && atm == 1)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.println(atm);
    digitalWrite(LED_BUILTIN,HIGH);
    
  }      
  delay(1000);
 
} 

your code looks fuzzy in my crystal ball ... (use </>)

I added the server code now, it is outputing to the serial monitor

I'd say that is standard debug output from the ESP. You may be able to change this in the board configuration. It would not bother me.

image

is this the output from?

    int atm =  UDP.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    Serial.println(atm);