{"id":1392,"date":"2022-04-05T19:31:00","date_gmt":"2022-04-05T19:31:00","guid":{"rendered":"http:\/\/lora.vsb.cz\/?page_id=1392"},"modified":"2023-10-13T09:49:56","modified_gmt":"2023-10-13T09:49:56","slug":"building-lora-basic-station-lbs-with-rpi-ic880a-for-the-things-network-v3-stack","status":"publish","type":"page","link":"https:\/\/lora.vsb.cz\/index.php\/building-lora-basic-station-lbs-with-rpi-ic880a-for-the-things-network-v3-stack\/","title":{"rendered":"868 MHz iC880a &#8211; LoRa Basics Station without Docker"},"content":{"rendered":"<table style=\"height: 66px;\" width=\"356\">\n<tbody>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>TTN version:<\/strong><\/td>\n<td><strong><span style=\"color: #008000;\">TTNv3<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>Frequency:<\/strong><\/td>\n<td>Europe 863-870 MHz (SF9 for RX2 &#8211; recommended)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>Using Docker:<\/strong><\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>Last updated:<\/strong><\/td>\n<td>October 13, 2023<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Used HW: <strong>Raspberry-Pi (version 2, 3 or 4) &amp; <a href=\"https:\/\/wireless-solutions.de\/products\/radiomodules\/ic880a.html\" target=\"_blank\" rel=\"noopener\">iC880a SPI<\/a><\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-306 alignnone\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2017\/12\/Raspberry-Pi-Model-B-462x322.jpg\" alt=\"\" width=\"159\" height=\"113\" \/><a href=\"https:\/\/wireless-solutions.de\/products\/radiomodules\/ic880a.html\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-307 alignnone\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2017\/12\/ic880a-spi.jpg\" alt=\"\" width=\"165\" height=\"129\" \/><\/a><\/p>\n<h4 class=\"comments-section\"><span style=\"color: #800000;\"><strong>Step 1: <\/strong>Install latest <a style=\"color: #800000;\" href=\"https:\/\/www.raspberrypi.com\/software\/operating-systems\/\" target=\"_blank\" rel=\"noopener\">Raspberry Pi OS<\/a> (choose &#8222;lite&#8220; version).<\/span><\/h4>\n<h4 class=\"comments-section\"><strong><span style=\"color: #800000;\">Step 2: Customise OS<\/span><br \/>\n<\/strong><\/h4>\n<p class=\"comments-section\">Run RPI, login as default user &#8222;pi&#8220; (default passwd &#8222;raspberry&#8220;) and customise OS:<\/p>\n<h5><span style=\"color: #800000;\"><strong>Step 2.1:<\/strong> update OS:<\/span><\/h5>\n<pre># rpi-update\r\n# apt dist-upgrade\r\n# apt update\r\n# rpi-update<\/pre>\n<h5><span style=\"color: #800000;\"><strong>Step 2.2: delete default user PI:<\/strong><\/span><\/h5>\n<pre># adduser &lt;new-user&gt;\r\n# deluser pi<\/pre>\n<h5><span style=\"color: #800000;\"><strong>Step 2.3:<\/strong> <strong>install Persistent IPtables:<\/strong><\/span><\/h5>\n<pre># apt-get install iptables-persistent\r\n# vi \/etc\/iptables\/rules.v4\r\n<\/pre>\n<p>This is an example of file rules.v4:<\/p>\n<pre><em>*filter \r\n:INPUT DROP [0:0] \r\n:FORWARD ACCEPT [0:0] \r\n:OUTPUT ACCEPT [0:0] \r\n-A INPUT -i lo -j ACCEPT \r\n-A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT \r\n-A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED \r\nCOMMIT\r\n<\/em><\/pre>\n<h5><span style=\"color: #800000;\"><em><strong>Step 2.4:<\/strong> <\/em><strong>set NTP time: <\/strong><\/span><\/h5>\n<ol>\n<li>Go to <a href=\"http:\/\/support.ntp.org\/bin\/view\/Servers\/NTPPoolServers\" target=\"_blank\" rel=\"noopener\">http:\/\/support.ntp.org\/bin\/view\/Servers\/NTPPoolServers<\/a> and click the host name corresponding to your area. Assuming the area is North America, the servers are:\n<div>\n<pre>  server 0.north-america.pool.ntp.org\r\n  server 1.north-america.pool.ntp.org\r\n  server 2.north-america.pool.ntp.org\r\n  server 3.north-america.pool.ntp.org\r\n<\/pre>\n<\/div>\n<\/li>\n<li>Open \/etc\/ntp.conf in a text editor. If you use the nano editor, run sudo nano \/etc\/ntp.conf<\/li>\n<li>You should see a list of servers similar to the one below, replace the servers with the ones from step 1::\n<div>\n<pre> server 0.cz.pool.ntp.org iburst\r\n server 1.cz.pool.ntp.org iburst\r\n server 2.cz.pool.ntp.org iburst\r\n server 3.cz.pool.ntp.org iburst\r\n<\/pre>\n<\/div>\n<\/li>\n<li>Comment out (by adding a # in front of the line) the following two lines:\n<div>\n<pre>  restrict 127.0.0.1\r\n  restrict ::1\r\n<\/pre>\n<\/div>\n<\/li>\n<li>Save the file and exit<\/li>\n<li>Set the correct time zone by running # sudo cp \/usr\/share\/zoneinfo\/US\/Pacific \/etc\/localtime. Replace US\/Pacific with your time zone. If you are not sure about the possible values, look in \/usr\/share\/zoneinfo<\/li>\n<li>Restart the ntp server: sudo \/etc\/init.d\/ntp restart<\/li>\n<li>Run <code class=\"highlighter-rouge\">date<\/code> in a terminal<\/li>\n<li>If the time is not correct, you might have to force update it. This is because, by default, <code class=\"highlighter-rouge\">ntp<\/code> will not sync if the difference between the system time and the real-time is greater that 1000 seconds. Run <code class=\"highlighter-rouge\">sudo ntpd -gq<\/code> and the restart <code class=\"highlighter-rouge\">ntp<\/code><\/li>\n<\/ol>\n<h5><strong> Step 2.5: turn off wifi (if you use RPI3 (and later) and if don&#8217;t need it):<\/strong><\/h5>\n<pre># iwconfig wlan0 txpower off (if needed tun on: # iwconfig wlan0 txpower auto)<\/pre>\n<p>check status:<\/p>\n<pre># rfkill list all<\/pre>\n<h4><span style=\"color: #800000;\"><strong>Step 3: Putting it all together <\/strong><\/span><\/h4>\n<p>Connect the jumper wires between the two boards using the following table:<\/p>\n<table style=\"border-collapse: collapse; border-spacing: 0px; border-color: #999999; width: 40%;\">\n<tbody>\n<tr>\n<th style=\"font-family: Arial, sans-serif; font-size: 14px; font-weight: bold; padding: 0px 3px; overflow: hidden; word-break: normal; color: #ffffff; background-color: #34cdf9; vertical-align: top; border: 1px solid #999999; text-align: center;\">iC880 pin<\/th>\n<th style=\"font-family: Arial, sans-serif; font-size: 14px; font-weight: bold; padding: 0px 3px; overflow: hidden; word-break: normal; color: #ffffff; background-color: #34cdf9; vertical-align: top; border: 1px solid #999999; text-align: center;\">Description<\/th>\n<th style=\"font-family: Arial, sans-serif; font-size: 14px; font-weight: bold; padding: 0px 3px; overflow: hidden; word-break: normal; color: #ffffff; background-color: #34cdf9; vertical-align: top; border: 1px solid #999999; text-align: center;\">RPi pin<\/th>\n<\/tr>\n<tr>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">21<\/td>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">+5V<\/td>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">2 (4)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">22<\/td>\n<td style=\"font-family: Arial,sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; text-align: center; vertical-align: top; border: 1px solid #999999;\">GND<\/td>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">6 (14, 25)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">13<\/td>\n<td style=\"font-family: Arial,sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; text-align: center; vertical-align: top; border: 1px solid #999999;\">Reset<\/td>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">11 (GPIO17)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">14<\/td>\n<td style=\"font-family: Arial,sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; text-align: center; vertical-align: top; border: 1px solid #999999;\">SPI CLK<\/td>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">23 (GPIO11)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">15<\/td>\n<td style=\"font-family: Arial,sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; text-align: center; vertical-align: top; border: 1px solid #999999;\">MISO<\/td>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">21 (GPIO09)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">16<\/td>\n<td style=\"font-family: Arial,sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; text-align: center; vertical-align: top; border: 1px solid #999999;\">MOSI<\/td>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">19 (GPIO10)<\/td>\n<\/tr>\n<tr>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">17<\/td>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">NSS<\/td>\n<td style=\"font-family: Arial, sans-serif; font-size: 14px; padding: 0px 3px; overflow: hidden; word-break: normal; color: #444444; background-color: #efefef; vertical-align: top; border: 1px solid #999999; text-align: center;\">24 (GPIO08)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>We&#8217;re now ready to power up and start configuring our gateway!<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-255 alignnone\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2017\/12\/web-1-300x180.jpg\" alt=\"\" width=\"425\" height=\"255\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2017\/12\/web-1-300x180.jpg 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2017\/12\/web-1-768x461.jpg 768w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2017\/12\/web-1-1024x615.jpg 1024w\" sizes=\"auto, (max-width: 425px) 100vw, 425px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"wp-image-413 alignnone\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2018\/01\/gw-1-300x200.jpg\" alt=\"\" width=\"383\" height=\"255\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2018\/01\/gw-1-300x200.jpg 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2018\/01\/gw-1-768x512.jpg 768w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2018\/01\/gw-1-1024x683.jpg 1024w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2018\/01\/gw-1-272x182.jpg 272w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2018\/01\/gw-1.jpg 1300w\" sizes=\"auto, (max-width: 383px) 100vw, 383px\" \/><\/p>\n<p>If you have a 3D printer, you can use a holder to mount both boards together. <a href=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2018\/01\/RPI-iC880-holder.zip\">Download<\/a> all <em>*.stl<\/em> and <em>*.gcode<\/em> files.<\/p>\n<h4><span style=\"color: #800000;\"><strong>Step 4: <\/strong>Setting up the Lora Basic Station software<\/span><\/h4>\n<ul>\n<li>Use <code>raspi-config<\/code> utility to <strong>enable SPI<\/strong> ([3] Interfacing options -&gt; P4 SPI \u2013 <em>automatic loading of the SPI kernel module<\/em>) and also expand the filesystem ([7] Advanced options -&gt; A1 Expand filesystem). If you use the GPS module\u2019s TX and RX lines connected to the serial port (the serial port is normally enabled as a console) Disable (P6) <em>shell messages on the serial connection <\/em>and leave the serial port hardware enabled.<\/li>\n<li>Reboot (it will ask on exit, but you can do it manually with <code>sudo reboot<\/code>)<\/li>\n<li>Configure locales and time zone:\n<pre>$ sudo dpkg-reconfigure locales\r\n$ sudo dpkg-reconfigure tzdata\r\n<\/pre>\n<\/li>\n<li>Make sure you have an updated installation and install <code>git<\/code>:\n<pre>$ sudo apt-get install git<\/pre>\n<\/li>\n<li>If PRI3 or 4: Configure the wifi credentials (check <a href=\"https:\/\/www.raspberrypi.org\/documentation\/configuration\/wireless\/wireless-cli.md\">here for additional details<\/a>)\n<pre># nano \/etc\/wpa_supplicant\/wpa_supplicant.conf<\/pre>\n<\/li>\n<\/ul>\n<p>And add the following block at the end of the file, replacing SSID and password to match your network:<\/p>\n<pre>\tnetwork={\r\n\t    ssid=\"The_SSID_of_your_wifi\"\r\n\t    psk=\"Your_wifi_password\"\r\n\t}\r\n<\/pre>\n<ul>\n<li><strong>Clone <\/strong><a href=\"https:\/\/github.com\/lorabasics\/basicstation\">the installer<\/a> and start the installation\n<pre>$ mkdir \/opt\/ttn-station\r\n$ cd \/opt\/ttn-station\r\n$ git clone https:\/\/github.com\/lorabasics\/basicstation.git\r\n$ cd basicstation\r\n$ make platform=rpi variant=std<\/pre>\n<\/li>\n<li><strong>Configuration<\/strong><br \/>\nCreate a file called <em>tc.uri<\/em> and fill it with the server name. Packet transport with the The Things Network V3 LNS goes on port 8887. Currently the following LNS exist:<\/p>\n<ul>\n<li>Europe 1: eu1.cloud.thethings.network<\/li>\n<li>North America 1: nam1.cloud.thethings.network<\/li>\n<li>Australia 1: au1.cloud.thethings.network<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre>$ cd \/opt\/ttn-station\r\n$ nano tc.uri\r\n<\/pre>\n<pre style=\"padding-left: 40px;\">and for EU place:\r\nwss:\/\/eu1.cloud.thethings.network:8887<\/pre>\n<p>Next we need to establish a secure connection. This involves copying the root certificate (expires Jun 2035) to a file called <em>tc.trust<\/em>.<\/p>\n<pre style=\"padding-left: 40px;\">$ nano tc.trust\r\n$ curl <a href=\"https:\/\/letsencrypt.org\/certs\/isrgrootx1.pem.txt\">https:\/\/letsencrypt.org\/certs\/isrgrootx1.pem.txt<\/a> -k -o tc.trust<\/pre>\n<p style=\"padding-left: 40px;\">Make a station configuration file:<\/p>\n<pre style=\"padding-left: 40px;\">$ nano station.conf<\/pre>\n<p style=\"padding-left: 40px;\">and fill it with:<\/p>\n<pre><i>{<\/i>\r\n\r\n<i>\u00a0\u00a0 \"radio_conf\": {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/* Actual channel plan is controlled by the server *\/<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"lorawan_public\": true,\u00a0\u00a0\u00a0\u00a0\u00a0 \/* is default *\/<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"clksrc\": 1,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/* radio_1 provides clock to concentrator *\/<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"device\": \"\/dev\/spidev0.0\",\u00a0 \/* default SPI device is platform specific *\/<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"pps\": true,<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"radio_0\": {<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/* freq\/enable provided by LNS - only hardware-specific settings are listed here *\/<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"type\": \"SX1257\",<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"rssi_offset\": -166.0,<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"tx_enable\": true<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 },<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"radio_1\": {<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"type\": \"SX1257\",<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"rssi_offset\": -166.0,<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"tx_enable\": false<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/* chan_multiSF_X, chan_Lora_std, chan_FSK provided by LNS *\/<\/i>\r\n<i>\u00a0\u00a0 },<\/i>\r\n<i>\u00a0\u00a0 \"station_conf\": {<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0 \"log_file\":\u00a0\u00a0\u00a0 \"stderr\",<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0 \"log_level\":\u00a0\u00a0 \"DEBUG\",<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0 \"log_size\":\u00a0\u00a0\u00a0 10e6,<\/i>\r\n<i>\u00a0\u00a0\u00a0\u00a0 \"log_rotate\":\u00a0 3<\/i>\r\n<i>\u00a0\u00a0 }<\/i>\r\n<i>}<\/i><\/pre>\n<ul>\n<li><strong>Reset<\/strong><i><br \/>\n<\/i><\/li>\n<\/ul>\n<p>The SX1301 chip has to be reset after power-up. However, this initial reset of the SX1301 is not performed by LBS. We have to do this externally and use <em>gpioset<\/em> that comes with the <em>gpiod*<\/em>. We have connected an iC880 reset pin (13) to GPIO17 of the R-Pi.<\/p>\n<p>Install the gpiod package:<\/p>\n<div class=\"enlighter-default enlighter-v-standard enlighter-t-enlighter enlighter-hover enlighter-linenumbers enlighter-overflow-scroll \">\n<div class=\"enlighter\">\n<div class=\"\">\n<pre><span class=\"enlighter-text\">$ apt install gpiod<\/span>\r\n$ nano reset_gw.sh<\/pre>\n<\/div>\n<\/div>\n<div>\n<pre>#!\/bin\/sh\r\n#gpioset --mode=time --usec=500 pinctrl-bcm2835 17=1\r\n#gpioset --mode=time --usec=500 pinctrl-bcm2835 17=0<\/pre>\n<\/div>\n<\/div>\n<p>*in legacy OS (e.g. Jessie) may not <span class=\"enlighter-text\">gpiod<\/span> available. Use old way work with GPIO:<\/p>\n<pre>SX1301_RESET_BCM_PIN=17\r\necho \"$SX1301_RESET_BCM_PIN\"\u00a0 &gt; \/sys\/class\/gpio\/export\r\necho \"out\" &gt; \/sys\/class\/gpio\/gpio$SX1301_RESET_BCM_PIN\/direction\r\necho \"0\"\u00a0\u00a0 &gt; \/sys\/class\/gpio\/gpio$SX1301_RESET_BCM_PIN\/value\r\nsleep 0.1\r\necho \"1\"\u00a0\u00a0 &gt; \/sys\/class\/gpio\/gpio$SX1301_RESET_BCM_PIN\/value\r\nsleep 0.1\r\necho \"0\"\u00a0\u00a0 &gt; \/sys\/class\/gpio\/gpio$SX1301_RESET_BCM_PIN\/value\r\nsleep 0.1\r\necho \"$SX1301_RESET_BCM_PIN\"\u00a0 &gt; \/sys\/class\/gpio\/unexport<\/pre>\n<p>And make the script an executable:<\/p>\n<pre>$ chmod 755 reset_gw.sh\r\n\r\n<\/pre>\n<h4><span style=\"color: #800000;\"><strong>Step 5:\u00a0<\/strong>Registering the Gateway on The Things Network<\/span><\/h4>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1401 alignnone\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/tts.png\" alt=\"\" width=\"268\" height=\"59\" \/><\/p>\n<p><strong>First run<\/strong><\/p>\n<pre>$ \/opt\/ttn-station\/basicstation\/build-rpi-std\/bin\/station --radio-init=\/opt\/ttn-station\/reset_gw.sh<\/pre>\n<p>The gateway\/station\u2019s EUI is made up from the Raspberry Pi\u2019s MAC address and should be shown in the first couple of lines of output when the station starts \u2013 for example:<\/p>\n<p><em><span class=\"enlighter-g1\">[<\/span><span class=\"enlighter-text\">SYS:INFO<\/span><span class=\"enlighter-g1\">]<\/span><span class=\"enlighter-text\"> proto EUI <\/span><span class=\"enlighter-g0\">:<\/span> <span class=\"enlighter-n1\">0<\/span><span class=\"enlighter-text\">:b827:ebxxxxxxx<\/span><\/em><\/p>\n<p>Log into the <a href=\"https:\/\/console.cloud.thethings.network\/\" target=\"_blank\" rel=\"noopener\" data-type=\"URL\" data-id=\"https:\/\/console.cloud.thethings.network\/\">console of the cluster<\/a> you intend to register with and click \u201c<em>Go to gateways<\/em>\u201c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-897\" src=\"https:\/\/www.beyondlogic.org\/wp-content\/uploads\/2021\/02\/TheThingsNetwork_V3_goto_gateways.png\" sizes=\"auto, (max-width: 454px) 100vw, 454px\" srcset=\"https:\/\/www.beyondlogic.org\/wp-content\/uploads\/2021\/02\/TheThingsNetwork_V3_goto_gateways.png 454w, https:\/\/www.beyondlogic.org\/wp-content\/uploads\/2021\/02\/TheThingsNetwork_V3_goto_gateways-300x283.png 300w\" alt=\"\" width=\"124\" height=\"117\" \/><\/p>\n<p>Then click <em>Add Gateway<\/em>. The following dialog should appear:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1396 alignnone\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/gw-reg.png\" alt=\"\" width=\"552\" height=\"1043\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/gw-reg.png 552w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/gw-reg-159x300.png 159w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/gw-reg-542x1024.png 542w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/p>\n<p id=\"api-key\">You need to add an API key to authorise your gateway:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1402 alignnone\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/key-1.png\" alt=\"\" width=\"934\" height=\"102\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/key-1.png 1181w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/key-1-300x33.png 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/key-1-1024x112.png 1024w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/key-1-768x84.png 768w\" sizes=\"auto, (max-width: 934px) 100vw, 934px\" \/><\/p>\n<p>Give your API key a name and change the rights to grant individual rights to \u201c<em>link as Gateway to a Gateway Server for traffic exchange, i.e. write uplink and read downlink<\/em>\u201d as per the example below. Then click Create API key to create it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-899\" src=\"https:\/\/www.beyondlogic.org\/wp-content\/uploads\/2021\/02\/TheThingsNetwork_v3_AddGwAPIkey.png\" sizes=\"auto, (max-width: 641px) 100vw, 641px\" srcset=\"https:\/\/www.beyondlogic.org\/wp-content\/uploads\/2021\/02\/TheThingsNetwork_v3_AddGwAPIkey.png 641w, https:\/\/www.beyondlogic.org\/wp-content\/uploads\/2021\/02\/TheThingsNetwork_v3_AddGwAPIkey-254x300.png 254w\" alt=\"\" width=\"355\" height=\"419\" \/><\/p>\n<p>Now you will be given a one time opportunity to copy the key. Click the copy button (highlighted below by the red box) and \u2026<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-900\" src=\"https:\/\/www.beyondlogic.org\/wp-content\/uploads\/2021\/02\/TheThingsNetwork_v3_CopyAPIKey.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/www.beyondlogic.org\/wp-content\/uploads\/2021\/02\/TheThingsNetwork_v3_CopyAPIKey.png 800w, https:\/\/www.beyondlogic.org\/wp-content\/uploads\/2021\/02\/TheThingsNetwork_v3_CopyAPIKey-300x203.png 300w, https:\/\/www.beyondlogic.org\/wp-content\/uploads\/2021\/02\/TheThingsNetwork_v3_CopyAPIKey-768x519.png 768w\" alt=\"\" width=\"404\" height=\"273\" \/><\/p>\n<pre style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">$ export LNS_KEY=\"&lt;API-KEY&gt;\"\r\n$ echo \"Authorization: Bearer $LNS_KEY\" | perl -p -e 's\/\\r\\n|\\n|\\r\/\\r\\n\/g' &gt; tc.key<\/pre>\n<p>Now start\/restart station and your gateway should successfully register.\u00a0 Make a simple bash script to run LBN:<\/p>\n<pre>$ nano start.sh\r\n<i>\/opt\/ttn-station\/basicstation\/build-rpi-std\/bin\/station --radio-init=\/opt\/ttn-station\/reset_gw.sh --home=\/opt\/ttn-station --log-file=station.log\u00a0 --daemon<\/i>\r\n$ chmod +x start.sh\r\n$ \/opt\/ttn-station\/start.sh<\/pre>\n<h5>Starting at boot<\/h5>\n<pre>$ nano \/etc\/systemd\/system\/ttn-station.service\r\n\r\n<span style=\"font-style: italic;\">[Unit]<\/span>\r\n<span style=\"font-style: italic;\">Description=The Things Network Station<\/span>\r\n<span style=\"font-style: italic;\">\r\n[Service]<\/span>\r\n<span style=\"font-style: italic;\">Type=simple<\/span>\r\n<span style=\"font-style: italic;\">RemainAfterExit=yes<\/span>\r\n<span style=\"font-style: italic;\">WorkingDirectory=\/opt\/ttn-station\/<\/span>\r\n<span style=\"font-style: italic;\">ExecStart=\/opt\/ttn-station\/start.sh<\/span>\r\n<span style=\"font-style: italic;\">TimeoutStartSec=0<\/span>\r\n<span style=\"font-style: italic;\">SyslogIdentifier=ttn-station<\/span>\r\n<span style=\"font-style: italic;\">Restart=on-failure<\/span>\r\n<span style=\"font-style: italic;\">RestartSec=5<\/span>\r\n<span style=\"font-style: italic;\">\r\n[Install]<\/span>\r\n<span style=\"font-style: italic;\">WantedBy=multi-user.target<\/span>\r\n\r\n$ systemctl daemon-reload\r\n$ systemctl enable ttn-station.service\r\n$ systemctl start ttn-station.service<\/pre>\n<h4><span style=\"color: #800000;\"><strong>Step 6: <\/strong><strong>RPI backup img:<\/strong><\/span><\/h4>\n<pre># dd if=\/dev\/mmcblk0 | gzip -1 - | ssh user@backup-server dd of=image.gz<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>TTN version: TTNv3 Frequency: Europe 863-870 MHz (SF9 for RX2 &#8211; recommended) Using Docker: No Last updated: October 13, 2023 Used HW: Raspberry-Pi (version 2, 3 or 4) &amp; iC880a SPI Step 1: Install latest Raspberry Pi OS (choose &#8222;lite&#8220; version). Step 2: Customise OS Run RPI, login as default user &#8222;pi&#8220; (default passwd &#8222;raspberry&#8220;) [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1402,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1392","page","type-page","status-publish","has-post-thumbnail","hentry","post","post-with-thumbnail","post-with-thumbnail-large"],"_links":{"self":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages\/1392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/comments?post=1392"}],"version-history":[{"count":24,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages\/1392\/revisions"}],"predecessor-version":[{"id":6188,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages\/1392\/revisions\/6188"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/media\/1402"}],"wp:attachment":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/media?parent=1392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}