Need help to program uplink payload if possible?

I need help with programming uplink payloads for my ESP32, which is connected to a network server to track the time transmission interval and data payload. Essentially, I want to monitor the downtime between the communication of my ESP32 and the server.

Using a LoRaWAN example file, I have successfully connected to my network server via OTAA to send uplink messages. Now, I want to utilize LoRa to send data from my devices to the network server. The device in question is a JSN-SR04T ultrasonic sensor. I have written code to read the sensor's values on arduino ide, and my ESP32 can send its own data to the network server.

Is there a way to send the sensor's readings to the network server using LoRa?
Is this feasible?

Yes.

how do I create a uplink data payload if I have the value of something like distance = 20 cm?

Post your code and what does not work. And what hardware you try to use for LoRa ...

its not that it does not work. more of like my esp32 is alr connected to the gateway via lora and sending data to my network server(chirpstack).

I am not sure how to change or edit the value of the data payload. Right now it is sending a payload oif 41424344 which has no value and meaning.

For the Hardware part I am using
microcontroller board-> HELTEC LORA 32 V3.1
sensors-> JSN-SR04T(ultrasonic sensor)

For the Software part I need help to be able to get the data(i.e. distance detected 20cm)
encode and to be sent to the network server.


static void prepareTxFrame(uint8_t port) {
    appDataSize = 4; // AppDataSize max value is 64
    appData[0] = 'A';
    appData[1] = 'B';
    appData[2] = 'C';
    appData[3] = 'D';
}

You define 4 byte payload and you see it on the servers GUI as 0x41 0x42 0x43 0x44:

static void prepareTxFrame ...

Change that to max. 64 bytes and fill as you please.

I got it thank you very much