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);
}