====== LoRa Gateway ======
{{:devices:loragw.png?400|}}
**Features**
* LoRaWAN Concentrator 868MHz ([[https://wireless-solutions.de/products/radiomodules/ic880a.html|iC880A]])
* Ethernet 10/100 ([[https://www.microchip.com/wwwproducts/en/LAN8720A|LAN8720A]])
* 4G LTE modem ([[https://www.telit.com/m2m-iot-products/cellular-modules/standard-industrial-grade/xe910-family|LE910-EUG]]),
* GNSS/GPS ([[https://www.telit.com/m2m-iot-products/positioning-timing-modules/positioning-gnss-sl871-sl871l|SL871]]),
* powered by [[litesom:about|liteSOM]],
* micro SD card socket,
* 12VDC power supply.
===== Schematics =====
{{:devices:loragw_1.3_sch.pdf|Download}}
{{pdfjs 1000px>:devices:loragw_1.3_sch.pdf|LoRa Gateway 1.3}}
===== Production files =====
{{:devices:loragw_1.3_bom.zip|BOM}}
{{:devices:loragw_1.3_gerber_x2.zip|Gerber X2}}
{{:devices:loragw_1.3_gerber_rs-274x.zip|Gerber RS-274X}}
===== Start guide =====
==== Firmware ====
There are two ways to get the firmware:
* download the image,
* build.
=== Image ===
//Available soon.//
=== Build ===
Download and extract the [[https://buildroot.org/|buildroot]] release:
wget https://buildroot.org/downloads/buildroot-2018.08.tar.gz
tar xf buildroot-2018.08.tar.gz
Clone [[https://github.com/grinn-pub/examples|Grinn examples repository]]:
git clone https://github.com/grinn-pub/examples.git
Configure the buildroot:
cd buildroot-2018.08
make BR2_EXTERNAL=/examples grinn_loragw_defconfig
where '''' is path to cloned Grinn examples repository.
Build the firmware:
make all
After successful build microSD card image ''sdcard.img'' can be found in ''output/images/'' directory.
==== Bootable microSD card ====
After getting the firmware, flash a microSD card with ''sdcard.img'' file:
sudo dd if=/sdcard.img of=/dev/ bs=1M
where '''' is path to built or downloaded firmware image and '''' can be ''sdX'' or ''mmcblkX''.
WARNING! This will destroy all contents of device you specify!
==== Board preparation ====
* put flashed microSD card into the socket on the board,
* connect an Ethernet cable and/or put your SIM card into the socket under the LoRa iC880A module,
* connect 868MHz antenna to the u.fl connector on the LoRa module (see [[https://wireless-solutions.de/downloads/Radio-Modules/iC880A/iC880A_Datasheet_V1_0.pdf|datasheet page 7]]),
* connect GSM antenna to ''ANT'' (''J7'') connector (//if you want to use GSM module, optional//),
* connect GPS antenna to ''GPS ANT'' (''J13'') connector under the LoRa module (//if you want to get GPS position of your device, optional//),
* connect 12V power supply to the ''J14'' connector.
==== Terminal connection ====
There are two ways to connect to a gateway:
- Via SSH (if the IP address is known)
- Via USB<->UART converter connected to the ''DBG'' (''J4'') goldpins (baudrate: 115200, 8N1)
Log in as:
user: root
password: root
It's highly recommended to change the password after first log in.
==== Configuration ====
To configure your device it's necessary to edit few files with embedded ''vi'' editor. ([[https://staff.washington.edu/rells/R110/|More about using]]).
=== Gateway EUI ===
In you own your EUI and want to assign it to the gateway follow point 1. If not follow point 2.
**1. Owned EUI**
Log into the gateway and edit the configuration file:
vi /ttn/local_conf.json
Overwrite the ''gateway_ID'' value:
...
"gateway_conf": {
"gateway_ID": "",
/* Devices */
...
Save the file and then run the following command:
sync
**2. Generate EUI**
Log into the gateway and type the following command:
/ttn/update_gwid.sh /ttn/local_conf.json
Response should looks like following:
Gateway_ID set to in file local_conf.json
Then run the following command:
sync
**3. Check EUI**
To see currently set Gateway EUI run the following command:
grep "gateway_ID" /ttn/local_conf.json
To apply changes of gateway settings it's necessary to reset the device by turning off and on power supply or typing the following command:
reboot
=== GSM - APN & PIN ===
//This paragraph consists information how to set up the Internet connection over the GSM module. If you want to use only Ethernet link you don't need to follow this part.//
**1. APN**
Open the ''apn'' file with the ''vi'' editor (type the following command):
vi /etc/ppp/chatscripts/apn
edit the last string (default value is ''internet'') according to the following:
AT+CGDCONT=1,"IP",""
Save the file and then type:
sync
**2. PIN**
//If your SIM card doesn't have a PIN then you don't need to do this step. Otherwise follow the instructions.//
Open the ''pin'' file with the ''vi'' editor (type the following command):
vi /etc/ppp/chatscripts/pin
change the default string:
AT
to the following:
AT+CPIN=
where '''' is your pin e.g. ''1234''.
Then type command:
sync
To apply changes of gateway settings it's necessary to reset the device by turning off and on power supply or typing the following command:
reboot
=== Registration ===
The gateway is configured to work by default with [[https://www.thethingsnetwork.org/|The Things Network]] but it can works with any LoRaWAN network e.g. [[https://www.loriot.io/|LORIOT]] as well.
**The Things Network**
Sign up on [[https://www.thethingsnetwork.org/]] and open [[https://console.thethingsnetwork.org/|console]].
{{ :devices:loragw_ttn_console_1.png?600 |}}
Choose ''Gateways'' and then ''Register gateway''. Check option //I'm using the legacy packet forwarder// and type the gateway EUI which you own or generated in previous step. Choose frequency plan and router according to your region.
{{ :devices:loragw_ttn_console_2.png?600 |}}
Register your gateway and restart it. After few minutes you its status should change to ''connected''.
{{ :devices:loragw_ttn_console_3.png?600 |}}
**Other LoRaWAN network**
To work with other LoRaWAN network it's necessary to adjust the gateway configuration.
Log into the gateway and edit the configuration file:
vi /ttn/local_conf.json
Find section ''servers'' and add new instance or edit existing one. The gateway can forward packets to maximum 4 servers parallelly.
...
/* node servers for poly packet server (max 4) */
"servers":
[ { "server_address": "127.0.0.1",
"serv_port_up": 1680,
"serv_port_down": 1681,
"serv_enabled": false },
{ "server_address": "router.eu.thethings.network",
"serv_port_up": 1700,
"serv_port_down": 1700,
"serv_enabled": true } ],
...
for example:
...
/* node servers for poly packet server (max 4) */
"servers":
[ { "server_address": "eu1.loriot.io",
"serv_port_up": 1780,
"serv_port_down": 1780,
"serv_enabled": true },
{ "server_address": "router.eu.thethings.network",
"serv_port_up": 1700,
"serv_port_down": 1700,
"serv_enabled": true } ],
...
Save file and type the following command:
sync
To apply changes of gateway settings it's necessary to reset the device by turning off and on power supply or typing the following command:
reboot