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

Hello tomjacobs:
Did you get issues solved? I am going to get Arduino MKRWAN 1310 soon at Minneapolis. Can I connect Arduino MKRWAN 1310 with a LoRa gateway for free? I am new for LoRa WAN networking here.
Thanks,
Flyingbean

Yes, just be sure to follow the TTN FUP (Forum search) and stay within commercial limits and you should be golden :slight_smile:

Yes TTN is free as long as you stay within the fair useage limits;

https://www.thethingsnetwork.org/docs/lorawan/duty-cycle/#fair-use-policy

So you need to calculate the air time of the packets size you are sending, see here;

https://www.thethingsnetwork.org/airtime-calculator

Hi [LoRaTracker]:
It is a great resource for my project. I am planning to build a project which will use LoRa tech to track Bees. The limit of using LoRa is quite a tight constraint for the project: 30 seconds per day (24 hours) per node and the downlink messages to 10 messages per day (24 hours. Anyway, I need to plan better how to fit my project into the usage limits before move to next step.
Where should I start to learn how to use LoRa gateway? In another word, I need to collect data from the cloud of LoRa gateway into my computing system.
Thanks in advance.
flyingbean

Depends on how far away they fly - if they stay close to the gateway you’ll be able to send far more messages as the data rate will be faster.

Scroll to the top of the page and click on the Learn link …

You can use LoRa point to point for free, but someone else has to pay for and support the significant infrastructure that is required to get your TTN\LoRaWAN messages from the receiving Gateway to your application on an Internet server somewhere. So what you can get for free is going to be limited. If you need more capacity then contact TTI for a paying option.

The limit of 10 downlinks a day is there partly for legal reasons, the Gateway has to observe legal duty cycle limits, typically 1% airtime, so its just not legally possible for it to send heaps of downlinks to a large number of nodes.

Best way to learn how to use a Gateway is to get one, the Things Indoor Gateway is not expensive, and quite handy for testing stuff…