{"id":1719,"date":"2015-01-21T21:59:12","date_gmt":"2015-01-21T21:59:12","guid":{"rendered":"http:\/\/www.daveakerman.com\/?p=1719"},"modified":"2016-10-16T19:23:11","modified_gmt":"2016-10-16T19:23:11","slug":"making-a-lora-gateway","status":"publish","type":"post","link":"http:\/\/www.daveakerman.com\/?p=1719","title":{"rendered":"Making a LoRa Gateway"},"content":{"rendered":"<p>One of the advantages of the LoRa transceivers, when compared to the traditional RTTY modulation used by most High Altitude Balloons, is that it requires very little processing power at the receiver. \u00a0So instead of using a PC or a high end tablet or phone to decode the transmissions, all you need is a simple microprocessor with (assuming you want to upload data to the web for mapping) an internet connection.<\/p>\n<p>The latter requirement makes devices such as the Raspberry Pi ideal for the task. \u00a0A Pi, plus wired or wireless connection, just needs a simple board added with a LoRa transceiver connected to the SPI pins. \u00a0And that&#8217;s exactly what <a href=\"https:\/\/store.uputronics.com\/index.php?route=product\/product&amp;path=61&amp;product_id=68\">Uputronics<\/a>\u00a0has made &#8211; and here&#8217;s a prototype board that they sent to me:<\/p>\n<p><a href=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/IMG_1214.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-large wp-image-1709\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/IMG_1214-1024x768.jpg\" alt=\"IMG_1214\" width=\"640\" height=\"480\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/IMG_1214-1024x768.jpg 1024w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/IMG_1214-300x225.jpg 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Normally it comes with a single 434MHz LoRa device but here I&#8217;ve added a second (you could add a 434MHz or 868MHz model). \u00a0The remainder of this post will assume that the board is populated with just one device, in position\u00a01.<\/p>\n<p>Physically install is very simple &#8211; just push on to the Pi model A+ or B+, using a standard pin header extender (supplied). \u00a0Or an\u00a0pin header with extended pins can be used if you want to stack another board on top.<\/p>\n<p>Next, burn an operating system onto a suitable SD card. \u00a0For this purpose anything from 4GB should be fine. \u00a0The following instructions are for Raspbian, and no other operating systems have been tested.<\/p>\n<p>First, run raspi-config:<\/p>\n<pre><code>sudo raspi-config<\/code><\/pre>\n<p>Then expand the filesystem, as you would normally do, then choose Advanced Options &#8211;&gt; SPI and enable SPI.<\/p>\n<p><a href=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/rc.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-1720\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/rc.png\" alt=\"rc\" width=\"641\" height=\"286\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/rc.png 641w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/rc-300x133.png 300w\" sizes=\"(max-width: 641px) 100vw, 641px\" \/><\/a><\/p>\n<p>It&#8217;s also worthwhile to change the hostname (Advanced Options &#8211;&gt; Hostname). \u00a0Finally, close the program and choose the reboot option.<\/p>\n<p>Once rebooted, login again. \u00a0We now have some software to install. \u00a0First,\u00a0install wiringPi, which is used for the SPI library and to read the status of the LoRa module via 2 of its INT pins:<\/p>\n<pre><code>cd ~\r\ngit clone git:\/\/git.drogon.net\/wiringPi\r\ncd wiringPi\r\n.\/build<\/code><\/pre>\n<p>Next, install SSDV which is used to decode download images:<\/p>\n<pre><code>cd ~\r\ngit clone https:\/\/github.com\/fsphil\/ssdv.git\r\ncd ssdv\r\nsudo make install<code><\/code><\/code><\/pre>\n<p>The gateway software uses the curl library for internet access (uploading telemetry data and\/or image data), so install that:<\/p>\n<pre><code>sudo apt-get install libcurl4-openssl-dev<\/code><\/pre>\n<p>and the ncurses library used for the screen display:<\/p>\n<pre><code>sudo apt-get install libncurses5-dev<\/code><\/pre>\n<p>Finally, install the gateway software itself:<\/p>\n<pre><code>cd ~\r\ngit clone https:\/\/github.com\/PiInTheSky\/lora-gateway.git\r\ncd lora-gateway\r\nmake<\/code><\/pre>\n<p>That completes the installation, so now for the configuration. \u00a0The main settings are in a file gateway.txt in the above folder (\/home\/pi\/lora-gateway). \u00a0Here&#8217;s a simple example:<\/p>\n<pre><code>tracker=MYCALLSIGN\r\n\r\n<\/code>frequency_0=434.451\r\nmode_0=2\r\n\r\n#frequency_1=434.450\r\n#mode_1=0<\/pre>\n<p>This firstly sets\u00a0<span style=\"text-decoration: underline;\">your<\/span> callsign, which if you are a radio amateur would normally be your radio callsign, but it can be something else.<\/p>\n<p>The next part sets the frequency and mode for the first LoRa device (the one in position &#8220;1&#8221;). \u00a0Frequency is in MHz and should match the frequency of the tracker that you intend to receive. \u00a0&#8220;Mode&#8221; is described below, where the other (optional) settings are also described. \u00a0The final lines are commented out, to disable the second LoRa module.<\/p>\n<pre style=\"color: #333333;\"><code>tracker=&lt;callsign&gt;.  This is whatever callsign you want to appear as on the tracking map and\/or SSDV page.\r\n\r\nEnableHabitat=&lt;Yes\/No&gt;.  Enables\/disables telemetry upload to habitat.\r\n\r\nEnableSSDV=&lt;Yes\/No&gt;.  Enables\/disables image upload to the SSDV server.\r\n\r\nfrequency_&lt;n&gt;=&lt;freq in MHz&gt;.  This sets the frequency for LoRa module &lt;n&gt; (0 for first, 1 for second).  e.g. frequency_0=434.450\r\n\r\nmode_&lt;n&gt;=&lt;mode&gt;.  Sets the \"mode\" for the selected LoRa module.  This offers a simple way of setting the various\r\n                LoRa parameters (SF etc.) in one go.  The modes are:\r\n\r\n                0 = (normal for telemetry)  Explicit mode, Error coding 4:8, Bandwidth 20.8kHz, SF 11, Low data rate optimize on\r\n                1 = (normal for SSDV)       Implicit mode, Error coding 4:5, Bandwidth 20.8kHz,  SF 6, Low data rate optimize off\r\n                2 = (normal for repeater)   Explicit mode, Error coding 4:8, Bandwidth 62.5kHz,  SF 8, Low data rate optimize off\r\n                3 = (normal for fast SSDV)  Explicit mode, Error coding 4:6, Bandwidth 250kHz,   SF 7, Low data rate optimize off\r\n\r\nSF_&lt;n&gt;=&lt;Spreading Factor&gt;  e.g. SF_0=7\r\n\r\nBandwidth_&lt;n&gt;=&lt;Bandwidth&gt;.  e.g. Bandwidth_0=41K7.  Options are 7K8, 10K4, 15K6, 20K8, 31K25, 41K7, 62K5, 125K, 250K, 500K\r\n\r\nImplicit_&lt;n&gt;=&lt;Y\/N&gt;.  e.g. Implicit_0=Y\r\n\r\nCoding_&lt;n&gt;=&lt;error_coding&gt;.  e.g. Coding_0=5 (4:5)\r\n<\/code><\/pre>\n<p>To run, just type<\/p>\n<pre>sudo .\/gateway<\/pre>\n<p>and you will see a screen like this:<\/p>\n<p><a href=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/gw1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-1726\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/gw1.png\" alt=\"gw\" width=\"643\" height=\"385\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/gw1.png 643w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/gw1-300x179.png 300w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><\/a><\/p>\n<p>In this example, channel 0 (the LoRa module in position 1 on the board) is enabled, at 434.451MHz, and mode 0 which is a shorthand for a mode suitable for continuous long-range telemetry transmission.<\/p>\n<p>The status display updates as packets are received:<\/p>\n<p><a href=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/gw2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-1727\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/gw2.png\" alt=\"gw2\" width=\"640\" height=\"388\" srcset=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/gw2.png 640w, http:\/\/www.daveakerman.com\/wp-content\/uploads\/2015\/01\/gw2-300x181.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Finally, to exit the program, press CTRL+C.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the advantages of the LoRa transceivers, when compared to the traditional RTTY modulation used by most High Altitude Balloons, is that it requires very little processing power at the receiver. \u00a0So instead of using a PC or a high end tablet or phone to decode the transmissions, all [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1719"}],"collection":[{"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1719"}],"version-history":[{"count":7,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1719\/revisions"}],"predecessor-version":[{"id":1992,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1719\/revisions\/1992"}],"wp:attachment":[{"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1719"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}