You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- `Stream& modemStream`: Stream for the LoRa modem (for The Things Node/Uno use `Serial1` and data rate `57600`).
16
-
- `Stream& debugStream`: Stream to write debug logs to (for The Things Node/Uno use `Serial` and data rate `9600`).
15
+
- `Stream& modemStream`: Stream for the LoRa modem (see comments at the end of this document).
16
+
- `Stream& debugStream`: Stream to write debug logs to (see comments at the end of this document).
17
17
- `fp_ttn_fp fp`: The frequency plan: `TTN_FP_EU868` or `TTN_FP_US915` depending on the region you deploy in.
18
18
- `uint8_t sf = 7`: Optional custom spreading factor. Can be `7` to `12` for `TTN_FP_EU868` and `7` to `10` for `TTN_FP_US915`. Defaults to `7`.
19
19
- `uint8_t fsb = 2`: Optional custom frequency subband. Can be `1` to `8`. Defaults to `2` (for US915).
@@ -174,3 +174,68 @@ void sleep(unsigned long mseconds);
174
174
```
175
175
176
176
- `unsigned long mseconds`: number of milliseconds to sleep.
177
+
178
+
# Comments
179
+
## Serial ports (Stream objects)
180
+
The Stream objects (Serial ports) need to be initialized at the correct baud rates at the start of your `setup()` function. See [our examples](https://github.com/TheThingsNetwork/arduino-device-lib/blob/asian-frequency-plans/examples) for more details. For example:
181
+
```
182
+
loraSerial.begin(57600);
183
+
debugSerial.begin(9600);
184
+
```
185
+
186
+
### TheThingsUno
187
+
At the top of your sketch use
188
+
```
189
+
#define loraSerial Serial1
190
+
#define debugSerial Serial
191
+
```
192
+
And in your `setup()` function use
193
+
```
194
+
void setup()
195
+
{
196
+
loraSerial.begin(57600);
197
+
debugSerial.begin(9600);
198
+
...
199
+
}
200
+
```
201
+
202
+
### SodaqOne
203
+
At the top of your sketch use
204
+
```
205
+
#define loraSerial Serial1
206
+
#define debugSerial SerialUSB
207
+
```
208
+
And in your `setup()` function use
209
+
```
210
+
void setup()
211
+
{
212
+
loraSerial.begin(57600);
213
+
debugSerial.begin(9600);
214
+
...
215
+
}
216
+
```
217
+
218
+
### Arduino Uno, Arduino Nano or other devices using SoftwareSerial
219
+
The Arduino Uno only has one hardware serial port which is used to communicate over USB to the computer. When connecting an RN2483/RN2903 to the Arduino Uno, one has to make use of SoftwareSerial. If you connected the RN2483/RN2903 to the Arduino using the same pinout as [described on the forum](https://www.thethingsnetwork.org/forum/t/how-to-build-your-first-ttn-node-arduino-rn2483/1574), you can make use of the following code.
220
+
221
+
At the top of your sketch use
222
+
```
223
+
#include <SoftwareSerial.h>
224
+
225
+
#define debugSerial Serial
226
+
227
+
SoftwareSerial loraSerial(10, 11); // RX, TX
228
+
```
229
+
And in your `setup()` function use
230
+
```
231
+
void setup()
232
+
{
233
+
loraSerial.begin(9600);
234
+
debugSerial.begin(9600);
235
+
...
236
+
}
237
+
```
238
+
239
+
SoftwareSerial does not operate correctly at high baud rates. We normally use it at 9600 baud. Because the RN2483 and RN2903 normally operates at 57600 baud, we need to switch it to 9600 baud so that we can communicate with it using 9600 baud. Luckily this is done automatically inside TheThingsNetwork Arduino library, so you as user do not have to worry about this.
240
+
241
+
If you connected the RN2483/RN2903 to different pins on the Arduino, you can change the line `SoftwareSerial loraSerial(10, 11); // RX, TX` to specify the correct RX and TX pins (from the Arduino's perspective).
0 commit comments