LoraWan gateway part1 with RAK831 and RPi 3 for AS1/AS2

 I have purchased rak831 from the company few years ago, it was a whole set including Pi3 and a premade SD card.


But it did not work at all. Not enough documentation nor reply from the company, I just put it aside and work on 1ch gateway...



As documentations of TTN is getting better, in terms of HW and frequency plan support, I decided to give it a try...again...

I followed these 2 links, which are very similar..

https://www.hackster.io/naresh-krish/getting-started-with-the-rak831-lora-gateway-and-rpi3-e3351d

https://learn.pi-supply.com/make/getting-started-with-the-rak831-lora-gateway-and-raspberry-pi/

1st. make a fresh sd card connect to wifi, and do the update and up grade of apt-get, install git..

2nd enable the SPI and the serial shell...

3rd install the forwarder from ttn

git clone https://github.com/ttn-zh/ic880a-gateway.git

cd ~/ic880a-gateway

sudo ./install.sh

During the installation, your will see a 8bytes stuff, it's your gateway EUI which you need to use it when register your gateway in TTN, mine is the mac address of my eth0 on Pi

the installation will use EU868 frequency plan. My hardware is 915 version, it could work.

With this RAKboard, the reset pin is connect on pin17 of Pi, but the program come with definition of pin 25 of Pi.

I did not use the remote config.

cd to this dir:

pi@ttn-gateway:~ $ cd /opt/ttn-gateway/bin/

you will see there is global_conf.json , local_conf.json, start.sh and the poly_pkt_fwd

pi@ttn-gateway:/opt/ttn-gateway/bin $ ls

 global_conf.json  poly_pkt_fwd

  local_conf.json   start.sh

Take a look on the start.sh

pi@ttn-gateway:/opt/ttn-gateway/bin $ sudo nano start.sh

I have changed SZ1301_RESET_BCM_PIN to 17


if you change the start.sh, when you reboot RPi, the forwarder will started.
You can check the running service with command ps-A
then you will find the poly_pkt_fwd running.











if you don't modify the start.sh, you will have to do like those 2 links, the do a rak831_reset.sh


#!/bin/bash 
echo "17" > /sys/class/gpio/export 
echo "out" > /sys/class/gpio/gpio17/direction 
echo "1" > /sys/class/gpio/gpio17/value 
sleep 5 
echo "0" > /sys/class/gpio/gpio17/value 
sleep 1 
echo "0" > /sys/class/gpio/gpio17/value 
and you have to run this bash to make forwarder running
sudo bash rak831_reset.sh

Change frequency plan

The default one is the eu868, to change to other frequency plan, for example, AS2 for Taiwan.
I found this post, it's from Thai, same frequency plan as Taiwan.

you will need to change the  global_conf.json in /opt/ttn-gateway/bin 

by one of the conf file, listed in here:

https://github.com/TheThingsNetwork/gateway-conf

and rename the new one as global_conf.json 

I can't send file in to this folder with winSCP due to permission issue. So I do the following:

1.use putty on my PC to log in Pi 

2. rename original global_conf.json to some other name.(I want to keep the old one)

3. sudo nano global_conf.json

4. copy the contain of AS2_global_conf.json in my windows, point to putty window, right click. then every thing will copy into it.

5. Save and reboot...

But it does not work any more. If I execute start.sh , I cames with an error.

Then I found this: an experience for US915

https://www.iotplaybook.com/article/configuring-lorawan-gateway-things-network 

You need to add gps lines in end of the file(the gate_conf section)

{
  "gateway_conf": {
  	...
    "gps": true,
    "gps_tty_path": "/dev/ttyAMA0",
    "fake_gps": false,
  	...
  }
}

Also check the local_config.json file.

Reboot or execute the start.sh, this time forwarder shows up in ps -A command.

Register Gateway(packet forwarder) to TTN

Follow the instruction of TTN: 

https://www.thethingsnetwork.org/docs/gateways/registration.html

Go to your TTN console to register you gateway, first, mark(check)

I'm using the legacy packet forwarder

Select this if you are using the legacy Semtech packet forwarder.

the go back to fill in the 8 bytes gateway EUI you noted when installation.

Then select your frequency plan. AS920-923 is AS1, 923-925 is AS2

handle router should show up once you select your frequency plan.

add geo info and antenna info.

Press the register gateway, few minutes later, you should be able to see your gateway with green light in your console.




Every 30 seconds, my gateway seems to "ring" the TTN router, so you can check the Last Seen to see if your gateway is still alive.



At the end, I put my gateway in frequency plan AS1, Since the most lorawan node lib in arduino does not have AS2, you will need to create one.

So, I use AS1 as testing, it seems fine. I will work out another log for AS2 node li9b.


留言

這個網誌中的熱門文章

Heltec ESP32+OLED+Lora, hardware testing

micro SD card for ESP32, on lolin32 with OLED and heltec 32 lora oled

Install Network Time Protocol(NTP) on BeagleBone with Angstrom linux and set local time zone