sending float value via udp

im trying to send a float value to a udp server running in python, My python output looks like this,

Message from Client:b'NODE01\x00\x00\x00\x00\x00\x00\x00\x0001NODE'

This is my arduino code,
void sendPacket() {
Serial.println("3");
const char delimiter[] = "NODE01";
const char delimiter2[] = "01NODE";

Udp.beginPacket(Server, ServerPort);
Udp.write((const uint8_t *)delimiter, sizeof(delimiter) - 1);
Udp.write((const uint8_t *)&localData, sizeof(localData));
Udp.write((const uint8_t *)delimiter2, sizeof(delimiter2) - 1);
Udp.endPacket();
ready = true;
//sendPacket2();
}

how can i just send localData.temp so i can see the value in the python server? i do not need to send the delimiter. the code is a program i made for a different project but its been so long ive forgotten what i was doing

do i need to convert the float to a string? how could i do this. in my python program im going to record the tempature values send by the esp. I tried

const char tempValue[] = {localData.temp};

but when the server send the message nothing shows up.

I have also tried,

String msg = String(localData.temp, sizeof(localData.temp));
Udp.beginPacket(Server2, ServerPort);
Udp.print(msg);

But the result in my python console is not showing anything im getting blank messages,

Heres the python code,

import socket

localIP = "10.0.0.104"
localPort = 9999
bufferSize = 1024
msgFromServer = "Hello UDP Client"
bytesToSend = str.encode(msgFromServer)
# Create a datagram socket
UDPServerSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
# Bind to address and ip
UDPServerSocket.bind((localIP, localPort))
print("UDP server up and listening")
# Listen for incoming datagrams
while (True):
    bytesAddressPair = UDPServerSocket.recvfrom(bufferSize)
    message = bytesAddressPair[0]
    address = bytesAddressPair[1]
    clientMsg = "Message from Client:{}".format(message)
    clientIP = "Client IP Address:{}".format(address)
    print(clientMsg)
    print(clientIP)
    # Sending a reply to client
    UDPServerSocket.sendto(bytesToSend, address)

i cant figure out what im doing wrong.

Do I need to convert the float to a string? how could i do this. in my python program im going to record the temperature values send by the esp.

I would convert them to a string as you suggest, something like:

char buffer[10];
sprintf (buffer, "%5.2f", float_to_send);

Then use the bytes in buffer and send those.

However, if your data is a temperature reading I am guessing you got it from some kind of temperature sensor, in which case you ought to be able to recover from somewhere the raw data from the sensor before it was converted into a float. That data will just be some bytes that you can send directly using UDP.

I can't offer any help with Python, sorry.

As it turns out, when i tried to convert to a string it "was" working. i had it in the wrong function in my arduino code so it never printed anything to the server because i wasnt running the right function... im sorry and thanks i forgot about sprintf its been a while since ive messed with arduino code. in the end this is what worked,

Arduino,

void sendPacket() {
  Udp.beginPacket(Server, ServerPort);
  String msg = String(localData.temp);
  Udp.beginPacket(Server2, ServerPort);
  Udp.print(msg);
  Udp.endPacket();
}

Python,

import socket
UDP_IP_ADDRESS = "10.0.0.104"
UDP_PORT_NO = 9999
serverSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
serverSock.bind((UDP_IP_ADDRESS, UDP_PORT_NO))
while True:
    data, addr = serverSock.recvfrom(1024)
    print ("Message: ", data.decode("ASCII"))