In this guide, I'll explain how to build easily a full channel LoRa gateway with the n-fuse mPCIe Card and an Orange Pi in my case. You could also use a Raspberry Pi if you like. There is no soldering required! You only need a bit of patience for all the parts to arrive from China...
Make sure you already have an OS installed. There are many guides for the Orange Pi or Raspberry Pi so I won't cover this part in my guide. I installed Armbian on my Pi.
You'll also need git and I useded the nano editor for this guide ( its normally already installed at Debian or Ubuntu dtributitions )
To install git simply type:
sudo apt-get update
sudo apt-get install git
Step 1: <Download & compile sources>Go to your home directory with following command. In my case it's /home/fewi
cd ~
Let's create a new folder and clone the repo
mkdir loragateway
cd loragateway
git clone https://github.com/Lora-net/picoGW_packet_forwarder.git
git clone https://github.com/Lora-net/picoGW_hal.git
Now it's time to compile the sources
cd picoGW_hal
make clean all
cd ..
cd picoGW_packet_forwarder
make clean all
Step 2: <Prepare the hardware>It's a really easy step because you don't need to solder anything. Just stick all together and plug it in. But attention! Don't plug the the mPCIe card into your Pi without an antenna. It could damage your LoRa conentrator module.
Make sure you plugged the module into a free USB port and now it's time to obtain a unique id for your gateway. Go to your picoGW_hal directory and execute util_chip_id.
cd picoGW_hal/
./util_chip_id/util_chip_id
3236313711005200
If everything goes well, you'll see some numbers and letters. Otherwise you should check your connection of the module or stop the execution with CTRL + C and execute it again.
Now if you obtained the unique string we can edit the global configuration file of the packet forwarder.
Therefore, jump in the picoGW_packet_forwarder/lora_pkt_fwd directory, open the global_conf.json file, go to the bottom and change the gateway_id to the string from the earlier step and also change the server_addres, serv_port_up and serv_port_down to TTN
cd ..
cd picoGW_packet_forwarder/lora_pkt_fwd/
nano global_conf.json
"gateway_conf": {
"gateway_ID": "3236313711005200", <--- change this
/* change with default server address/ports, or overwrite in local_conf.json */
"server_address": "router.eu.thethings.network", <---- change this
"serv_port_up": 1700, <---- change this
"serv_port_down": 1700, <---- change this
/* adjust the following parameters for your network */
"keepalive_interval": 10,
"stat_interval": 30,
"push_timeout_ms": 100,
/* forward only valid packets */
"forward_crc_valid": true,
"forward_crc_error": false,
"forward_crc_disabled": false
}
Finally save your file with CTRL + o and exit with CTRL + x
Step 4: <Register your new gateway at TTN>Go to https://console.thethingsnetwork.org/ and log in or register a new account.
Navigate to Gateways and click "register gateway"
Fill in your gateway EUI. This is the gateway_id you already configured in your global_conf.json, select that you are using the legacy packet forwarder, choose a gateway description, select your location of the gateway, choose the antenna placement and click the "Register Gateway" button.
Make sure you are in the lora_pkt_fwd folder. Then simply start the forwarder by typing ./lora_pkt_fwd
and follow the magic it outputs.
./lora_pkt_fwd
*** Packet Forwarder for Lora PicoCell Gateway ***
Version: 0.1.0
*** Lora concentrator HAL library version info ***
Version: 0.2.2;
*** MCU FW version for LoRa PicoCell Gateway ***
Version: 0x010A0006
***
INFO: Little endian host
INFO: found global configuration file global_conf.json, parsing it
INFO: global_conf.json does contain a JSON object named SX1301_conf, parsing SX1301 parameters
INFO: lorawan_public 1, clksrc 1
INFO: antenna_gain 0 dBi
INFO: Configuring TX LUT with 16 indexes
INFO: radio 0 enabled (type SX1257), center frequency 867500000, RSSI offset -164.000000, tx enabled 1
INFO: radio 1 enabled (type SX1257), center frequency 868500000, RSSI offset -164.000000, tx enabled 0
INFO: Lora multi-SF channel 0> radio 1, IF -400000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 1> radio 1, IF -200000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 2> radio 1, IF 0 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 3> radio 0, IF -400000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 4> radio 0, IF -200000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 5> radio 0, IF 0 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 6> radio 0, IF 200000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 7> radio 0, IF 400000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora std channel> radio 1, IF -200000 Hz, 250000 Hz bw, SF 7
INFO: FSK channel> radio 1, IF 300000 Hz, 125000 Hz bw, 50000 bps datarate
INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to 3236313711005200
INFO: server hostname or IP address is configured to "router.eu.thethings.network"
INFO: upstream port is configured to "1700"
INFO: downstream port is configured to "1700"
INFO: downstream keep-alive interval is configured to 10 seconds
INFO: statistics display interval is configured to 30 seconds
INFO: upstream PUSH_DATA time-out is configured to 100 ms
INFO: packets received with a valid CRC will be forwarded
INFO: packets received with a CRC error will NOT be forwarded
INFO: packets received with no CRC will NOT be forwarded
INFO: [main] concentrator started, packet can now be received
INFO: host/sx1301 time offset=(1535651231s:812932µs) - drift=1535651231812932µs
Gratulation your packet forwarder is running, and you should be able to receive LoRa messages. You should also see your gateway status as connected in the TTN console
If you already have LoRa nodes sending packets you should see them in the TTN console
If you reboot your gateway, you'll probably also start the packet forwarder automatically. Therefore, we need to configure a linux service.
Create a file with sudo
sudo nano /lib/systemd/system/pkt_fwd.service
Copy following code into the file. Modify the WorkingDirectory and ExecStart path for your environment and save with CTRL + o and exit with CTRL + x.
[Unit]
Description=Semtech packet-forwarder
[Service]
WorkingDirectory=/home/fewi/loragateway/picoGW_packet_forwarder/lora_pkt_fwd
ExecStart=/home/fewi/loragateway/picoGW_packet_forwarder/lora_pkt_fwd/lora_pkt_fwd
Restart=on-failure
RestartSec=30
[Install]
WantedBy=multi-user.target
Now we can enanble and start the service
systemctl daemon-reload
systemctl enable pkt_fwd.service
systemctl start pkt_fwd.service
Check with following command if your service is running
systemctl status pkt_fwd.service
Test it by rebooting your Pi and check the status again. If you have problems, look at the Troubleshooting section.
You can also follow logs of the packet forwarder since the last reboot by following command
journalctl -u pkt_fwd.service -b -f
Step 7: <Put everything together>Now your prototype is finished and it's time to put everything in a case to protect the hardware. The case depends on your usage. If want to put it outside it should be waterproof. There are endless possibilities for your case. I bought mine at the local tool store. It's dust and splash water proof.
Final pictures of the gateway1. The sofware won't connect to the gateway at first time ( Orange Pi )
-- Update August 2019 --
Semtech released a new firmware and fixed the bug in Version 0.2.1
You can get the new firmware here: https://www.n-fuse.co/products/lrwccx/lrwccx-mpcie-usb-fw-v0.2.1.dfu
Instructions for flashing the binary can be found here:
https://github.com/Lora-net/picoGW_mcu#2-precompiled-binaries
-- Update end --
I had the problem after a reboot that my paketforwarder won't start at the first time. Therefore, I use a little workaround and start the packet forwarder twice.
Simply got to your picoGW_packet_forwarder/lora_pkt_fwd/
directory and create a new file start.sh
nano start.sh
Copy follwoing code in the file
timeout 10 ./lora_pkt_fwd
sleep 5
./lora_pkt_fwd
And save with CTRL + o and exit with CTRL + x
Now we need to make it executable
chmod +x start.sh
You can test the script by typing ./start.sh
It will start the packetforwarder and after 10 seconds it will start it again.
./start.sh
Now you need to modify your service
sudo nano /lib/systemd/system/pkt_fwd.service
Change ExecStart
at the end to start.sh
ExecStart=/home/fewi/loragateway/picoGW_packet_forwarder/lora_pkt_fwd/start.sh
Save and exit. Now reboot your Pi and check after some time if the gateway is connected in the TTN console.
Comments