{"id":269,"date":"2020-10-07T21:56:26","date_gmt":"2020-10-07T19:56:26","guid":{"rendered":"http:\/\/www.hoekstra.nu\/wordpress\/?p=269"},"modified":"2020-10-07T21:56:26","modified_gmt":"2020-10-07T19:56:26","slug":"the-things-network-platformio-lilygo-ttgo-t-beam-lora-neo-m8n-gps-esp32","status":"publish","type":"post","link":"http:\/\/www.hoekstra.nu\/wordpress\/blog\/2020\/10\/07\/the-things-network-platformio-lilygo-ttgo-t-beam-lora-neo-m8n-gps-esp32\/","title":{"rendered":"The Things Network + PlatformIO + LilyGO TTGO T-Beam &#8211; LoRa NEO-M8N GPS &#8211; ESP32"},"content":{"rendered":"<p>Recently I&#8217;ve been playing with the\u00a0LilyGO TTGO T-Beam &#8211; LoRa 868MHz &#8211; NEO-M8N GPS &#8211; ESP32.<br \/>\nIt&#8217;s a nice board that includes LoRa, WiFi, Bluetooth and a GPS on a single board.<\/p>\n<p>I programmed it with PlatformIO and got it working with The Things Network.<br \/>\nIf you want to achieve the same, there are a few things you need to keep in mind to get LoRaWAN working.<br \/>\nI my case used the &#8220;MCCI LoRaWAN LMIC library&#8221;, and used the APB example:\u00a0\u00a0https:\/\/github.com\/mcci-catena\/arduino-lmic\/blob\/master\/examples\/ttn-abp\/ttn-abp.ino<\/p>\n<p>Here is what I placed in my platformio.ini to select the 868Mhz frequency for Europe :<\/p>\n<pre>[env:ttgo-t-beam]\r\nplatform = espressif32\r\nframework = arduino\r\nboard = ttgo-t-beam\r\nlib_deps =\r\nMCCI LoRaWAN LMIC library\r\nbuild_flags = -D CFG_eu868 -DLMIC_DEBUG_LEVEL=2 -DLMIC_PRINTF_TO=Serial -D ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS -D CFG_sx1276_radio<\/pre>\n<p>You need to include the Arduino header file near the top of your source file src\/main.cpp:<\/p>\n<pre>#include &lt;Arduino.h&gt;<\/pre>\n<p>You need to add your TTN keys.<br \/>\nPay attention that the formatting of the DEVADDR is different from the NWKSKEY and the APPSKEY.<\/p>\n<pre>static const PROGMEM u1_t NWKSKEY[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };\r\nstatic const u1_t PROGMEM APPSKEY[16] =\u00a0{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };\r\nstatic const u4_t DEVADDR = 0x12345678 ;<\/pre>\n<p>And in the src\/main.cpp you also need to specify a custom pin-mapping for the LMIC library:<\/p>\n<pre>\/\/ Pin mapping\r\nconst lmic_pinmap lmic_pins = {\r\n  .nss = 18, \/\/ chip select \r\n  .rxtx = LMIC_UNUSED_PIN,\r\n  .rst = 23, \/\/ reset pin\r\n  .dio = {26, 33, 32},\r\n};<\/pre>\n<p>And last:<br \/>\nThe function &#8220;void do_send(osjob_t* j)&#8221; needs to be moved above the function &#8220;void onEvent (ev_t ev)&#8221;.<br \/>\nOtherwise PlatformIO produces an error during the compilation.<\/p>\n<p>I hope this helps, and saves you some time.\u00a0 \ud83d\ude09<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I&#8217;ve been playing with the\u00a0LilyGO TTGO T-Beam &#8211; LoRa 868MHz &#8211; NEO-M8N GPS &#8211; ESP32. It&#8217;s a nice board that includes LoRa, WiFi, Bluetooth and a GPS on a single board.<\/p>\n<p>I programmed it with PlatformIO and got it working with The Things Network. If you want to achieve the same, there are <span style=\"color:#777\"> . . . &rarr; Read More: <a href=\"http:\/\/www.hoekstra.nu\/wordpress\/blog\/2020\/10\/07\/the-things-network-platformio-lilygo-ttgo-t-beam-lora-neo-m8n-gps-esp32\/\">The Things Network + PlatformIO + LilyGO TTGO T-Beam &#8211; LoRa NEO-M8N GPS &#8211; ESP32<\/a><\/span><\/p>\n","protected":false},"author":96,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[78,75,76,80,79,77,74],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.hoekstra.nu\/wordpress\/wp-json\/wp\/v2\/posts\/269"}],"collection":[{"href":"http:\/\/www.hoekstra.nu\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hoekstra.nu\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hoekstra.nu\/wordpress\/wp-json\/wp\/v2\/users\/96"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hoekstra.nu\/wordpress\/wp-json\/wp\/v2\/comments?post=269"}],"version-history":[{"count":1,"href":"http:\/\/www.hoekstra.nu\/wordpress\/wp-json\/wp\/v2\/posts\/269\/revisions"}],"predecessor-version":[{"id":270,"href":"http:\/\/www.hoekstra.nu\/wordpress\/wp-json\/wp\/v2\/posts\/269\/revisions\/270"}],"wp:attachment":[{"href":"http:\/\/www.hoekstra.nu\/wordpress\/wp-json\/wp\/v2\/media?parent=269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hoekstra.nu\/wordpress\/wp-json\/wp\/v2\/categories?post=269"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hoekstra.nu\/wordpress\/wp-json\/wp\/v2\/tags?post=269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}