# Big ESP32 + SX127x topic part 3

**URL:** <https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436>\
**Category:** End Devices (Nodes)\
**Created:** [October 4, 2018, 12:58pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436 "2018-10-04T12:58:13Z")\
**Posts on this page:** 20\
**Page:** 13

<div class="post-metadata">

**Author:** ![bluejedi](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bluejedi/32/44639_2.png) [@bluejedi](https://www.thethingsnetwork.org/forum/u/bluejedi)\
**Post date:** [September 6, 2019, 11:14am UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/250 "2019-09-06T11:14:39Z")

</div>

> [@Verkehrsrot](#):
>
> it runs LMiC controled by hardware Interrupts.

Can hardware interrupts be enabled for LMIC without requiring further changes to Arduino application code?  
When would enabling hardware interrupts for LMIC be useful and when not?  
Is this valid for both the original LMIC-Arduino library and for the MMCI LoRaWAN LMIC library?  
Is that independent of type of MCU used?

Until recently I have only seen remarks like ‘enabling interrupts for LMIC is best avoided because it can cause issues’ while you seem to promote it (use it in Paxcounter).  
I understand that interrupt based is usually better than polling but if so, why hasn’t that been the norm with LMIC previously?

Can you please elaborate on that?

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [September 6, 2019, 12:51pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/251 "2019-09-06T12:51:25Z")

</div>

It’s pretty easy with current MCCI LMIC code, you just have to enable the function in `lmic_config.h`:

`#define LMIC_USE_INTERRUPTS 1`

The original LMIC arduino library does - as far as i see - not and did never include this function.

Using hardware interrupts instead of polling has in my opinion more advantages than disadvantages: Is frees up CPU from polling and thus allows a more “sharp” timing for the time critical opening of RX-windows. This saves power and thus is relevant for all real low power applications. While power savings maybe not significant with Class A devices, it will with Classes B / C.

Another advantage, also for Class A, might be that in busy multithreaded applications (like paxcounter) timing by hardware works better than by software, because by software will cause more jitter, and this could result to missed RX packets. That’s the reason why i decided to switch paxcounter code to use interrupts.

Only disadvantage in my opinion is, that the used GPIO pins for LORA\_IRQ (= DIO0) , and LORA\_DIO1 must be connected to interrupt capable pins of CPU. This might be an issue on hardware with small CPU footprint, but on a ESP32 system you have lots of suitable GPIOs, and as far as i see it works with all Heltec, TTGO, Pycom etc. development boards. So why not using it?

There was an issue, that broke the interrupt function working in MCCI LMiC on ESP32, but recently i spotted the bug in the HAL code, and made a [PR](https://github.com/mcci-catena/arduino-lmic/pull/396) for it. This was merged in MCCI LMIC master last week and since then i have some test clients up and running on interrupts, so far working smooth and i don’t see any RX packet loss any more.

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [September 6, 2019, 12:53pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/252 "2019-09-06T12:53:58Z")

</div>

Next level would be to have ESP32 proprietary interrupt function, which captures the timestamp of the interrupt by hardware. This should be somehow possible with ESP32 hardware, i guess, but i did not yet find out the way how to. This would allow a further sharpening of timing, what opens up opportunity to have a high precision (\< 1ms) “NTP” via LORAWAN.

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [September 6, 2019, 1:28pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/253 "2019-09-06T13:28:00Z")

</div>

TTGO Beam V1.0 now supported by paxcounter.  
To get this running, i did register power management chip AXP202X Library by LilyGo to platformio (after asking them for permission) and added it to paxcounter.  
This chip has a bunch of power management features; unfortunately we still miss a schematic for TTGO Beam V1.0 to use all functions.

---

<div class="post-metadata">

**Author:** ![cjhdev](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cjhdev/32/35697_2.png) [@cjhdev](https://www.thethingsnetwork.org/forum/u/cjhdev)\
**Post date:** [September 6, 2019, 3:15pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/254 "2019-09-06T15:15:41Z")

</div>

> [@bluejedi](#):
>
> When would enabling hardware interrupts for LMIC be useful and when not?

You need interrupts if want to sleep all the time between events (e.g. TX begin, TX complete, RX begin, RX complete, etc.). Pretty sure no-one uses LMIC this way.

Sleep aside, using interrupts might allow you to reduce your clock error compensation since there will be less jitter in determining RX begin compared to polling at both ends. Reducing compensation might mean the radio is waiting to receive for less time.

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [September 9, 2019, 8:12pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/255 "2019-09-09T20:12:22Z")

</div>

I got a TTGO T-Beam V1.0 and enhanced the paxcounter software to support some of the new board features:

- GPS PPS interrupt line
- PMU (power management unit)
- Two Buttons

As PMU an [x-powers.com](http://x-powers.com) AXP192 chip is used. Although this is an older model dated around 2011, is has a bunch of interesting features, look at the [data sheet](http://www.x-powers.com/en.php/Info/product_detail/article_id/29) (unfortunately chinese only, does anyone has english version?)

In paxcounter code i added some examples for the various power interrupts - works! Now you can easyly trigger on power events, like battery connected/removed, USB plug connected/removed, battery overheated/charged etc.

The second user button is also controlled by the PMU.

> <https://github.com/cyberman54/ESP32-Paxcounter/blob/master/src/power.cpp#L18>

---

<div class="post-metadata">

**Author:** ![bluejedi](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bluejedi/32/44639_2.png) [@bluejedi](https://www.thethingsnetwork.org/forum/u/bluejedi)\
**Post date:** [September 10, 2019, 9:48am UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/256 "2019-09-10T09:48:21Z")

</div>

> [@Verkehrsrot](#):
>
> unfortunately chinese only, does anyone has english version?

You may try to (partially) translate it here: [onlinedoctranslator](https://www.onlinedoctranslator.com/en/)

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [September 10, 2019, 9:50am UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/257 "2019-09-10T09:50:22Z")

</div>

Did that already, but doesn’t work well with that technical datasheet.  
Meanwhile i found that the datasheet to the very similary AXP202 chip is available in english, so i can use the register map from this source.

---

<div class="post-metadata">

**Author:** ![Linar](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/linar/32/35697_2.png) [@Linar](https://www.thethingsnetwork.org/forum/u/Linar)\
**Post date:** [September 11, 2019, 4:53pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/258 "2019-09-11T16:53:42Z")

</div>

Recent TTGO product [T-Watch](http://s.click.aliexpress.com/e/LFKHlQVK) belongs to a ‘wearable appliance’ category. And like majority of their products, the T-watch is also based on ESP32 SoC.  
This is an option to buy the watch together with ‘GNSS+LoRa daughterboard’ which has SX1276 RF IC (been wrapped inside S76G SoC) and LoRaWAN compliant firmware built-in.  
The RF daughterboard performs quite well, provided that external SMA antenna is in use.

Below is an illustration of how [SoftRF](https://github.com/lyusupov/SoftRF) firmware is driving the watch to transmit and receive packets with LoRa modulation (FANET protocol):

![](https://thingiverse-production-new.s3.amazonaws.com/assets/fb/f5/53/6f/79/t-watch-extant-2.jpg)

3D design of ‘cargo bay’ for the T-Watch is available on my [Thingiverse page](https://www.thingiverse.com/thing:3856355).  
It is designed to fit for two SMA \<=\> uFL/IPEX adapters.

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [September 11, 2019, 8:26pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/259 "2019-09-11T20:26:44Z")

</div>

Is there a software for the S76G, which replicates the SX1276 signals on GPIO pins? This way LMIC stack could be run on the watch.

---

<div class="post-metadata">

**Author:** ![MattFromSydney](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mattfromsydney/32/25844_2.png) [@MattFromSydney](https://www.thethingsnetwork.org/forum/u/MattFromSydney)\
**Post date:** [September 19, 2019, 6:12am UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/264 "2019-09-19T06:12:18Z")

</div>

I have a TTGO LORA32 board that I am going to use as a soil moisture sensor, however the results of esp\_deep\_sleep\_start() is underwhelming. I have the consumption down to ~15mA when sleeping, but I was hoping/expecting to get down to double-digit uA.

I’ve noticed that the moisture sensor continues to draw current when the ESP32 is in sleep (~5mA), so it looks like there is more to be done with the config.

My current setup is:

> esp\_sleep\_pd\_config(ESP\_PD\_DOMAIN\_RTC\_SLOW\_MEM, ESP\_PD\_OPTION\_OFF);  
> esp\_sleep\_pd\_config(ESP\_PD\_DOMAIN\_RTC\_FAST\_MEM, ESP\_PD\_OPTION\_OFF);  
> esp\_sleep\_pd\_config(ESP\_PD\_DOMAIN\_RTC\_PERIPH, ESP\_PD\_OPTION\_OFF);

and rtc\_gpio\_isolate doesn’t compile.

Does anyone have a working config or suggestions on how I can better reduce deep sleep power consumption?

TIA.

---

<div class="post-metadata">

**Author:** ![LoRaTracker](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/loratracker/32/48502_2.png) [@LoRaTracker](https://www.thethingsnetwork.org/forum/u/LoRaTracker)\
**Post date:** [September 19, 2019, 6:41am UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/265 "2019-09-19T06:41:01Z")

</div>

Long discussion about similar problems on the **ESP32 support forums** ;

> <https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/issues/6>

A bare bones ESP32 board, with a carefully selected regulator, may well get down to 30uA or so in deep sleep, but very often the boards are not designed for that.

Most ESP32 boards have components that may consume current even when the ESP32 device itself is in deep sleep; USB-Serial devices, displays, charger ICs.

---

<div class="post-metadata">

**Author:** ![MattFromSydney](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/mattfromsydney/32/25844_2.png) [@MattFromSydney](https://www.thethingsnetwork.org/forum/u/MattFromSydney)\
**Post date:** [September 19, 2019, 6:42am UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/266 "2019-09-19T06:42:13Z")

</div>

I’ll have a read.

Thanks for the pointer.

---

<div class="post-metadata">

**Author:** ![Linar](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/linar/32/35697_2.png) [@Linar](https://www.thethingsnetwork.org/forum/u/Linar)\
**Post date:** [September 19, 2019, 5:20pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/267 "2019-09-19T17:20:50Z")

</div>

> [@Verkehrsrot](#):
>
> … this way LMIC stack could be run on the watch …

**I have LMIC which runs entirely inside the S76G-based T-Watch daughterboard** (on it’s STM32L073 MCU) as a part of my [SoftRF port on STM32 platform](https://github.com/lyusupov/SoftRF/wiki/Retro-Edition).  
But this topic is out of scopes for this ESP32 thread.

![t-watch-extant-3](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/5/2/52d5d9544bd93c989e50b036a8eb036933ce505d.jpeg)

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [September 20, 2019, 11:47am UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/268 "2019-09-20T11:47:36Z")

</div>

Great! Can you share your LMIC port? In your github repo i found binaries only.

---

<div class="post-metadata">

**Author:** ![Linar](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/linar/32/35697_2.png) [@Linar](https://www.thethingsnetwork.org/forum/u/Linar)\
**Post date:** [September 20, 2019, 1:02pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/269 "2019-09-20T13:02:12Z")

</div>

The LMIC is integrated into SoftRF as one library of many.  
Direct link onto the library is below:

> **[lyusupov/SoftRF](https://github.com/lyusupov/SoftRF/tree/master/software/firmware/source/libraries/arduino-lmic)**
>
> :airplane: Multifunctional, compatible DIY general aviation proximity awareness system - lyusupov/SoftRF

SoftRF/S76G is to be built with [Arduino Core STM32](https://github.com/stm32duino/Arduino_Core_STM32) for Nucleo L073RZ target.

[Build instructions](https://github.com/lyusupov/SoftRF/tree/master/software/firmware/source#stm32)

---

<div class="post-metadata">

**Author:** ![Verkehrsrot](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/verkehrsrot/32/46588_2.png) [@Verkehrsrot](https://www.thethingsnetwork.org/forum/u/Verkehrsrot)\
**Post date:** [September 22, 2019, 7:50pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/270 "2019-09-22T19:50:53Z")

</div>

This means your whole application, including LMIC, is running on the daughterboard of T-Watch, i guess?

I’m looking for a solution which emulates a native SX1276 on the S76g, thus the S76g is controllable like a RFM95 module.

---

<div class="post-metadata">

**Author:** ![fuxi](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/fuxi/32/29253_2.png) [@fuxi](https://www.thethingsnetwork.org/forum/u/fuxi)\
**Post date:** [October 2, 2019, 12:17pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/271 "2019-10-02T12:17:25Z")

</div>

I’m having problems with my recendly purcharsed board - its exact name is:  
SX1276 V2 Lora ESP32 LX6 Dual-Core 0,96" OLED Bluetooth LE Wifi Kit 32 Modul CP2012 IOT 868-915MHz

EDIT: from Heltec  
I’ve tried ttn-abp.ino for activating with differend pin settings and i’m never receiving anything in the Data Console … ☹  
I’ve set up anything properly in my Account with ABP as activation method.

I think for V2 this should be correct:

const lmic\_pinmap lmic\_pins = {  
.nss = 18,  
.rxtx = LMIC\_UNUSED\_PIN,  
.rst = 14,  
.dio = {/_dio0_/ 26, /_dio1_/ 35, /_dio2_/ 34 }  
};

Could it be that I’m already having V2.1 and it requires different settings? (It has only printed “V2” on it)

In my Serial Monitor I’m having something like this:

14:14:02.410 -\> Starting  
14:14:02.410 -\> RXMODE\_RSSI  
14:14:02.410 -\> 9585: engineUpdate, opmode=0x808  
14:14:02.410 -\> 9618: EV\_TXSTART  
14:14:02.444 -\> 9686: TXMODE, freq=903900000, len=26, SF=7, BW=125, CR=4/5, IH=0  
14:14:02.444 -\> Packet queued  
14:14:03.458 -\> 75200: setupRx1 txrxFlags 00 --\> 01  
14:14:03.492 -\> start single rx: now-rxtime: 4  
14:14:03.492 -\> 75331: RXMODE\_SINGLE, freq=923300000, SF=7, BW=500, CR=4/5, IH=0  
14:14:03.492 -\> rxtimeout: entry: 76664 rxtime: 75325 entry-rxtime: 1339 now-entry: 4 rxtime-txend: 61775  
14:14:04.492 -\> 138172: setupRx2 txrxFlags 0x1 --\> 02  
14:14:04.492 -\> start single rx: now-rxtime: 4  
14:14:04.492 -\> 138303: RXMODE\_SINGLE, freq=923300000, SF=9, BW=125, CR=4/5, IH=0  
14:14:04.526 -\> rxtimeout: entry: 140624 rxtime: 138297 entry-rxtime: 2327 now-entry: 4 rxtime-txend: 124747  
14:14:04.526 -\> 140640: processRx2DnData txrxFlags 0x2 --\> 00  
14:14:04.526 -\> 140700: processDnData\_norx txrxFlags 00 --\> 20  
14:14:04.526 -\> 140960: EV\_TXCOMPLETE (includes waiting for RX windows)  
14:14:04.526 -\> 141269: engineUpdate, opmode=0x900

Any ideas what’s wrong?  
Thanks

---

<div class="post-metadata">

**Author:** ![bluejedi](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bluejedi/32/44639_2.png) [@bluejedi](https://www.thethingsnetwork.org/forum/u/bluejedi)\
**Post date:** [October 2, 2019, 12:37pm UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/272 "2019-10-02T12:37:55Z")

</div>

> [@fuxi](#):
>
> SX1276 V2 Lora ESP32 LX6 Dual-Core 0,96" OLED Bluetooth LE Wifi Kit 32 Modul CP2012 IOT 868-915MHz

This looks more like some AliExpress product title than the actual make and model of a board.  
Start with getting the exact make (manufacturer), model and version of your board first _(read the start of this topic for an impression of a subset of available boards)._  
The board make, model and version are essential for determining:

- What pin mappings to use
- If manual wiring of DIO ports is required
- If additional code is required to get the board running _(e.g. like required for TTGO T-Beam V1.0)_

Also take care that the TTN LoRaWAN keys/id’s in the sketch are entered correctly and in the correct byte order. See: [Format of Keys and ID's for Arduino LMIC libraries [HowTo]](https://www.thethingsnetwork.org/forum/t/format-of-keys-and-ids-for-arduino-lmic-library-howto/28243)

Please read the following for how to format code and logs in your posts:  
[How do I format my forum post? [HowTo]](https://www.thethingsnetwork.org/forum/t/how-do-i-format-my-forum-post-howto/8735)

---

<div class="post-metadata">

**Author:** ![fmeylink](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/fmeylink/32/25844_2.png) [@fmeylink](https://www.thethingsnetwork.org/forum/u/fmeylink)\
**Post date:** [October 8, 2019, 11:54am UTC](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436/273 "2019-10-08T11:54:57Z")

</div>

Hi,

I have a heltec v1 board, they are not providing the license code so i cannot use the heltec files.  
i loaded ttgo file in the heltec that worked well, i see the hello world in hex code in the ttn gateway manager.

the problem i have now is that the rssi is not showing on the display.  
i use this code: [https://github.com/PiAir/esp32-sx1276/blob/master/TTN\_test\_ESP32\_ABP.ino](https://github.com/PiAir/esp32-sx1276/blob/master/TTN_test_ESP32_ABP.ino)

any toughts ?

[Previous page](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436.md?page=12)

[Next page](https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436.md?page=14)
