All the software modifications you'd need to make are within one line of code.py. The country defaults to the US (adafruit is located in this region), but you can change it to any of the four supported regions:
- US - USA, Canada, and South America
- EU - Europe
- AS - Asia
- AU - Australia
If you wanted to switch to an European frequency plan, you'd configure the
ttn_config object with the following parameters:
ttn_config = TTN(devaddr, nwkey, app, country = 'EU')
We've supported a subset of the major frequency plans in the initial release of TinyLoRa for CircuitPython. If you don't see your region listed here, you can submit an issue and we'll add it to the library.
By default, TinyLoRa for CircuitPython broadcasts on multiple channels, randomly hopping between them. Since most gateways only listen for a transmission on a few channels at a time, this is a way to increase the probability of the gateway "seeing" the packet.
You can specify a channel by feeding the LoRa object constructor a channel as a keyword argument. For example, if you'd like to send data on channel 3, the object would be created like the following:
lora = TinyLoRa(spi, cs, irq, ttn_config, channel=3)
Want to change channels during the event loop, between sending different data packets? We included a
set_channel function which will set up the radio to use the specified channel:
By default, TinyLoRa uses the datarate SF7BW125. That is, a spreading factor of 7 and a bandwidth of 125kHz. Similar to setting a channel, TinyLoRa can set the datarate given a specific bandwidth and spreading factor. If you'd like to set the transmission datarate to a spreading factor of 10 and a bandwidth of 125kHz, call
set_datarate() like the following:
TinyLoRa has the following datarates available for use by this method:
- SF7BW125, SF7BW250, SF8BW125, SF9BW125, SF10BW125, SF11BW125, SF12BW125
Want to learn more about datarates and LoRa? Check out this blog post here..
If you're hitting an error,
RuntimeError: Timeout during packet send , it's likely a gateway is not in range, or connected properly. Ensure that there are gateways near you and in-range (click here for a map of all the registered gateways).
If you're a Things Network Gateway operator, check from the Things Network Console if the gateway has been seen recently. If the Last Seen value is greater than a few minutes, reset your gateway.
If you haven't disabled frame counter checks from within your device (instructions on how do this are on the TinyLoRa TTN Setup page), you'll encounter this issue when the device is reset/loses power.
Why would this happen? There's a mismatch between the frame counter on your device and the frame counter on The Things Network. Most likely, the frame counter on your device is reset to zero, and the frame counter on your device's console is set to the last known value.
There are ways around this issue, such as using a different activation method such as OTAA (currently unsupported by TinyLoRa).
However, we can still reset both the node and the frame counter on the application.
To do this, From your Things Network Console, navigate to your device (Applications->Application->Device).
Click the reset frame counters button next to the Frames up label. This will reset the frame counter of the device (on The Things Network's Console) to zero.
We'll also need to reset the frame counter on our device to zero. Press the RST button on the board.
Disabling frame counter checks allows you to transmit data to The Things Network without requiring a match between your device's frame counter and the console's frame counter.
If you're making a project and doing a lot of prototyping/iteration to the code, disabling these checks is okay as it'll let you reset the device and not re-register it to the application (it'll also prevent counter overflows).
If you're deploying a project, you'll want to re-activate the frame counter for security purposes. With the frame counter disabled, one could re-transmit the messages sent to TTN using a replay attack.
The Things Network's documentation page has a full explanation about the role of the Frame Counter.