Deep Sleep with LMIC LIbrary

Hello everyone,

I have built a LoraWan sensor that sends its data to TTN. The base is a LilyGo/TTGO. As sensor I use a BME280. The software is compiled with the Arduino IDE. The software is based on the library LMIC. When I turn on the sensor everything works fine and data is transmitted to TTN. I send one packet every 20 minutes.

Now I tried to run the node from battery. It works, but the battery runs out in a few days.

I then tried to use deep_sleep. However with moderate success. The node transmits as it should. The data also arrive at the Geteway. At TTN, however, data arrives only sporadically. Sometimes no data arrives for hours. Sometimes several packets in a row.

Has anyone had similar experiences and then found a solution? I would be pleased about feedback.

Greetings
Josef, DL8DBN

The LilyGo/TTGO is not an ‘ideal’ choice for a deep sleep node.

What is the measured battery current in deep sleep mode ?

When the ESP32 comes out of deep sleep what code do you run, the ESP32 normally would not save its join status in a deep sleep ?

Use a microcontroller that has a low deep sleep current and retains memory during deep sleeps.

There are many many discussions on the forum that you can search for about how deep sleep works on the ESP32 that will help you out.

Also, be aware of how the frame counters work on LoRaWAN - the Learn button at the top of this page will provide you with more info too.

Eureka!
I have found the solution.
After waking up from deep sleep, the Sketch starts again at “void setup”. That means, the LMIC is initialized again by the command “os_init();”. But a multiple call of this function leads to problems. It seems that the LMIC remembers something from the initialization in spite of deep slepp. Now I immediately close the LMIC before the deep sleep starts, with the command “LMIC_shutdown ();”.Now everything works fine.

Translated with DeepL Translate: The world's most accurate translator (free version)

1 Like

So does that mean its doing a join every time it comes out of deep sleep ?

Sounds not good.

You might have a look here as well. Very interesting read on difficulties with LowPower/low update frequency. Different MCU but same principles apply on the Lora side: https://stuartsprojects.github.io/2022/12/14/Easy-Build-TTN-and-LoRaWAN-Nodes.html

I’m building this one too. Seems a nice small project.

1 Like

Yep :rofl: @LoRaTracker (Stuart) does tend to talk with credibility and from hard earned experience :wink:

Yes, the XIAO SAMD21 is good for a simple TTN node.

There are two revised PCBs on the way, both have a FRAM, which is used to (successfully!) save session state, so a power down or reset does not resut in a fresh OTAA join.

2 Likes

Many thanks for the suggestions. First, I will now test my current configuration. The node will now be exposed to the winter weather.
For information: My node sends voltage, temperature, humidity and air pressure every 20 minutes. I do not use OTTA but ABP with Counter Check.

interesting. I just started designing a 3D printed enclosure, using your Dec 2022 design as a basis but I want it to be still usable with your revised design, if it has different size/location of mounting holes/location of connectors. If possible, I want to make my box parametric (or depending on the new layout, with multiple fixing options) so both PCBs can be accommodated

The smaller one, increased in length by 2mm to 41mm x 19mm, but does not have mount holes as such (no room) its more designed for use a tracker, covered in shrink film etc. Or as a pico balloon tracker, so has hanging holes. It changed size because the FRAM was so important in making a tiny deep sleep OTAA TTN node possible.

Screenshot - 01_02_2023 , 14_43_05

The ‘larger’ one does have mount holes and can be fitted with an edge SMA, so more useful for box mounting or general purpose TTN nodes. Still smallish though, 49.5mm x 24mm;

The XIAO needed to be rotated to keep the USB socket out of the way of the SMA socket.

Boards arrived this morning, so if they are OK, details should be online soon.

Am I confusing which board you are refering too ?

Did you mean this one;

I’ve used the 240922 PCB. Almost done with the case, only need to do the lid. But I can in a minute start the printer to make a first test fit prototype. The 18650 holder is in NL, so that’s only something for Friday. It’s a trial anyway, I already see things I’ll change in a next revision.
I’m using meltable mounting posts, sort of a once-off mounting solution but if all is working before mounting it in, then there should be no need to take it out anymore. The USB port will still be reachable. I’ll make a stub to shut off the USB port, to keep creepy crawlers out and to make it a tiny bit splash proof.

1 Like