Skip to content

Commit b435998

Browse files
committed
[MKC-525] Update IoT Cloud LoRaWAN Article
Updated code + added disclaimer to limit update frequency to 3 minutes
1 parent f0a2d24 commit b435998

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

Diff for: content/cloud/iot-cloud/tutorials/04.cloud-lora-getting-started/cloud-lora-getting-started.md

+20-16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ So, what does that mean for you? It means that you can connect to any of the **2
2222

2323
In this tutorial we will walk you through the steps needed to successfully provision devices that use the Arduino Cloud & The Things Network, from unboxing your device until viewing data on a dashboard!
2424

25+
***Please note that when working with LoRaWAN® devices, data rates are very limited. Messages sent from devices should be limited to once every several minutes. Methods for implementing this are described further down in this article. To read more about limitations using the LoRaWAN® network, please visit [The Things Network Limitations article](https://www.thethingsnetwork.org/docs/lorawan/limitations/).***
26+
2527
### Terminology Run-Trough
2628

2729
- **LoRa®** - short for **Lo**ng **Ra**nge, and is a modulation technique used to send and receive data over low-power, wide-area networks (LPWAN).
@@ -62,7 +64,6 @@ The goals of this project are:
6264
- [Arduino MKR WAN 1300](https://store.arduino.cc/mkr-wan-1300) or [Arduino MKR WAN 1310](https://store.arduino.cc/mkr-wan-1310)
6365
- [Antenna](https://store.arduino.cc/antenna)
6466

65-
6667
## Circuit
6768

6869
Follow the wiring diagram below to connect the antenna to the MKR WAN 1300/1310 board.
@@ -166,7 +167,7 @@ After some time, the automatic email sent out by TTI will expire. If the link is
166167

167168
## Step 3: Completing Arduino Cloud Setup
168169

169-
In this step, we will complete the Arduino Cloud setup that we started earlier by configuring a device. We will create a simple **test variable**, that we will use to send data from the MKR WAN 1300/1310 device. This will just be a counter that updates every 10 seconds, to see if the data can be successfully sent from **end device** to the **Arduino Cloud** via the **The Things Network**.
170+
In this step, we will complete the Arduino Cloud setup that we started earlier by configuring a device. We will create a simple **test variable**, that we will use to send data from the MKR WAN 1300/1310 device. This will just be a counter that updates **3 minutes**, to see if the data can be successfully sent from **end device** to the **Arduino Cloud** via the **The Things Network**.
170171

171172
***At this point, we will need to make sure that we are in reach of a gateway registered to The Things Network. This might take a few attempts, depending on your device's success of transmitting to a nearby gateway. You can check the coverage of your area through either [TTN Map](https://www.thethingsnetwork.org/map) or the [TTN Mapper](https://ttnmapper.org/)***
172173

@@ -178,20 +179,14 @@ In this step, we will complete the Arduino Cloud setup that we started earlier b
178179

179180
![Create a new variable.](assets/cloud-lora-img-16.png)
180181

181-
**3.** Let's head to the **Sketch** tab, and add the following code inside the `void loop()`:
182-
183-
```arduino
184-
test = test + 1;
185-
delay(10000);
186-
```
187-
188-
This code will simply increase the `test` variable every 10 seconds, which will sync with the variable we just created. That means that every 10 seconds, there's a change in value, which should also be visible in the Arduino Cloud if the data is sent properly.
189-
190-
You can take a look at the full code in the snippet below:
182+
**3.** Let's head to the **Sketch** tab, where you can use the following code:
191183

192184
```arduino
193185
#include "thingProperties.h"
194186
187+
unsigned long previousMillis = 0;
188+
const long interval = 180000; //180 second interval (3 minutes)
189+
195190
void setup() {
196191
// Initialize serial and wait for port to open:
197192
Serial.begin(9600);
@@ -217,14 +212,23 @@ void setup() {
217212
218213
void loop() {
219214
ArduinoCloud.update();
220-
// Your code here
221-
hello = hello + 1;
222-
Serial.println(hello);
223-
delay(10000);
224215
216+
unsigned long currentMillis = millis();
217+
218+
if (currentMillis - previousMillis >= interval) {
219+
220+
previousMillis = currentMillis;
221+
222+
test +=1;
223+
224+
}
225225
}
226226
```
227227

228+
This code will simply increase the `test` variable every 3 minutes, which will sync with the variable we just created. That means that every 3 minutes, there's a change in value, which should also be visible in the Arduino Cloud if the data is sent properly.
229+
230+
***Note that the 180000 milliseconds / 180 seconds / 3 minutes interval should be in place to limit the amount of data being sent from the device to the Arduino Cloud. This can also be defined during the variable creation in the Thing interface to update only every 180 seconds.***
231+
228232
**4.** Finally, we can upload the sketch to the board. After we have uploaded it, the board will start sending data via The Things Network, to the Arduino Cloud. We can check if we are receiving any data in the **Things overview**, under the **"Last Value / Last Update"** column.
229233

230234
![Data from the MKR WAN 1300/1310 device.](assets/cloud-lora-img-18.png)

0 commit comments

Comments
 (0)