New firmware release 1.6.7.b1 (LoRaWAN Nano Gateway with TTN example!!)
We are very excited about this one. I know that many around here have been waiting patiently to see the LoPy work as a LoRaWAN Nano Gateway and connect it to servers like TTN, but guess what? we did it :-)
The Nano gateway script is located here: https://github.com/pycom/pycom-libraries/tree/master/examples/lorawan-nano-gateway
For the Nano Gateway itself you need nanogateway, config and main. The other 2 files are examples on how to setup the nodes either with ABP or OTAA join methods.
Before trying the nano gateway make sure to update the LoPy to firmware version 1.6.7.b1 first!
Features/characteristics of the Nano Gateway:
- Single channel and single datarate (for now, multiple datarates on a single channel will come soon).
- Support for Downlinks on any channel and DR.
- OTAA and ABP.
- Semtech packet forwarder protocol version 2.
- NTP sync.
The script uses multithreading and callbacks heavily, so it's a very nice example of the capabilities of the LoPy and MicroPython. The total RAM consumed is only around 22KB.
Features to be added soon:
- Ability to receive packets sent on any spreading factor.
- Add an option to enable and disable debug messages.
- Implement the .stop() method to gracefully stop and start the nano gateway at any moment.
All comments and suggestions are more than welcome.
Malaysia uses the AS923 plan:
Vicky_ last edited by
@jmarcelino I live in Malaysia. May i know what frequency should i use? i have tried to search but i couldn't find.
@jmarcelino thank you again. This makes much sense. I was looking on the wrong end.
Glad you managed to receive data.
Yes, that's exactly what LoRaWAN gateways are :) They don't send or receive anything on their own, that's the job for the network server.
@jmarcelino thank you for your reply!
When I add some data in the downlink field in the TTN backend, this data is received by the node. This is already one more step forward :-)
Should I see the gateway as a "dumb" packet forwarder, and do the logic on the node and the TTN side?
jmarcelino last edited by jmarcelino
In LoRaWAN with TTN (Class A) you must send data from the node in order to receive any messages back.
But if you queue a downlink with TTN you should receive it in your node - for example with
data = s.recv(64)- once you've done an uplink (an s.send(...) ).
I have a setup with a node and a nano gateway with the latest default script from Github. The data is received in the TTN backend, so that part is working.
I want to update the date and time on the nodes over Lora (no wifi) I discovered that no rx data is received on the node. Could you give me a hint how to configure the gateway to send back the current time to the node?
@livius Thanks. I was looking into docs and I found the examples. Though they needed modifications, it worked perfectly.
livius last edited by
@devang-sharma said in New firmware release 1.6.7.b1 (LoRaWAN Nano Gateway with TTN example!!):
look at examples
and sources on git
Devang Sharma last edited by Devang Sharma
@jmarcelino, KotahiNet does not provide free connectivity in India. Also, they provide private LoRaWAN network only to the larger companies.
Is it possible to connect one LoPy(acting as a node) to connect with another LoPy(acting as a Gateway) without such LoRaWAN network?
If yes, can you guide me how to achieve it?
My question might not seem a good one, but I'm really new to LoRa.
@jmarcelino, thanks. I've sent them an e-mail in order to get a free network connection. I hope they'll reply soon.
jmarcelino last edited by jmarcelino
India has a unique Frequency plan:
I recommend setting your config.py for the nano gateway and nodes to
LORA_FREQUENCY = 865062500
and make sure your nodes use this 865062500 frequency as well:
# set the 3 default channels to the same frequency lora.add_channel(0, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=5) lora.add_channel(1, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=5) lora.add_channel(2, frequency=config.LORA_FREQUENCY, dr_min=0, dr_max=5)
@daniel, I live in India. While registering the gateway, which frequency plan I should choose? Can I choose Europe or do I have to choose Asia?
I've updated the Nano-gateway documentation to show how to generate a Gateway ID and also to reflect the changes in the TTN interface: https://docs.pycom.io/chapter/tutorials/lopy/lorawan-nano-gateway.html
Thanks again for your suggestion!
Thank you very much for your suggestion, TTN changed their language and gateway registration process recently - we'll update our documentation to reflect this.
fredg last edited by
I'm coming from this tutorial: https://docs.pycom.io/chapter/tutorials/lopy/lorawan-nano-gateway.html
You should update it probably to mention the "I'm using the legacy packet forwarder" for TTN network, and update the code to make it easy to extract the GATEWAY_ID.
Or maybe update the code to allow any GATEWAY_ID for TTN? I'm not sure how it really works...
@daniel Excellent! Seems no need to directly alter the join command since the 'dr' parameter also uses a config parameter, 'LORA_NODE_DR'. I'm looking at the latest example on Github.
@jomifo yes, if you change the spreading factor to 12 ("SF12BW125") the range will be much better. Do this both on the nano-gateway and in the node. You also need to tweak the Join command like this:
lora.join(activation, auth, * ,timeout=None, dr=None)
drand make it 0 (which is the same as SF12BW125).
I have successfully used the nanogateway example code to push some temperature sensor data (MCP9808) to TTN and am happy about that. Now I'm wondering are there ways using this example to configure LoRa to increase the range? I see the LORA_GW_DR = "SF7BW125" property in the config, but am unsure how or if this can be used to tweak Lora.