Getting data from Arduino MKRWAN 1310 LoRa to TTN

Hello, I am currently trying to write a code in Arduino IDE 2.0.1 that will allow me to get data from a vibration sensor (ARD VIB 01) into ttn.
My previous code (Below) does connect to TTN, but only on command.
I don’t know how to make it so that, for example, every 10 minutes a data is automatically sent from MKRWAN to TTN. In the Arduino IDE the Data of the virbrationssensors arrive regularly, I do not know only how I get these then to the ttn.
I know that this is for some again an annoying post, but I’m desperate for days and would appreciate help.
A gateway is of course also available and already connected.
(The appkey is of course normally entered correctly, only hidden here)
Best regards

#include <MKRWAN.h>

LoRaModem modem;

String appEui = “0000000000000000”;
String appKey = “76AAA*************************”;

void setup() {
if (!modem.begin(EU868)) {
//Failed to start module
while (1);
};

int connected = modem.joinOTAA(appEui, appKey);
while(!connected){
//Retry
if(!modem.joinOTAA(appEui, appKey)){
//Fail
}
else{
break;
}
};

// put your setup code here, to run once:
Serial.begin(1152000000);
}
void loop() {
// put your main code here, to run repeatedly:
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.println(voltage);
}

Follow this guide Connecting MKR WAN 1310 to The Things Network (TTN)

I did, but now I still don't know how to get data from the vibration sensor to TTN.

First try the example in the guide to check if you have connection. If you have, means your board is working fine. Then you can try and get your sensor to work afterwards.

I tryed. It works. I get data in TTN. But now, i have no clue how to change the code, that the sensor send the sensor Data to TTN.

Your topic has been moved to a more suitable location on the forum
Installation and Troubleshooting is not for problems with (nor for advice on) your project.

Did you get it working ?