Recently I’ve been playing with the LilyGO TTGO T-Beam – LoRa 868MHz – NEO-M8N GPS – ESP32.
It’s a nice board that includes LoRa, WiFi, Bluetooth and a GPS on a single board.
I programmed it with PlatformIO and got it working with The Things Network.
If you want to achieve the same, there are a few things you need to keep in mind to get LoRaWAN working.
I my case used the “MCCI LoRaWAN LMIC library”, and used the APB example: https://github.com/mcci-catena/arduino-lmic/blob/master/examples/ttn-abp/ttn-abp.ino
Here is what I placed in my platformio.ini to select the 868Mhz frequency for Europe :
[env:ttgo-t-beam] platform = espressif32 framework = arduino board = ttgo-t-beam lib_deps = MCCI LoRaWAN LMIC library build_flags = -D CFG_eu868 -DLMIC_DEBUG_LEVEL=2 -DLMIC_PRINTF_TO=Serial -D ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS -D CFG_sx1276_radio
You need to include the Arduino header file near the top of your source file src/main.cpp:
#include <Arduino.h>
You need to add your TTN keys.
Pay attention that the formatting of the DEVADDR is different from the NWKSKEY and the APPSKEY.
static const PROGMEM u1_t NWKSKEY[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; static const u1_t PROGMEM APPSKEY[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; static const u4_t DEVADDR = 0x12345678 ;
And in the src/main.cpp you also need to specify a custom pin-mapping for the LMIC library:
// Pin mapping const lmic_pinmap lmic_pins = { .nss = 18, // chip select .rxtx = LMIC_UNUSED_PIN, .rst = 23, // reset pin .dio = {26, 33, 32}, };
And last:
The function “void do_send(osjob_t* j)” needs to be moved above the function “void onEvent (ev_t ev)”.
Otherwise PlatformIO produces an error during the compilation.
I hope this helps, and saves you some time. 😉