LoPy-nano-gateway-wan-private: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(19 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Link title]] | ==[[Link title]]== | ||
== LoPy Nano-gateway and private | == LoPy Nano-gateway and private lora-server installation == | ||
* | |||
* | In this page we are going to: | ||
** | |||
1.Install open source private LoRa server (by [https://github.com/brocaar Orne Brocaar]) | |||
2.Setup LoPy as single channel nano gateway | |||
3.Send data from LoPy node | |||
---- | |||
1.Install private LoRa server: | |||
We use [https://github.com/brocaar/loraserver-setup LoRa Server Setup] Ansible playbook to install all the LoRa server component: | |||
For testing use vagrant to install the server to virtual machine in our local pc (We will update the guide to deploy later): | |||
*Download and install vagrant to your machine [https://www.vagrantup.com/downloads.html vagrant download page] | |||
*Install git to your machine | |||
*Clone the LoRa Server Setup repository [https://github.com/brocaar/loraserver-setup#vagrant Reference]: | |||
git clone https://github.com/brocaar/loraserver-setup.git | |||
*Go to loraserver-setup folder (In terminal or CMD) | |||
cd loraserver-setup | |||
*Run vagrant up | |||
vagrant up | |||
*The virtual machine will boot and install all the component (This can take a while) | |||
*Note: we can access the server web interface at https://localhost:8080/ (As a self-signed certificate is used, your browser will prompt that the certificate can't be trusted. This is ok for testing) | |||
*We can use our machine IP address and port 1700 for our gateway to forward the package (We do this later in setup LoPy as Nano Gateway below) | |||
---- | |||
2.Setup LoPy as a Single channel nano gateway: (Reference [https://forum.pycom.io/topic/810/new-firmware-release-1-6-7-b1-lorawan-nano-gateway-with-ttn-example Pycom Forum] [https://github.com/pycom/pycom-libraries/tree/master/examples/lorawan-nano-gateway Github Code] | |||
*Update LoPy firmware to 1.6.7.b1 [https://docs.pycom.io/pycom_esp32/pycom_esp32/getstarted.html?highlight=update#firmware-upgrades Firmware Upgrade] | |||
*Download main.py, config.py, nanogateway.py from [https://github.com/pycom/pycom-libraries/tree/master/examples/lorawan-nano-gateway Github]: | |||
*Edit the config.py file to setup: Gateway ID, Server IP, Server Port, Wifi Access Point for LoPy to connect to the network. | |||
GATEWAY_ID = '11aa334455bb7788' | |||
SERVER = 'ip.address.here' | |||
PORT = 1700 | |||
WIFI_SSID = 'my-wifi' | |||
WIFI_PASS = 'my-wifi-password' | |||
**Note: We can get gateway id by execute these code in LoPy (Referenece [https://www.thethingsnetwork.org/docs/devices/lopy/usage.html TTN]): | |||
from network import LoRa | |||
import binascii | |||
lora = LoRa(mode=LoRa.LORAWAN) | |||
print(binascii.hexlify(lora.mac()).upper().decode('utf-8')) | |||
*Copy the code to the 'flash' folder of LoPy: | |||
Via FTP: | |||
Follow this reference to connect to LoPy via FTP [https://docs.pycom.io/pycom_esp32/pycom_esp32/toolsandfeatures.html?highlight=ftp#pycom-filesystem pycom] | |||
*Reset LoPy | |||
We should be able to see the message from gateway from MQTT server with this topic (Reference [https://docs.loraserver.io/lora-gateway-bridge/topics/ loraserver]): | |||
mosquitto_sub -t "gateway/#" -v | |||
---- | |||
3.Send data from LoPy node: | |||
*Register node in server | |||
**To register node go to server IP address port 8080 (ex: https://localhost:8080) | |||
**Click create application: | |||
***Enter application name and description and click submit | |||
**Click create node: | |||
***Enter node name, description, device EUI and application EUI (Note: application EUI can be any hex number) | |||
***Check ABP node and Submit | |||
**Activate node: | |||
***Click on node name | |||
***Click "(RE)ACTIVATE NODE (ABP)" | |||
***Enter Device Address, Network Session Key, Application Session Key (click generate to generate device address, Network Session Key and Application Session Key can be any hex number) | |||
***Click submit | |||
*Send data from node (LoPy) | |||
**Download [https://github.com/pycom/pycom-libraries/blob/master/examples/lorawan-nano-gateway/abp_node.py this code] | |||
**Change dev_addr, nwk_swkey, app_swkey to match our node when we register our node in web server. | |||
**Rename the code to main.py and copy to "flash" folder of LoPy. | |||
**Reset the LoPy to run the code | |||
*Subscribe to node data from server: | |||
**To read data send from node we need to subscribe to its topic (Reference [https://docs.loraserver.io/lora-app-server/mqtt-topics/ LoRa App Server MQTT]) | |||
mosquitto_sub -t "application/1/#" -v | |||
**Data is in JSON format and encoded with base64 (Reference [https://docs.loraserver.io/lora-app-server/mqtt-topics/ LoRa App Server MQTT]) | |||
== References == | |||
The above guide follow these two main tutorial | |||
[https://github.com/brocaar/loraserver-setup LoRa Server Setup Guide] | |||
[https://forum.pycom.io/topic/810/new-firmware-release-1-6-7-b1-lorawan-nano-gateway-with-ttn-example LoPy as Nano Gateway] | |||
*Note: | |||
1. After setup [https://docs.loraserver.io/loraserver/ LoRa Server] with [https://github.com/brocaar/loraserver-setup LoRa Server Setup Guide] we fail to find application ID to subscript to it MQTT topic to get data from node. | |||
The application id can be seen in browser url when enter application page (Reference [https://docs.loraserver.io/lora-app-server/mqtt-topics/ LoRa App Server MQTT]. | |||
ex: mosquitto_sub -t "application/1/#" -v | |||
mosquitto_sub -t "application/2/#" -v | |||
2. To use 250khz bandwidth: | |||
*In nanogateway.py file: we change every code with 125 to 250 | |||
*In config.py file: we change "SF7BW125" to "SF7BW250" | |||
*In abp node file we change: | |||
lora.add_channel(0, frequency=868100000, dr_min=0, dr_max=5) to lora.add_channel(0, frequency=868100000, dr_min=0, dr_max=6) | |||
lora.add_channel(1, frequency=868100000, dr_min=0, dr_max=5) to lora.add_channel(1, frequency=868100000, dr_min=0, dr_max=6) | |||
lora.add_channel(2, frequency=868100000, dr_min=0, dr_max=5) to lora.add_channel(2, frequency=868100000, dr_min=0, dr_max=6) | |||
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5) to s.setsockopt(socket.SOL_LORA, socket.SO_DR, 6) | |||
== LoPy Nano-gateway and private Lora-server experiments == | == LoPy Nano-gateway and private Lora-server experiments == |
Latest revision as of 14:04, 15 March 2017
Link title
LoPy Nano-gateway and private lora-server installation
In this page we are going to:
1.Install open source private LoRa server (by Orne Brocaar)
2.Setup LoPy as single channel nano gateway
3.Send data from LoPy node
1.Install private LoRa server:
We use LoRa Server Setup Ansible playbook to install all the LoRa server component:
For testing use vagrant to install the server to virtual machine in our local pc (We will update the guide to deploy later):
- Download and install vagrant to your machine vagrant download page
- Install git to your machine
- Clone the LoRa Server Setup repository Reference:
git clone https://github.com/brocaar/loraserver-setup.git
- Go to loraserver-setup folder (In terminal or CMD)
cd loraserver-setup
- Run vagrant up
vagrant up
- The virtual machine will boot and install all the component (This can take a while)
- Note: we can access the server web interface at https://localhost:8080/ (As a self-signed certificate is used, your browser will prompt that the certificate can't be trusted. This is ok for testing)
- We can use our machine IP address and port 1700 for our gateway to forward the package (We do this later in setup LoPy as Nano Gateway below)
2.Setup LoPy as a Single channel nano gateway: (Reference Pycom Forum Github Code
- Update LoPy firmware to 1.6.7.b1 Firmware Upgrade
- Download main.py, config.py, nanogateway.py from Github:
- Edit the config.py file to setup: Gateway ID, Server IP, Server Port, Wifi Access Point for LoPy to connect to the network.
GATEWAY_ID = '11aa334455bb7788' SERVER = 'ip.address.here' PORT = 1700 WIFI_SSID = 'my-wifi' WIFI_PASS = 'my-wifi-password'
- Note: We can get gateway id by execute these code in LoPy (Referenece TTN):
from network import LoRa import binascii lora = LoRa(mode=LoRa.LORAWAN) print(binascii.hexlify(lora.mac()).upper().decode('utf-8'))
- Copy the code to the 'flash' folder of LoPy:
Via FTP: Follow this reference to connect to LoPy via FTP pycom
- Reset LoPy
We should be able to see the message from gateway from MQTT server with this topic (Reference loraserver):
mosquitto_sub -t "gateway/#" -v
3.Send data from LoPy node:
- Register node in server
- To register node go to server IP address port 8080 (ex: https://localhost:8080)
- Click create application:
- Enter application name and description and click submit
- Click create node:
- Enter node name, description, device EUI and application EUI (Note: application EUI can be any hex number)
- Check ABP node and Submit
- Activate node:
- Click on node name
- Click "(RE)ACTIVATE NODE (ABP)"
- Enter Device Address, Network Session Key, Application Session Key (click generate to generate device address, Network Session Key and Application Session Key can be any hex number)
- Click submit
- Send data from node (LoPy)
- Download this code
- Change dev_addr, nwk_swkey, app_swkey to match our node when we register our node in web server.
- Rename the code to main.py and copy to "flash" folder of LoPy.
- Reset the LoPy to run the code
- Subscribe to node data from server:
- To read data send from node we need to subscribe to its topic (Reference LoRa App Server MQTT)
mosquitto_sub -t "application/1/#" -v
- Data is in JSON format and encoded with base64 (Reference LoRa App Server MQTT)
References
The above guide follow these two main tutorial
LoRa Server Setup Guide LoPy as Nano Gateway
- Note:
1. After setup LoRa Server with LoRa Server Setup Guide we fail to find application ID to subscript to it MQTT topic to get data from node. The application id can be seen in browser url when enter application page (Reference LoRa App Server MQTT. ex: mosquitto_sub -t "application/1/#" -v mosquitto_sub -t "application/2/#" -v 2. To use 250khz bandwidth: *In nanogateway.py file: we change every code with 125 to 250 *In config.py file: we change "SF7BW125" to "SF7BW250" *In abp node file we change: lora.add_channel(0, frequency=868100000, dr_min=0, dr_max=5) to lora.add_channel(0, frequency=868100000, dr_min=0, dr_max=6) lora.add_channel(1, frequency=868100000, dr_min=0, dr_max=5) to lora.add_channel(1, frequency=868100000, dr_min=0, dr_max=6) lora.add_channel(2, frequency=868100000, dr_min=0, dr_max=5) to lora.add_channel(2, frequency=868100000, dr_min=0, dr_max=6) s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5) to s.setsockopt(socket.SOL_LORA, socket.SO_DR, 6)