LoRaWAN-GW-Schritt-für-Schritt: Unterschied zwischen den Versionen

Aus Opennet
Wechseln zu: Navigation, Suche
(systemd Service konfigurieren)
(systemd Service konfigurieren)
Zeile 172: Zeile 172:
 
  [Install]
 
  [Install]
 
  WantedBy=multi-user.target
 
  WantedBy=multi-user.target
 +
 +
* Script kopieren und aktivieren
 +
 +
sudo cp ttn.service /etc/systemd/system/ttn.service
 +
sudo systemctl deamon-reload
 +
sudo systemctl enable ttn.service
 +
sudo systemctl start ttn.service
 +
sudo systemctl status ttn.service
  
 
== LoRa Netzwerkkonfiguration ==
 
== LoRa Netzwerkkonfiguration ==

Version vom 14. Juni 2021, 10:21 Uhr

Inhaltsverzeichnis

Gateway für The Things Network API V3 einrichten

Raspberry Pi mit IMST IC880A

Hardware zusammenbauen

Pin am IC880A Name Pin am Raspberry
21 VDD 5V 700mA 4 (5V)
22 GND 6 (GND)
13 SPI Reset 22 (GPIO 25)
14 SPI CLK 23 (SPI0_SCLK)
15 MISO 21 (SPI0_MISO)
16 MOSI 19 (SPI0_MOSI)
17 NSS 24 (SPI0_CE0_N)

Raspberry OS runterladen, auspacken und auf SD Karte kopieren. SSH Zugang einrichten.

Raspberry booten, Internet einrichten, Update

  • DHCP beim ersten Booten
  • ssh pi@rasberrypi.local (oder wo immer der ist), Passwort "raspberry"
  • sudo -i
  • DNS prüfen, Routing prüfen
  • apt update
  • apt upgrade
  • reboot

SPI aktivieren

  • ssh pi@...
  • sudo raspi-config
  • 3 Interface Options
  • P4 SPI enable
  • /dev/spidev0.0 sollte jetzt vorhanden sein

Basic Station auf Zielplattform selbst laden und bauen

cd ~
sudo apt install git
git clone https://github.com/lorabasics/basicstation.git
cd basicstation
make platform=rpi variant=std

Konfiguration für TTN

cd ~
mkdir TTN
cd TTN
echo "wss://eu1.cloud.thethings.network:8887" > tc.uri
curl https://letsencrypt.org/certs/isrgrootx1.pem.txt -o tc.trust
nano station.conf
  • Datei station.conf anlegen und folgendes eintragen:
{
   "radio_conf": {                  /* Actual channel plan is controlled by the server */
       "lorawan_public": true,      /* is default */
       "clksrc": 1,                 /* radio_1 provides clock to concentrator */
       "device": "/dev/spidev0.0",  /* default SPI device is platform specific */
       "pps": true,
       "radio_0": {
           /* freq/enable provided by LNS - only hardware-specific settings are listed here */
           "type": "SX1257",
           "rssi_offset": -166.0,
           "tx_enable": true
       },
       "radio_1": {
           "type": "SX1257",
           "rssi_offset": -166.0,
           "tx_enable": false
       }
       /* chan_multiSF_X, chan_Lora_std, chan_FSK provided by LNS */
   },
   "station_conf": {
     "log_file":    "stderr",
     "log_level":   "DEBUG",
     "log_size":    10e6,
     "log_rotate":  3
   }
}
  • Reset konfigurieren
sudo apt install gpiod
touch reset_gw.sh
chmod 755 reset_gw.sh
nano reset_gw.sh
  • In Datei reset_gw.sh folgendes eingeben:
#!/bin/sh
gpioset --mode=time --usec=500 pinctrl-bcm2835 25=1
gpioset --mode=time --usec=500 pinctrl-bcm2835 25=0

Gateway bei TTN registrieren

  • Erster Start - noch nicht registriert
~/basicstation/build-rpi-std/bin/station --radio-init=./reset_gw.sh
  • EUI kopieren
  • Gateway bei TTN registrieren
  • Einen App Key erzeugen. Recht sollte "Link to a Gateway Server for traffic exchange ..." sein.
  • App Key kopieren
cd ~
export LNS_KEY="xxxx"
echo "Authorization: Bearer $LNS_KEY" | perl -p -e 's/\r\n|\n|\r/\r\n/g' > tc.key
/home/pi/basicstation/build-rpi-std/bin/station --radio-init=/home/pi/TTN/reset_gw.sh

systemd Service konfigurieren

cd ~/TTN
touch startgw.sh
chmod 755 startgw.sh
nano startgw.sh
  • In startgw.sh folgendes eintragen:
#!/bin/bash
cd /home/pi/TTN
/home/pi/basicstation/build-rpi-std/bin/station --radio-init=/home/pi/TTN/reset_gw.sh
  • Script anlegen
cd ~/TTN
nano ttn.service
  • Folgendes eintragen:
[Unit]
Description=TTN Gateway Service
After=network.target
[Service]
ExecStart=/home/pi/TTN/startgw.sh
WorkingDirectory=/home/pi/TTN
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
[Install]
WantedBy=multi-user.target
  • Script kopieren und aktivieren
sudo cp ttn.service /etc/systemd/system/ttn.service
sudo systemctl deamon-reload
sudo systemctl enable ttn.service
sudo systemctl start ttn.service
sudo systemctl status ttn.service

LoRa Netzwerkkonfiguration

Folgenden Schritte haben wir unternommen damit alles funktionierte:

Geräte:

  • Netzwerkkonfiguration in /etc/network/interfaces
 # Ethernet
 auto eth0
 allow-hotplug eth0
 iface eth0 inet static
 address 192.168.5.30
 netmask 255.255.0.0
 gateway 192.168.11.52
 # add nameserver routes
 dns-nameservers 192.168.0.246 192.168.0.247 192.168.0.248
 up ip route add 192.168.0.246 dev eth0 via 192.168.11.52
 down ip route del 192.168.0.246 dev eth0 via 192.168.11.52
 up ip route add 192.168.0.247 dev eth0 via 192.168.11.52
 down ip route del 192.168.0.247 dev eth0 via 192.168.11.52
 up ip route add 192.168.0.248 dev eth0 via 192.168.11.52
 down ip route del 192.168.0.248 dev eth0 via 192.168.11.52
  • Konfiguration des TTN Gateways (unter anderem, welcher TTN Server genutzt werden soll)
 /opt/ttn-gateway/global_conf.json
  • Status des Gateway abfragen:
 service ttn-gateway status
Meine Werkzeuge
Namensräume

Varianten
Aktionen
Start
Opennet
Kommunikation
Karten
Werkzeuge