29
29
#include < rn2xx3.h>
30
30
31
31
// create an instance of the rn2xx3 library,
32
- // giving the software serial as port to use
32
+ // giving Serial1 as stream to use for communication with the radio
33
33
rn2xx3 myLora (Serial1);
34
34
35
35
String toLog;
@@ -47,8 +47,7 @@ void setup()
47
47
Serial1.begin (57600 );
48
48
49
49
// make sure usb serial connection is available,
50
- // or after 10s go on anyway for 'headless' use of the
51
- // node.
50
+ // or after 10s go on anyway for 'headless' use of the node.
52
51
while ((!SerialUSB) && (millis () < 10000 ));
53
52
54
53
SerialUSB.println (" SODAQ LoRaONE TTN Mapper starting" );
@@ -64,6 +63,11 @@ void setup()
64
63
// initialize GPS
65
64
sodaq_gps.init (GPS_ENABLE);
66
65
66
+ // Set the datarate/spreading factor at which we communicate.
67
+ // DR5 is the fastest and best to use. DR0 is the slowest.
68
+ myLora.setDR (dr);
69
+
70
+ // LED pins as outputs. HIGH=Off, LOW=On
67
71
pinMode (LED_BLUE, OUTPUT);
68
72
digitalWrite (LED_BLUE, HIGH);
69
73
pinMode (LED_RED, OUTPUT);
@@ -124,6 +128,7 @@ void loop()
124
128
sodaq_gps.scan (true );
125
129
digitalWrite (LED_GREEN, HIGH);
126
130
131
+ // if the latitude is 0, we likely do not have a GPS fix yet, so wait longer
127
132
while (sodaq_gps.getLat ()==0.0 )
128
133
{
129
134
SerialUSB.println (" Latitude still 0.0, doing another scan" );
@@ -178,7 +183,8 @@ void loop()
178
183
digitalWrite (LED_BLUE, HIGH);
179
184
180
185
// Cycle between datarate 0 and 5
181
- dr = (dr + 1 ) % 6 ;
182
- myLora.setDR (dr);
186
+ // dr = (dr + 1) % 6;
187
+ // myLora.setDR(dr);
188
+
183
189
SerialUSB.println (" TX done" );
184
190
}
0 commit comments