Big ESP32 + SX127x topic part 2


For LMIC-Arduino use the following formats:

// For activation type OTAA (over the air activation) use:

// DevEUI (end-device identifier) in LSB (least-significant-byte) first / little endian format.
static const u1_t PROGMEM DEVEUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

// AppEUI (application identifier) in LSB (least-significant-byte) first / little-endian format.
// For TTN issued EUIs the last bytes should be 0xD5, 0xB3, 0x70.
static const u1_t PROGMEM APPEUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

// AppKey (application key) in MSB (most-significant-byte) first / big endian format.
static const u1_t PROGMEM APPKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

// For activation type ABP (activation by personalization) use:

// DevAddr (end-device address) in MSB (most-significant-byte) first / big endian format.
// Note that in the example it is defined as u4_t, not as an array of u1_t.
static const u4_t DEVADDR = 0x00000000 ;

// NwkSKey (network session key) in MSB (most-significant-byte) first / big endian format.
static const PROGMEM u1_t NWKSKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

// AppSKey (application session key) in MSB (most-significant-byte) first / big endian format.
static const u1_t PROGMEM APPSKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

(Jpm Huls) #171

Thanks bluejedi,

So for ABP, DevAddr can be copied just as it is listed in Hex format. In a post I read it should be LSB, so currently I reversed the bytes in the sketch… The 2 other keys are shown initially as MSB, so those I should have correct.


Yes, DevAddr must be in MSB and can be copied as shown by default in the console (it is not defined as an array in the LMIC code example so no need to select the array format in the console).

(Jpm Huls) #173

Thanks, in that case I’ll have to revert my change and put in the proper DevAddrr. I also got message from the gateway owner that both MSB and LSB keys are supported, as long as they exist in my Application.

Currently I’ve put my Heltex card next to a window, hoping that it can pickup the gateway’s signal…

Also, should I specify the Handler (set to ttn-handler-eu)?


Different keys / IDs can be defined in different byte orders in the source code, as in the case of OTAA.
However, there is no such thing as a MSB and LSB version of the same key / ID and that these are both supported on the gateway. There exists only one value of a key.

The LoRaWAN protocol defines in what byte order the keys and IDs must be transferred over the air, but in the source code for the definition of a key or ID a different byte order may be used. Therefore define keys and IDs in the byte order how they are used in the source code. For LMIC-Arduino the byte orders of the different keys and IDs are defined in the LMIC-Arduino library code.

A different LoRaWAN stack/library can possibly require different byte orders than LMIC-Arduino.

Yes, in Application settings.

(Jpm Huls) #175

In any case, the keys should be in the proper byte order. And I’ve opened the window and put the (default short) antenna outside… Still no data arriving in my application. So if all seems to be set properly, the only conclusion I can make is that I’m still not in reach of a gateway…

(using the Arduino LMIC Master library)

Ok, I’ve just order another 868 antenna to replace the ootb small antenna that came with my Heltec board… If that doesn’t work… :scream:

(Verkehrsrot) #176

Today i received another TTGOv2, ordered on Aliexpress.

Shipping option “Ali Express Standard” took longer than “ePacket”. I ordered on 25/01, the package arrived 19/02, so this makes ~25 days from China to Germany. The other one ordered with option “ePacket” took 15 days. Both not too bad for free shipping.

But now to the downsights:The OLED-Display arrived broken, the right part shows pixel garbage, even in the original flashed demo application. So those chinese quality issues seem to continue with TTGOv2.

Enough time waste for me. I switched to Pycom LoPy, also ESP32 based, and similar features, but no display of course.

Another point: I tried to operate the board in original shape, without external wiring of DIO1. As expected this causes missing LMIC events TX_complete. So the TTGOv2 is unusable for LMIC without extra wiring.

Since i assume that no one needs the micro sd card reader, the one and only advantage of TTGOv2 compared with Heltec is the proven better Wifi antenna.

Heltec announced a new board v2 for march 2018. Let’s wait and see…

(Bsiege) #177

Not shure about that. Have a pair since a few weeks. And they differs much in wifi RX.

Cannot find any optical issue or difference on the antennas.

(Verkehrsrot) #178

The on board so called “3D” wifi antennas on the TTGOv2 are much better than the coil antennas on the Heltec boards. I proved that by counting seen MAC frames in monitor mode over a full week, the difference in total count was signifcant compared with the Heltec. But the performance is still poor compared with the onboard taoglass ceramic antenna on the LoPy/LoPy4.


I have not seen any hard figures yet but my expectation is that LoRa performance of TTGO V2 will be substantially better than the Heltec and the other TTGO’s boards due to use of the HPDTek LoRa module.

Don’t focus too much on the included antenna, get something better or tune it somehow and take care of a proper groundplane.
Even the antenna included with the RAK831 gateway board is sub-optimal (understatement).

(Jpm Huls) #180


(Slash Dev Slash Null) #181

Hi, I just joined to add a comment as…

a. I have just got a pair of TTGO boards in the post to play with
b. I’m struggling to get more that around 12dBm out of the boards (they claim 20dBm)

I haven’t looked to see if there is some soldering fault yet, but the two boards have remarkably similar outputs (within 0.1 dBm), so it seem unlikely they are both identically faulty.

What I have done so far is to load up the OLED_LoRa_Sender and receiver code from the Heltec git page ( I then ran the Tx code on both boards, and fed the output into my Anritsu spectrum analyser to see how the output looked (Image hopefully attached)

The measurements showed a pretty consistent 12.2 dBm output across the expected ~125kHz bandwidth, but what ever I try with the the PA pin settings and TxPower, I don’t get any higher Tx output.

My previous experiments with a couple of RA-01 modules gave me ~18dBm, and this gave me a range of around 5-6 Km without too much messing about. I haven’t had the chance to test the range on these yet, but I’m not expecting > 1-2 km at these power levels.

Has anyone done any tx power tests on these? And and I missing something obvious on the PA/Power config?

Might be time to order a couple of v2 boards and see how they behave, although it sounds like the main change between v1 and v2 is the wifi performance, which I’m not really worried about right now…

(Jpm Huls) #182

Ok, yesterday I decided to do a sort of wardriving after work on my way home to see if my Heltec is actually sending out a signal. Driving near one gateway location resulted in 14 Frame Ups… but no data in my console. So, it definitely has to do with signal coverage. I’m using a proper 868 MHz antenna. Does anyone know

  1. how to “tune the spreading factor” or “increase the tx power”?
  2. Why I don’t see any data in my ttn console while there are 14 Frame Ups? If it is due to missing or incomplete payload decoder/converter, can someone provide an example for both the ttn_abp.ino and the ttn_otaa.ino examples?

Thanks again.

(Jpm Huls) #183

Ok, kit is now outside on a table and… tadaaa… I’m receiving data on my TTN console.

But maybe one of you more experienced IoT gurus can create a full workshop around the ttn_abp/ttn_otaa examples including a Payload Converter/decoder or whatever to complete the example exercise.

Regs, Jean-Pierre


Good to hear that you succeeded in getting it to work.

It would indeed be nice to have some complete walk-through’s. But at least the basic steps are already provided in this topic’s start (but without the payload stuff): which libraries, which settings and which sketch to use for getting a basic node up and running.

(Verkehrsrot) #185

The TTGO boards use SX1276 chip, this has different RF output pins: RFO_HF/LF (depending on frequency band) and PA_Boost.

In the LMIC code power switching between this pin is done in radio.c, the part of code looks like this (note- i tweaked it a little):

static void configPower () {
#ifdef CFG_sx1276_radio
    // no boost used for now
    s1_t pw = (s1_t)LMIC.txpow;
    if(pw > 15) {
        pw = 15;
    } else if(pw < 2) {
        pw = 2;
    // check board type for BOOST pin
    writeReg(RegPaConfig, (u1_t)(0x80|(pw&0xf))); // sets PA_BOOST pin (original lmic)
    //writeReg(RegPaConfig, (u1_t)(pw&0xf)); // sets RFO pin (patched lmic)
    writeReg(RegPaDac, readReg(RegPaDac)|0x4); 

Original LMIC uses PA_BOOST pin. I tried to switch to RFO_HF pin. This caused on the TTGOv2 module that there was no RF power at all, or to be more precise, because i do not own a spectrum analyser: no packets at all seen on the gateway.

Unfortunately we don’t know the schematic of the TTGOv2 board here, but i assume RF power is taken from PA_BOOST pin only. So, this way it should be possible to reach the 20dB output power from the SX1276 when switching it in the PA_BOOST and maxium TX power mode. If the 20dB then do not show up at the antenna of the board, it means the board has bad RF output path.

(Verkehrsrot) #186

I opened two antennas which came with the Heltec and TTGOv2 boards.

They are not identical, the length of the coils is slightly different.
One has a short cut caused by a loose piece of solder in the SMA plug (see picture).

So it maybe useful to examine those antennas before use. The plastic cap can easily be removed and reattached to the SMA plug, it’s not glued.


I found the coils to be (nearly) identical: The BIG and SMALL ANTENNA topic part 1
It is the antenna length below the coil that is different. I measured a difference of two millimeter. On the picture the difference between your antennas appears even more.

(Batigolle) #188

Goodmorning everyone
I successfully managed to run my ESP32 Heltec with the LMIC-Arduino library
can be found here: .

After setting the keys for ABP in the sample file ttn-abp.ino ,
on the gateway I receive the messages, but they are not comtinues,
in TTN console application I receive data every 8 frames

Output example

Is there a setting to be modified to be able to send all frames, in sequence?

(Gebir) #189

Hello All !

if you have 3d printer, you can print shell for TTGO ESP32 LORA.
liligo send me this (printed version can’t buy now :frowning: )