Skip to content

LowPower.deepSleep not working after modem.begin #36

Closed
@janvrska

Description

@janvrska
  • I am running the latest version of this repository (dependencies too)
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been created

Expected Behavior

After setting modem.begin(EU868) and LowPower.deepSleep() it goes sleep, and the chip will not wake up.

Current Behavior

After setting modem.begin(EU868) and LowPower.deepSleep() it goes sleep, but after around 900ms it wakes up.

If modem.begin(EU868) isn't used then it works as intended, and the chip will not wake up.

Minimal example

#include <Arduino.h>
#include <STM32LoRaWAN.h>
#include <STM32RTC.h>
#include "STM32LowPower.h"

STM32RTC& rtc = STM32RTC::getInstance();
STM32LoRaWAN modem;

void setup() {
    Serial.begin(115200);
    modem.begin(EU868);
    LowPower.begin();
    LowPower.deepSleep();
}

void loop() {
    Serial.begin(115200);
    Serial.println("wakes up");
    delay(1000);
    LowPower.deepSleep();
}

Power Profiler screenshot with modem.begin()
image

Power Profiler screenshot without modem.begin()
image

Details (what I tried)

I tried to look on

bool STM32LoRaWAN::begin(_lora_band band)
{
if (instance != nullptr)
return failure("Only one STM32LoRaWAN instance can be used");
instance = this;
/*
* Init RTC as an object :
* use the MIX mode = free running BCD calendar + binary mode for
* the sub-second counter RTC_SSR on 32 bit
*/
_rtc.setClockSource(STM32RTC::LSE_CLOCK);
_rtc.setBinaryMode(STM32RTC::MODE_MIX);
_rtc.begin(true, STM32RTC::HOUR_24);
/* Attach the callback function before enabling Interrupt */
_rtc.attachInterrupt(UTIL_TIMER_IRQ_MAP_PROCESS, STM32RTC::ALARM_B);
_rtc.attachSecondsInterrupt(TIMER_IF_SSRUCallback);
/* The subsecond alarm B is set during the StartTimerEvent */
UTIL_TIMER_Init(_rtc.getHandle());
and tried in my main code to:

rtc.detachInterrupt, rtc.detachSecondsInterrupt, rtc.disableAlarm (both A ,B), but none of it worked.

Only when I after modem.begin() called rtc.end() and then rtc.begin() it stops waking up, but after joining the network (which was successfull), modem.send() didn't send any message (propably some problem with RTC settings that should have been set in modem.begin() and was cleared after rtc.end())

Context

I'm using supported LORA-E5 chip (STM32WLE5JC) on custom PCB

platformio.ini:

[env:lora_e5_mini]
platform = ststm32
board = lora_e5_mini
framework = arduino
lib_deps = 
    https://github.com/stm32duino/STM32LoRaWAN.git#0.2.0
    https://github.com/stm32duino/STM32RTC.git#1.4.0
    https://github.com/stm32duino/STM32LowPower.git#5ae219c
monitor_speed = 115200
monitor_filters = time
upload_protocol = stlink
debug_tool = stlink

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't working

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions