Giter VIP home page Giter VIP logo

stm32lowpower's Introduction

STM32LowPower

Arduino library to support STM32 Low Power.

Requirement

API

  • void begin(): configure the Low Power

  • void idle(uint32_t ms): enter in idle mode param ms (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the chip in ms milliseconds.

  • void sleep(uint32_t ms): enter in sleep mode param ms (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the chip in ms milliseconds.

  • void deepSleep(uint32_t ms): enter in deepSleep mode param ms (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the chip in ms milliseconds.

  • void shutdown(uint32_t ms): enter in shutdown mode param ms (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the board in ms milliseconds.

Note

With STM32RTC version lower than 1.1.0, the minimum number of milliseconds is 1000 ms.**

  • void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode): Enable GPIO pin in interrupt mode. If the pin is a wakeup pin, it is configured as wakeup source (see board documentation). param pin: pin number
    param callback: pointer to callback
    param mode: interrupt mode (HIGH, LOW, RISING, FALLING or CHANGE) param LowPowerMode: Low power mode which will be used (IDLE_MODE, SLEEP_MODE, DEEP_SLEEP_MODE or SHUTDOWN_MODE). In case of SHUTDOWN_MODE only, Wakeup pin capability is activated.

  • void enableWakeupFrom(HardwareSerial *serial, voidFuncPtrVoid callback): enable a UART peripheral in low power mode. See board documentation for low power mode compatibility.
    param serial: pointer to a UART
    param callback: pointer to a callback to call when the board is waked up.

  • void enableWakeupFrom(STM32RTC *rtc, voidFuncPtr callback, void * data) attach a callback to the RTC peripheral.
    param rtc: pointer to RTC. Could be NULL as RTC is a Singleton.
    param callback: pointer to a callback to call when the board is waked up.
    param callback: data: optional pointer to callback data parameters (default NULL).

  • void enableWakeupFrom(TwoWire *wire, voidFuncPtrVoid callback): enable an I2C peripheral in low power mode. See board documentation for low power mode compatibility. Currently not available.
    param wire: pointer to I2C
    param callback: pointer to a callback to call when the board is waked up.

Begin() function must be called at least once before idle(), sleep(), deepSleep() or shutdown() functions.

attachInterruptWakeup() or enableWakeupFrom() functions should be called before idle(), sleep(), deepSleep() or shutdown() functions.

Important

  • HardwareSerial used as Wakeup source will configure it to use HSI clock source even if another peripheral clock is configured.

  • RTC used as Wakeup source requires to have LSE or LSI as clock source. If one of them is used nothing is changed else it will configure it to use LSI clock source. One exception exists when SHUTDOWN_MODE is requested and PWR_CR1_LPMS is defined, in that case LSE is required. So, if the board does not have LSE, it will fail.

  • The board will restart when exit shutdown mode.

Hardware state

  • Idle mode: low wake-up latency (µs range) (e.g. ARM WFI). Memories and voltage supplies are retained. Minimal power saving mainly on the core itself.

  • sleep mode: low wake-up latency (µs range) (e.g. ARM WFI), Memories and voltage supplies are retained. Minimal power saving mainly on the core itself but higher than idle mode.

  • deep sleep mode: medium latency (ms range), clocks are gated to reduced. Memories and voltage supplies are retained. If supported, Peripherals wake-up is possible (UART, I2C ...).

  • shutdown mode: high wake-up latency (possible hundereds of ms or second timeframe), voltage supplies are cut except always-on domain, memory content are lost and system basically reboots.

Source

You can find the source files at
https://github.com/stm32duino/STM32LowPower

stm32lowpower's People

Contributors

abostm avatar angelnu avatar fpistm avatar frastm avatar morsisko avatar per1234 avatar tshcherban avatar ttmaza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stm32lowpower's Issues

Nucleo L432KC low power problem

I’m trying to go in sleep mode (using the LowPower.deepSleep() command) for a few seconds between 2 serial prints.

But somehow the print statements are right after eachother, so the board doesn’t appear to go to sleep. Any idea?

Edit: just found out that it should reset after a deepsleep, which is doesn’t either.

Pin alternate function

Hello,
I try to use timer input capture with a Nucleo-L476RG, TIM3, channel 1.
The channel input pin is PA6. I linked PA6 to PA0 while PA0 is running a PWM output signal.
Timer is counting, but there is no edge detection.
What is the function to set up PA6 so it will act as timer capture input?
pinMode function doesn't accept alternate as mode parameter.
I tried this but without success:

// PA6
pinMode(PA6, INPUT);
pin_function(digitalPinToPinName(PA6), STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0));

pinMode call is to setup pin as configured, pin_function call is to set alternate configuration.
Thanks for your help,
Patrick

LowPower.deepSleep doesnt work

Hello,

i use an Custom Stm32L432KC Board but if i use LowPower.deepSleep in my Code in Arduino Windows tell me the USB Device got some Error -> Invalid Device Description.

If i use LowPower.sleep, it wont work at all, Serial.print occour infinity no delay at all.

So maybe u can help me and tell what i do wrong?

How to get elapsed time in low power modes?

Hi,
I normally use Arduino's millis() function to measure the elapsed time since application started. But, by entering any of the low-power modes, the millis() counter seems to be freezed, so I can't get the real elapsed time by millis().
Is there a way in which I can get the elapsed time even in low-power modes?
Thanks.

Using LSE clock source for the RTC does not work with the LowPower shutdown

Hi, I have made a forum post here that contains information about the bug. https://www.stm32duino.com/viewtopic.php?f=62&t=360

Here is the sample code that doesn't work. It shuts down on the first loop and never starts up again.


#include <STM32RTC.h>

#include <STM32LowPower.h>

STM32RTC& rtc = STM32RTC::getInstance();
volatile bool sleeping = false;
void callback(void* data)
{
	sleeping = false;
	Serial.println("Callback!");
	Serial.flush();
}

void setup() {
	// put your setup code here, to run once:
	Serial.begin(9600);
	Serial.println("Started");
	Serial.flush();


	rtc.begin();
	rtc.setClockSource(STM32RTC::LSE_CLOCK);
	LowPower.begin();

	if (!rtc.isTimeSet())
	{
		Serial3.println("Time did not persist.");
		Serial3.flush();
	}
	else
	{
		Serial3.println("Time persisted!");
		Serial3.flush();
	}
	rtc.setHours(5);
	rtc.setMinutes(5);
	rtc.setSeconds(1);
	rtc.setWeekDay(1);
	rtc.setDay(1);
	rtc.setMonth(1);
	rtc.setYear(20);
	LowPower.enableWakeupFrom(&rtc, callback);
}

void loop() {
	Serial.println("Shutting down!");
	Serial.flush();
	LowPower.shutdown(1000);
	Serial.println("Done!");
	Serial.flush();
}

If you remove the line "rtc.setClockSource()" the code operates normally however the time does not persist.

Unable to upload since TimedWakeup example

Hi all, thanks for this library.

I have been playing with the blink example just trying different delays for the LED and programming several times successfully.

Next I uploaded the TimedWakeup example which seems to be working well.
I have now tried to upload another example and I now constantly get the following error.

      -------------------------------------------------------------------
                       STM32CubeProgrammer v2.3.0                  
      -------------------------------------------------------------------

ST-LINK SN  : 061D08002A12354D314B4E00
ST-LINK FW  : V2J31S7
Voltage     : 3.14V
Error: ST-LINK error (DEV_TARGET_CMD_ERR)

I have tried resetting the board, unplugging and replugging the ST-Link.
I am using the blue pill board.

Is there something I need to do to make this work again? I was thinking that now the MCU is in deep sleep mode the programmer is not working but I am unsure. Any help is appreciated.

LowPower.attachInterruptWakeup() configures external interrupt pins incorrectly

Pins will be configured incorrectly when LowPower.attachInterruptWakeup() is invoked because the underlying Arduino LowPower_EnableWakeUpPin() function will treat every GPIO pin as a SystemWakeup pin even if it can operate as an ExternalInterrupt pin. This matters because of this feature of SystemWakeup pins (from the STM32L071 reference manual in this case):

"PWR power control/status register (PWR_CSR)

Bit 8 EWUP1: Enable WKUP pin 1
This bit is set and cleared by software.
0: WKUP pin 1 is used for general purpose I/Os. An event on the WKUP pin 1 does not
wakeup the device from Standby mode.
1: WKUP pin 1 is used for wakeup from Standby mode and forced in input pull down
configuration (rising edge on WKUP pin 1 wakes-up the system from Standby mode).
Note: This bit is reset by a system reset."

So a pin operating in SystemWakeup mode WILL have an internal-pull down attached while the same pin operating in EXTI mode may pull-up, pull-down, or no internal pull-up. Whether or not this will cause your code to fail to operate will be dependent on the external circuit attached to the pin. I happened to discover this issue as my particular circuit required the GPIO pin to have the internal pull-up to function properly. Strictly speaking this isn't a flaw in the STM32LowPower module per se, as it's the underlying Arduino STM32 code that doesn't recognize that GPIO pins have multiple wake-up modes with conflicting properties. As-is, LowPower.attachInterruptWakeup() should only be called if the shutdown() function is to be used, which currently puts the STM32 into Standby mode which requires external interrupts to be configured as SystemWakeup.

ExternalWakeup example and UART

On the ExternalWakeup example, If I add Serial.println(repetitions) instruction. Then the LowPower.sleep(); will not worked.

#include "STM32LowPower.h"

#define LED_BUILTIN  PB12

// Blink sequence number
// Declare it volatile since it's incremented inside an interrupt
volatile int repetitions = 1;

// Pin used to trigger a wakeup
const int pin = PB5;

void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
  // Set pin as INPUT_PULLUP to avoid spurious wakeup
  pinMode(pin, INPUT_PULLUP);

  // Configure low power
  LowPower.begin();
  // Attach a wakeup interrupt on pin, calling repetitionsIncrease when the device is woken up
  LowPower.attachInterruptWakeup(pin, repetitionsIncrease, RISING);
}

void loop() {
  /*
  for (int i = 0; i < repetitions; i++) {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
  }*/
  Serial.println(repetitions);
  // Triggers an infinite sleep (the device will be woken up only by the registered wakeup sources)
  // The power consumption of the chip will drop consistently
  LowPower.sleep();
}

void repetitionsIncrease() {
  // This function will be called once on device wakeup
  // You can do some little operations here (like changing variables which will be used in the loop)
  // Remember to avoid calling delay() and long running functions since this functions executes in interrupt context
  repetitions ++;
}

Got compilation errors

Hello,

I've been trying to use this library with Blue Pill board.

After adding dependency to STM32RTC + Wire, I got following (adding platformio config):

image

Thank you in advance for help!

Low power Arduino Library for STM32L151

I have tested this lowpower arduino to the RAK811 LoRa module.
Using this example in this github, the deepSleep/shutdown current is about 3.5miliAmp,
while using RAK811 firmware, the deepSleep current can be about 12 microAmp.

Do you have any explanation for the difference ?

Regards,

deepSleep() wakes up before alarm timeouts

I'm trying to put the STM32 into deep sleep for an hour by using deepSleep(60x60x1000) but I see that the MCU wakes up much earlier (perhaps after 20 or 30 seconds).

All I'm doing in my code is to use the basic functionality shown in the TimedWakeup example, so I call begin() in setup() and then call deepSleep() in the loop().

I must also say that I use three serial interfaces in total, one for debuging, one hardware serial and one software serial. My suspicion is that one of those is causing the MCU to go out of sleep.

Is there a way to only enable waking up from RTC?

I have also seen the example AlarmTimedWakeup, which seems to do something similar but in a different way. There is no explanation why this is different. Is that the best way to use in my case?

Support for Arduino_STM32

Hi guys, I'm currently using the Arduino_STM32 from here and i couldn't find a way to run this version on there. There is some possibility to run the same code using that core? thanks

LowPowerSupport for STMG0-series

Hi,
I tried to compile the example sketch 'AlarmTimedWakeup' but it failed with a
STM32LowPowerIssue-5.txt
linkage error:

  Linking everything together...
  ...
  collect2: error: ld returned 1 exit status
  Using library STM32duino_Low_Power at version 1.1.0 in folder: /home/bekr/MYCODE-ARDUINO-IDE/libraries/STM32duino_Low_Power 
  Using library STM32duino_RTC at version 1.1.0 in folder: /home/bekr/MYCODE-ARDUINO-IDE/libraries/STM32duino_RTC 
  Using library SrcWrapper at version 1.0.1 in folder: /home/bekr/.arduino15/packages/STMicroelectronics/hardware/stm32/2.0.0/libraries/SrcWrapper 
  exit status 1
  Error compiling for board Generic STM32G0 series.

My question is then, does the library lack support for STM32G0-series, or is it something that should work, but obviously does not. I'm using Arduino IDE 1.8.15 on Debian Linux/Bullseye. I have attached the complete log from Arduino IDE for inforamtion.

Issue compiling for STM32MP1

I am trying to compile the following sketch. This is the ExternalWakeup sketch. But the error occurs on other examples as well.

Also the Releases for the STM32LowPower and STM32RTC library are not correct. The attached release files are of 1.0.0 and not 1.0.3. Is this intentional? I have tried both and the same error was present.

/*
  ExternalWakeup

  This sketch demonstrates the usage of External Interrupts (on pins) to wakeup
  a chip in sleep mode. Sleep modes allow a significant drop in the power usage
  of a board while it does nothing waiting for an event to happen.
  Battery powered application can take advantage of these modes to enhance
  battery life significantly.

  In this sketch, pressing a pushbutton attached to pin will wake up the board.

  This example code is in the public domain.
*/


#include "hal_conf_extra.h"
#include "STM32LowPower.h"

// Blink sequence number
// Declare it volatile since it's incremented inside an interrupt
volatile int repetitions = 1;

// Pin used to trigger a wakeup
#ifndef USER_BTN
#define USER_BTN SYS_WKUP1
#endif

const int pin = USER_BTN;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  // Set pin as INPUT_PULLUP to avoid spurious wakeup
  pinMode(pin, INPUT_PULLUP);

  // Configure low power
  LowPower.begin();
  // Attach a wakeup interrupt on pin, calling repetitionsIncrease when the device is woken up
  LowPower.attachInterruptWakeup(pin, repetitionsIncrease, RISING);
}

void loop() {
  for (int i = 0; i < repetitions; i++) {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
  }
  // Triggers an infinite sleep (the device will be woken up only by the registered wakeup sources)
  // The power consumption of the chip will drop consistently
  LowPower.sleep();
}

void repetitionsIncrease() {
  // This function will be called once on device wakeup
  // You can do some little operations here (like changing variables which will be used in the loop)
  // Remember to avoid calling delay() and long running functions since this functions executes in interrupt context
  repetitions ++;
}

This is the code in "hal_conf_extra.h".

#define HAL_RTC_MODULE_ENABLED

I get the following Error.

In file included from /home/mint/Arduino/libraries/STM32duino_Low_Power/src/STM32LowPower.h:51,
                 from /home/mint/Documents/Shepherd Projects/Low power/ExternalWakeup/ExternalWakeup.ino:17:
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:75:17: error: 'HOUR_FORMAT_12' was not declared in this scope
   75 |       HOUR_12 = HOUR_FORMAT_12,
      |                 ^~~~~~~~~~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:76:17: error: 'HOUR_FORMAT_24' was not declared in this scope
   76 |       HOUR_24 = HOUR_FORMAT_24
      |                 ^~~~~~~~~~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:80:12: error: 'HOUR_AM' was not declared in this scope; did you mean 'HOUR_24'?
   80 |       AM = HOUR_AM,
      |            ^~~~~~~
      |            HOUR_24
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:81:12: error: 'HOUR_PM' was not declared in this scope; did you mean 'HOUR_24'?
   81 |       PM = HOUR_PM
      |            ^~~~~~~
      |            HOUR_24
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:85:28: error: 'OFF_MSK' was not declared in this scope
   85 |       MATCH_OFF          = OFF_MSK,                          // Never
      |                            ^~~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:86:28: error: 'SS_MSK' was not declared in this scope
   86 |       MATCH_SS           = SS_MSK,                           // Every Minute
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:87:28: error: 'SS_MSK' was not declared in this scope
   87 |       MATCH_MMSS         = SS_MSK | MM_MSK,                  // Every Hour
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:87:37: error: 'MM_MSK' was not declared in this scope
   87 |       MATCH_MMSS         = SS_MSK | MM_MSK,                  // Every Hour
      |                                     ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:88:28: error: 'SS_MSK' was not declared in this scope
   88 |       MATCH_HHMMSS       = SS_MSK | MM_MSK | HH_MSK,         // Every Day
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:88:37: error: 'MM_MSK' was not declared in this scope
   88 |       MATCH_HHMMSS       = SS_MSK | MM_MSK | HH_MSK,         // Every Day
      |                                     ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:88:46: error: 'HH_MSK' was not declared in this scope
   88 |       MATCH_HHMMSS       = SS_MSK | MM_MSK | HH_MSK,         // Every Day
      |                                              ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:89:28: error: 'SS_MSK' was not declared in this scope
   89 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:89:37: error: 'MM_MSK' was not declared in this scope
   89 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                                     ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:89:46: error: 'HH_MSK' was not declared in this scope
   89 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                                              ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:89:55: error: 'D_MSK' was not declared in this scope
   89 |       MATCH_DHHMMSS      = SS_MSK | MM_MSK | HH_MSK | D_MSK, // Every Month
      |                                                       ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:92:28: error: 'SS_MSK' was not declared in this scope
   92 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:92:37: error: 'MM_MSK' was not declared in this scope
   92 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                                     ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:92:46: error: 'HH_MSK' was not declared in this scope
   92 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                                              ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:92:55: error: 'D_MSK' was not declared in this scope
   92 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                                                       ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:92:63: error: 'M_MSK' was not declared in this scope
   92 |       MATCH_MMDDHHMMSS   = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK,
      |                                                               ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:28: error: 'SS_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                            ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:37: error: 'MM_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                                     ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:46: error: 'HH_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                                              ^~~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:55: error: 'D_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                                                       ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:63: error: 'M_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                                                               ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:93:71: error: 'Y_MSK' was not declared in this scope
   93 |       MATCH_YYMMDDHHMMSS = SS_MSK | MM_MSK | HH_MSK | D_MSK | M_MSK | Y_MSK
      |                                                                       ^~~~~
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h: In member function 'bool STM32RTC::isTimeSet()':
/home/mint/Arduino/libraries/STM32duino_RTC/src/STM32RTC.h:204:14: error: 'RTC_IsTimeSet' was not declared in this scope; did you mean 'isTimeSet'?
  204 |       return RTC_IsTimeSet();
      |              ^~~~~~~~~~~~~
      |              isTimeSet
exit status 1
Error compiling for board STM32MP1 series coprocessor.

ExternalWakeup - add deepSleep() example - leak of current

In ExternalWakeup example there is line 36 which is just for shutdown() mode

LowPower.attachInterruptWakeup(pin, repetitionsIncrease, RISING);

Function attachInterruptWakeup is declared in STM32LowPower.h as:
void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode = SHUTDOWN_MODE);
which means that if you call LowPower.attachInterruptWakeup(pin, repetitionsIncrease, FALLING); with deepSleep(), it will call LowPower_EnableWakeUpPin function for SHUTDOWN mode by default. Result of this is that pin is left floating during sleep and there is current leakage.

To be precise, without including LowPowerMode in call, I measured 70uA current during deepSleep, and with adding DEEP_SLEEP_MODE current is 1.6uA.

So solution is to call:
LowPower.attachInterruptWakeup(pin, repetitionsIncrease, FALLING, DEEP_SLEEP_MODE);

Please add this to example (at least to comment) so someone else will spare couple of hours to investigate what is missing :)

STM32L4R5xx does not restart or resume code execution after wakeup from deep sleep

Hi,

I have a STM32L4R5ZIY6 which I am trying to get working correctly with deep sleep mode. I can effectively put the MCU into deep sleep mode as observed by the low current readings and it appears to wake up as well per current readings but no code gets executed. According to your read me a wake-up from deep sleep will trigger a reboot.

I see neither this nor resuming from after the sleep statement.

Thanks for any pointers.
Serge

Serial is not output normally when returning from DeepSleep

Serial is not output normally when returning from DeepSleep

My Envitonment

STM32F103(8MHz Xtal) + platformIO

Platform Manager
================
Platform ststm32
--------
Checking platformio/ststm32                   15.2.0                             [Up-to-date]
Checking platformio/toolchain-gccarmnoneeabi  1.70201.0 @ >=1.60301.0,<1.80000.0 [Up-to-date]
Checking platformio/framework-arduinoststm32  4.20100.211028 @ ~4.20100.0        [Up-to-date]
Checking platformio/framework-arduinoststm32-maple 3.10000.201129 @ ~3.10000.0        [Up-to-date]
Checking platformio/tool-stm32duino           1.0.1 @ ~1.0.1                     [Up-to-date]
Checking platformio/tool-openocd              2.1100.211028 @ ~2.1100.0          [Up-to-date]
Checking platformio/tool-dfuutil              1.9.200310 @ ~1.9.190708           [Up-to-date]

My config

[platformio]
default_envs = blackpill_f103c8

[env:blackpill_f103c8]
platform = ststm32
board = blackpill_f103c8
framework = arduino
lib_deps =
  https://github.com/stm32duino/STM32LowPower
  https://github.com/stm32duino/STM32RTC

My code

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

void setup() {
  LowPower.begin();
  Serial.begin(115200);
  Serial.println("serial (same as 1)");
  Serial.println("*****");
}

void loop() {
  Serial.println("serial printing");
  for(int i=0;i<20;i++) LowPower.deepSleep(1000);
  //for(int i=0;i<20;i++) LowPower.sleep(1000);
  //for(int i=0;i<20;i++) LowPower.idle(1000);
  //delay(1000);
}

Problem

Serial is not output normally when returning from DeepSleep.

Serial is output normally when returning from Sleep.

Serial is output normally when returning from Idle.

Screen Shot

LowPower

Deep sleep not waking up

Hi,

I moved to the latest (08.20.2020) version of the STM32LowPower and stm32duino and now my code does not always wake up from deep sleep with a STM32L41x and an external LSE cristal.

My code is:

setup()

  STM32RTC& rtc = STM32RTC::getInstance();
  rtc.setClockSource(STM32RTC::LSE_CLOCK);
  rtc.begin();
  
  LowPower.begin();

  #if defined(STM32L4xx) 
    HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2);
    HAL_PWREx_DisableBORPVD_ULP();
  #endif

sleep (uint32_t sleepTime)

    STM32RTC& rtc = STM32RTC::getInstance();

    //Round the sleep time - I was trying this circumvention in case the problem was with sub second delays
    if (sleepTime % 1000) sleepTime+=1000;
    sleepTime = (sleepTime/1000)*1000;

    //remember start
    uint32_t start_ms=0;
    uint32_t startTime = rtc.getEpoch(&start_ms);

    HAL_SuspendTick(); //Without this the MCU wakes up inmediatly

    LowPower.deepSleep(sleepTime);

    //remember start
    uint32_t end_ms=0;
    uint32_t endTime = rtc.getEpoch(&end_ms);

    HAL_ResumeTick();
    sleepTime = (endTime - startTime) * 1000 + endTime - startTime;
      
    addMillis(sleepTime);
    Serial.print(F("Deep slept "));
    Serial.println(sleepTime);

The weird thing is that it works most of the times (maybe 9 out of 10) but when it does not it hangs for ever (I enabled the flag for the watchdog to allow long deep sleeps of minutes) until I reset.

In the example I do not see HAL_SuspendTick being used but at least for me it does not work without it.

If there is any debugging/logs you would recommend please let me know.

Sleep modes can fail with no feedback to the user

Hello-
The LowPower_stop() function relies on ST's HAL_PWR_EnterSTOPMode() function to enter sleep modes. Sleep mode is actually entered with the WFI ARM assembly instruction with has the following explanation from ARM:
WFI (Wait For Interrupt) makes the processor suspend execution (Clock is stopped) until one of the following events take place:

  • An IRQ interrupt
  • An FIQ interrupt
  • A Debug Entry request made to the processor

If one of these events is pending or happens to trigger at the exact time the processor executes WFI, program execution will continue in HAL_PWR_EnterSTOPMode() with no flags set that sleep mode wasn't actually entered. Most software I've seen written doesn't take into account the fact that entry into sleep mode could have actually failed, resulting in inconsistent behavior when using a debugger or lots of interrupts. To guarantee that the device does in fact sleep code should check the wake-up flag (defined as PWR_FLAG_WU in the ST libraries). ST's low-power functions recommend clearing this bit (it does start at 0 on POR) before invoking sleep modes, but I've yet to see any application code do so. A more robust implementation of this library's STM32LowPower::deepSleep() function would be as follows:

void STM32LowPower::deepSleep(uint32_t millis)
{
  if((millis > 0) || _rtc_wakeup) {
    programRtcWakeUp(millis, DEEP_SLEEP_MODE);
  }
  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
   while ((PWR->CSR & PWR_FLAG_WU) == 0x00)  {
    LowPower_stop(_serial);
  }
}

For even more functionality a timeout value could be added so that the process could be aborted if the device is failing to sleep excessively. Then give a return value that the user can check to verify that the device woke up from sleep or sleep mode failed.

library cant upload to stm32f103c8

when i upload this library to stm32f103c8t6 board,I stuck with this error"#error "PWR configuration is missing. Check flag HAL_PWR_MODULE_ENABLED in variants/board_name/stm32yzxx_hal_conf.h"

no matching function for call....

Hey! I am trying to compile the standard SerialDeepSleep example from the library and I am getting tons of errors:

C:\Users\Игорь\Documents\Arduino\libraries\STM32LowPower-master\examples\SerialDeepSleep\SerialDeepSleep.ino: In function 'void setup()':
SerialDeepSleep:25:50: error: no matching function for call to 'STM32LowPower::enableWakeupFrom(USBSerial*, void (&)())'
In file included from C:\Users\Игорь\Documents\Arduino\libraries\STM32LowPower-master\examples\SerialDeepSleep\SerialDeepSleep.ino:13:
C:\Users\�����\Documents\Arduino\libraries\STM32LowPower-master\src/STM32LowPower.h:94:10: note: candidate: 'void STM32LowPower::enableWakeupFrom(HardwareSerial*, voidFuncPtrVoid)'
   94 |     void enableWakeupFrom(HardwareSerial *serial, voidFuncPtrVoid callback);
      |          ^~~~~~~~~~~~~~~~
C:\Users\�����\Documents\Arduino\libraries\STM32LowPower-master\src/STM32LowPower.h:94:43: note:   no known conversion for argument 1 from 'USBSerial*' to 'HardwareSerial*'
   94 |     void enableWakeupFrom(HardwareSerial *serial, voidFuncPtrVoid callback);
      |                           ~~~~~~~~~~~~~~~~^~~~~~
C:\Users\�����\Documents\Arduino\libraries\STM32LowPower-master\src/STM32LowPower.h:95:10: note: candidate: 'void STM32LowPower::enableWakeupFrom(STM32RTC*, voidFuncPtr, void*)'
   95 |     void enableWakeupFrom(STM32RTC *rtc, voidFuncPtr callback, void *data = NULL);
      |          ^~~~~~~~~~~~~~~~
C:\Users\�����\Documents\Arduino\libraries\STM32LowPower-master\src/STM32LowPower.h:95:37: note:   no known conversion for argument 1 from 'USBSerial*' to 'STM32RTC*'
   95 |     void enableWakeupFrom(STM32RTC *rtc, voidFuncPtr callback, void *data = NULL);
      |                           ~~~~~~~~~~^~~
exit status 1
no matching function for call to 'STM32LowPower::enableWakeupFrom(USBSerial*, void (&)())'

What could be the problem?
I am using the core: https://github.com/stm32duino/Arduino_Core_STM32
Microcontroller: STM32L152CBT6
Безымянный

Ask for update

Hello
When updating the library in platformio errors started because it mentions that certain functions that belong to low_power.h are not declared as attached in the following image, when using this programming environment should I define something else?
I tried the library on arduino and it works but going to Platformio doesn't finish loading the program, I am using STM32duino on both platforms.
Thank you for your attention
asd

Compilation error

Hello,
I am facing a strange issue. Please bear with me and help me out.
STM32 Arduino core version used is 1.5.0
The compilation error as follows:

"C:\Users\...\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11  -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOC -DERROR_LED_PIN=13 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10803 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1  -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -DMCU_STM32F103C8  -mthumb  -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 "-IC:\Users\...\Documents\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple" "-IC:\Users\...\Documents\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include" "-IC:\Users\...\Documents\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/stm32f1/include" "-IC:\Users\...\Documents\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/stm32f1" "-IC:\Users\...\Documents\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/usb/usb_lib" "-IC:\Users\...\Documents\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple" "-IC:\Users\...\Documents\Arduino\hardware\Arduino_STM32\STM32F1\variants\generic_stm32f103c" "-IC:\Users\...\Documents\Arduino\libraries\STM32duino_Low_Power\src" "-IC:\Users\...\Documents\Arduino\libraries\STM32RTC\src" "-IC:\Users\...\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\Wire" "C:\Users\...\AppData\Local\Temp\arduino_build_623640\sketch\SerialDeepSleep.ino.cpp" -o "C:\Users\...\AppData\Local\Temp\arduino_build_623640\preproc\ctags_target_for_gcc_minus_e.cpp"
In file included from C:\Users\...\Documents\Arduino\libraries\STM32duino_Low_Power\examples\SerialDeepSleep\SerialDeepSleep.ino:13:0:

C:\Users\...\Documents\Arduino\libraries\STM32duino_Low_Power\src/STM32LowPower.h:46:2: error: #error "PWR configuration is missing. Check flag HAL_PWR_MODULE_ENABLED in variants/board_name/stm32yzxx_hal_conf.h"

 #error "PWR configuration is missing. Check flag HAL_PWR_MODULE_ENABLED in variants/board_name/stm32yzxx_hal_conf.h"

  ^

In file included from C:\Users\...\Documents\Arduino\libraries\STM32duino_Low_Power\src/STM32LowPower.h:49:0,

                 from C:\Users\...\Documents\Arduino\libraries\STM32duino_Low_Power\examples\SerialDeepSleep\SerialDeepSleep.ino:13:

C:\Users\...\Documents\Arduino\libraries\STM32RTC\src/STM32RTC.h:46:2: error: #error "RTC configuration is missing. Check flag HAL_RTC_MODULE_ENABLED in variants/board_name/stm32yzxx_hal_conf.h"

 #error "RTC configuration is missing. Check flag HAL_RTC_MODULE_ENABLED in variants/board_name/stm32yzxx_hal_conf.h"

  ^

Multiple libraries were found for "STM32RTC.h"
 Used: C:\Users\...\Documents\Arduino\libraries\STM32RTC
 Not used: C:\Users\...\Documents\Arduino\libraries\STM32duino_RTC
Multiple libraries were found for "Wire.h"
 Used: C:\Users\...\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\Wire
 Not used: C:\Users\...\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\WireSlave
Using library STM32duino_Low_Power at version 1.0.1 in folder: C:\Users\...\Documents\Arduino\libraries\STM32duino_Low_Power 
Using library STM32RTC at version 1.0.3 in folder: C:\Users\...\Documents\Arduino\libraries\STM32RTC 
Using library Wire at version 1.0 in folder: C:\Users\Tapan\Documents\Arduino\hardware\Arduino_STM32\STM32F1\libraries\Wire 
exit status 1
Error compiling for board Generic STM32F103C series.

I have installed the STM32RTC library.

Minimun achived current is 1.4 mA

I am trying to use this library but the minimum current that I am getting with shutdown mode is 1.4 mA. The same result was observed in Platform.IO and Arduino IDE.

I flash the program using serial mode.

The board is a blackpill with stm32f103c8t6

#include <low_power.h>
#include <STM32LowPower.h>

void setup() {
  LowPower.begin();
  LowPower.shutdown(15000);

}

void loop() {

}

WKUP pin for shutdown mode

Hi friends,
I want to wake up the micro-controller from shutdown mode using WKUP pin (PA0). is there anyway to do it in this repository approach?

Add support for wake on SPI

Would it be possible for support to be added for waking on incoming SPI signal?
This library is great by the way!

Is Wire.h required?

I noticed a reference to wire.h at STM32LowPower.h:52 - Is this required? Removing it makes less code build, but the final binary seems to stay the same size.

Support for STM32WL boards

Hi,
I want to try this example of .ino code for the STM32WL board? (NUCLEO-WL55JC)

Can you tell what changes should I make?

Library uses 12K of flash memory!

I am using a STM32F070F6 in my project, with only 32K of flash, but just the low power library added 12K to my code. Is there an easy way to use the STM32 low power modes but using less flash memory?

thanks

Bluepill STM32 doesn't enter sleep mode

I'm trying to work out what the default wakeup events are for the STM32.

I tried modifying the timed wakeup example from deepSleep to sleep, and now it does nothing - sleep mode is never started.

#include "STM32LowPower.h"

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  // Configure low power
  LowPower.begin();
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  LowPower.sleep(1000);
  digitalWrite(LED_BUILTIN, LOW);
  LowPower.sleep(1000);
}

STM32 doesn't enter sleep mode when compiling on Windows 10 but does when compiled on Linux

Compiling the following deepsleep example, from STM32LowPower, on Windows 10 doesn't work but does on Linux.

For some reason when compiling on Win10, STM32 doesn't go to sleep but does when compiled on Ubuntu 20.04 LTS. Logical conclusion is something with the toolchain.

/*
  TimedWakeup

  This sketch demonstrates the usage of Internal Interrupts to wakeup a chip
  in deep sleep mode.

  In this sketch, the internal RTC will wake up the processor every second.

  This example code is in the public domain.
*/

#include "STM32LowPower.h"

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  // Configure low power
  LowPower.begin();
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  LowPower.deepSleep(1000);
  digitalWrite(LED_BUILTIN, LOW);
  LowPower.deepSleep(1000);
}

Low power modes

Hi! I've to use low power modes based on the charge of an external battery with stm32L053R8.
I read the voltage of battery through ADC and if this is less of "x" I enter into low power mode.
I readed datasheet and I see five power modes and I want to use low power run and sleep mode. In this library I see other modes (idle mode, sleep mode , deep sleep mode and shutdown mode). They are the same or not? I can use this for my project? Thank you for help :)

Build library error: error: 'SYS_WKUP1' undeclared (first use in this function) 103 | case SYS_WKUP1

When compiling against the newest STM32 core with this library, I get the following error:

error: 'SYS_WKUP1' undeclared (first use in this function)
103 | case SYS_WKUP1 :

Specifically, this command fails (I can repro on the command line alone)
"C:/Program Files/Arm/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin/arm-none-eabi-gcc" -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb "@C:\Users\Admin\AppData\Local\Temp\arduino_build_744812/sketch/build_opt.h" -c -Os -w -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD "-ID:\Igniter\OneFX" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\cores\arduino/avr" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\cores\arduino/stm32" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\cores\arduino/stm32/LL" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\cores\arduino/stm32/usb" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\cores\arduino/stm32/OpenAMP" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\cores\arduino/stm32/usb/hid" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\cores\arduino/stm32/usb/cdc" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Drivers/STM32F4xx_HAL_Driver/Inc/" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Drivers/STM32F4xx_HAL_Driver/Src/" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/STM32F4xx/" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Middlewares/ST/STM32_USB_Device_Library/Core/Src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Middlewares/OpenAMP" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Middlewares/OpenAMP/open-amp/lib/include" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Middlewares/OpenAMP/libmetal/lib/include" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Middlewares/OpenAMP/virtual_driver" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Middlewares/Third_Party/FatFs/src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\variants\OneFxBoot/FatFs" -DSTM32F4xx -DARDUINO=10813 -DARDUINO_OneFxFull -DARDUINO_ARCH_STM32 "-DBOARD_NAME="OneFxFull"" -DSTM32F405xx -DHAL_UART_MODULE_ENABLED "-ID:\My Documents\Arduino\hardware\OneFX\tools\CMSIS\5.7.0/CMSIS/Core/Include/" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Drivers/CMSIS/Device/ST/STM32F4xx/Include/" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\system/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/" "-ID:\My Documents\Arduino\hardware\OneFX\tools\CMSIS\5.7.0/CMSIS/DSP/Include" "-ID:\My Documents\Arduino\hardware\OneFX\tools\CMSIS\5.7.0/CMSIS/DSP/PrivateInclude" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\cores\arduino" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\variants\OneFxBoot" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\STM32LowPower\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\STM32RTC\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\OneFx\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\OneFxCommon\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\Wav\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\DataStream\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\NEC\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\GyroAccl\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\Wire\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\SrcWrapper\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\SPI\src" "-ID:\My Documents\Arduino\hardware\OneFX\STM32\libraries\DigitalIO\src" "D:\My Documents\Arduino\hardware\OneFX\STM32\libraries\STM32LowPower\src\low_power.c" -o "C:\Users\Admin\AppData\Local\Temp\arduino_build_744812\libraries\STM32LowPower\low_power.c.o"

Where is SYS_WKUP1 actually defined as a variable? I see it gets set in PinDefinitoins.h for each variant, but it never seems to be defined as an extern anywhere.

When I do Serial.println twice, sleep time doesn't work properly

My Envitonment

STM32F103(8MHz Xtal) + platformIO

Platform Manager
================
Platform ststm32
--------
Checking platformio/ststm32                   15.2.0                             [Up-to-date]
Checking platformio/toolchain-gccarmnoneeabi  1.70201.0 @ >=1.60301.0,<1.80000.0 [Up-to-date]
Checking platformio/framework-arduinoststm32  4.20100.211028 @ ~4.20100.0        [Up-to-date]
Checking platformio/framework-arduinoststm32-maple 3.10000.201129 @ ~3.10000.0        [Up-to-date]
Checking platformio/tool-stm32duino           1.0.1 @ ~1.0.1                     [Up-to-date]
Checking platformio/tool-openocd              2.1100.211028 @ ~2.1100.0          [Up-to-date]
Checking platformio/tool-dfuutil              1.9.200310 @ ~1.9.190708           [Up-to-date]

My config

[platformio]
default_envs = blackpill_f103c8

[env:blackpill_f103c8]
platform = ststm32
board = blackpill_f103c8
framework = arduino
lib_deps =
  https://github.com/stm32duino/STM32LowPower
  https://github.com/stm32duino/STM32RTC

My code

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

void setup() {
  LowPower.begin();
  Serial.begin(115200);
  Serial.println("serial (same as 1)");
  Serial.println("*****");
}

void loop() {
  Serial.println("serial printing");
  Serial.println("serial printing 2");
  //for(int i=0;i<20;i++) LowPower.deepSleep(1000);
  //for(int i=0;i<10;i++) LowPower.sleep(1000);
  for(int i=0;i<10;i++) LowPower.idle(1000);
  //delay(1000);
}

Problem

sleep time does not work properly.

Multiple External Interrupt Not working in Deep Sleep Mode

In Low Power Deep Sleep mode in setup multiple external interrupt pins declared. But only one ISR is responding while others are not working. If I pick only one at a time and comment out the rest then it is working. I want to use multiple external interrupts as source of wake-up. Please help!

what timer/interupt library to match

Hello,
thanks for this great lib.
What timer / interupt library matches to this lib for STM32F103C8 / Blue Pill.

are there any conflicts to be expected?

thanks Oliver

Does not compile for STM32F1 in VisualStudio+Platformio

Does not compile for STM32F1-BluePill in VisualStudio+Platformio because definitions used in low_power.h:

#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION > 0x01090000) &&
defined(HAL_PWR_MODULE_ENABLED) && !defined(HAL_PWR_MODULE_ONLY)

are not defined in Platformio for STM32DUINO environment for STM32F1-BluePill board. Same for STM32RTC library used in LowPower library:

#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION > 0x01090000) &&
defined(HAL_RTC_MODULE_ENABLED) && !defined(HAL_RTC_MODULE_ONLY)

Here is the list of defines for STM32F1-BluePill, defined in c_cpp_properties.json :
"PLATFORMIO=50100",
"STM32F1",
"STM32F103xB",
"ARDUINO_BLUEPILL_F103C8",
"STM32F1xx",
"ARDUINO=10808",
"ARDUINO_ARCH_STM32",
"ARDUINO_BLUEPILL_F103C8",
"BOARD_NAME="BLUEPILL_F103C8"",
"HAL_UART_MODULE_ENABLED"

Power consumption for STM32L0 below 1mA

Hi everyone,
I'm using stm32duino for STM32L0 for Dragino LSN50.
I use the variant B-L072Z-LRWAN1 as it is very similar to LSN50. The only difference are some SPI and LoRa pins.

I'm able to go down from 10mA in normal mode to 1mA in deep sleep / shutdown mode.
LoRa is not in used yet.
Is there anyway I should take note to go down bellow 1mA?
By right, the STM32L) should go to uA in deep sleep/shutdown mode?

Thanks a lot.

#include "config.h"
#include "STM32LowPower.h"

// https://github.com/stm32duino/Arduino_Core_STM32/tree/master/variants/DISCO_L072CZ_LRWAN1
// DISCO Pin: https://os.mbed.com/platforms/ST-Discovery-LRWAN1/
  
void setup() {  
  Serial.begin(BAUD_RATE);
  Serial.println("Hello LoRa Low-Power Node");
  delay(1000);  

  // Configure low power
  LowPower.begin();

  // Setup LoRa
  // setupLoRa();  
}

void loop() { 
  // After sleep, doing some work
  // Serial.println("Doing some work...");
  
  // Send to gateway
  // sendLoRaMessage(sensorMessage);
  // sendLoRaMessage("Hi");
  delay(10000);
 
  // Deep sleep       
  Serial.println("Going to sleep...");  
  // delay(1000);
  // LoRa.sleep();
  // LowPower.sleep(5000);
  // LowPower.deepSleep(10000);
  LowPower.shutdown(10000);
  // LoRa.idle();
}

do not compile on platformio

The example https://github.com/stm32duino/STM32LowPower/blob/master/examples/TimedWakeup/TimedWakeup.ino works well with arduino but with platformio (same board) and platformio.ini:

[env]
framework = arduino
monitor_speed = 115200
lib_deps =
	 STM32duino  Low Power

[env:nucleo_l476rg]
platform = ststm32
board = nucleo_l476rg

I get:

pio run -j1 -e nucleo_l476rg -v
******************************************************************************************************************************************************************************************************************************
Obsolete PIO Core v5.1.1 is used (previous was 5.2.0a3)
****************************************************************************
Processing nucleo_l476rg (platform: ststm32; board: nucleo_l476rg; framework: arduino; monitor_speed: 115200; lib_deps: STM32duino  Low Power)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_l476rg.html
PLATFORM: ST STM32 (12.1.1) > ST Nucleo L476RG
HARDWARE: STM32L476RGT6 80MHz, 128KB RAM, 1MB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES: 
 - framework-arduinoststm32 4.10900.200819 (1.9.0) 
 - framework-cmsis 2.50501.200527 (5.5.1) 
 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
arm-none-eabi-g++ -o "/home/pat1/git/rmap/platformio/test/microduinostm32_F103CB_lowpower/src/TimedWakeup.ino.cpp" -x c++ -fpreprocessed -dD -E "/tmp/tmp6_9qwuio"
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Library Manager: Installing STM32duino  Low Power
Library Manager: STM32duino Low Power @ 1.1.0 has been installed!
Library Manager: Installing dependencies...
Library Manager: STM32duino RTC @ 1.1.0 is already installed
Found 12 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <STM32duino Low Power> 1.1.0 (/home/pat1/git/rmap/platformio/test/microduinostm32_F103CB_lowpower/.pio/libdeps/nucleo_l476rg/STM32duino Low Power)
|   |-- <STM32duino RTC> 1.1.0 (/home/pat1/git/rmap/platformio/test/microduinostm32_F103CB_lowpower/.pio/libdeps/nucleo_l476rg/STM32duino RTC)
|   |-- <Wire> 1.0 (/home/pat1/.platformio/packages/framework-arduinoststm32/libraries/Wire)
Building in release mode
arm-none-eabi-g++ -o .pio/build/nucleo_l476rg/src/TimedWakeup.ino.cpp.o -c -std=gnu++14 -fno-threadsafe-statics -fno-rtti -fno-exceptions -fno-use-cxa-atexit -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Os -mcpu=cortex-m4 -mthumb -ffunction-sections -fdata-sections -Wall -nostdlib --param max-inline-insns-single=500 -DPLATFORMIO=50101 -DSTM32L476xx -DSTM32L4xx -DARDUINO=10808 -DARDUINO_ARCH_STM32 -DARDUINO_NUCLEO_L476RG -DBOARD_NAME=\"NUCLEO_L476RG\" -DHAL_UART_MODULE_ENABLED -Isrc "-I.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src" -I/home/pat1/.platformio/packages/framework-arduinoststm32/libraries/Wire/src "-I.pio/libdeps/nucleo_l476rg/STM32duino RTC/src" -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/avr -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32 -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/LL -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/OpenAMP -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/hid -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/cdc -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32L4xx_HAL_Driver/Inc -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32L4xx_HAL_Driver/Src -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/STM32L4xx -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/open-amp/lib/include -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/libmetal/lib/include -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/virtual_driver -I/home/pat1/.platformio/packages/framework-cmsis/CMSIS/Core/Include -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32L4xx/Include -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc -I/home/pat1/.platformio/packages/framework-cmsis/CMSIS/DSP/Include -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino -I/home/pat1/.platformio/packages/framework-arduinoststm32/variants/NUCLEO_L476RG -I/home/pat1/.platformio/packages/framework-arduinoststm32/variants/NUCLEO_L476RG src/TimedWakeup.ino.cpp
arm-none-eabi-g++ -o ".pio/build/nucleo_l476rg/libf31/STM32duino Low Power/STM32LowPower.cpp.o" -c -std=gnu++14 -fno-threadsafe-statics -fno-rtti -fno-exceptions -fno-use-cxa-atexit -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Os -mcpu=cortex-m4 -mthumb -ffunction-sections -fdata-sections -Wall -nostdlib --param max-inline-insns-single=500 -DPLATFORMIO=50101 -DSTM32L476xx -DSTM32L4xx -DARDUINO=10808 -DARDUINO_ARCH_STM32 -DARDUINO_NUCLEO_L476RG -DBOARD_NAME=\"NUCLEO_L476RG\" -DHAL_UART_MODULE_ENABLED "-I.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src" -I/home/pat1/.platformio/packages/framework-arduinoststm32/libraries/Wire/src "-I.pio/libdeps/nucleo_l476rg/STM32duino RTC/src" -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/avr -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32 -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/LL -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/OpenAMP -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/hid -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/usb/cdc -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32L4xx_HAL_Driver/Inc -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Drivers/STM32L4xx_HAL_Driver/Src -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/STM32L4xx -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/open-amp/lib/include -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/libmetal/lib/include -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Middlewares/OpenAMP/virtual_driver -I/home/pat1/.platformio/packages/framework-cmsis/CMSIS/Core/Include -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32L4xx/Include -I/home/pat1/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc -I/home/pat1/.platformio/packages/framework-cmsis/CMSIS/DSP/Include -I/home/pat1/.platformio/packages/framework-arduinoststm32/cores/arduino -I/home/pat1/.platformio/packages/framework-arduinoststm32/variants/NUCLEO_L476RG -I/home/pat1/.platformio/packages/framework-arduinoststm32/variants/NUCLEO_L476RG ".pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp"
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::begin()':
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp:56:3: error: 'LowPower_init' was not declared in this scope; did you mean 'LowPower'?
   56 |   LowPower_init();
      |   ^~~~~~~~~~~~~
      |   LowPower
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::idle(uint32_t)':
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp:71:3: error: 'LowPower_sleep' was not declared in this scope
   71 |   LowPower_sleep(PWR_MAINREGULATOR_ON);
      |   ^~~~~~~~~~~~~~
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::sleep(uint32_t)':
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp:85:3: error: 'LowPower_sleep' was not declared in this scope
   85 |   LowPower_sleep(PWR_LOWPOWERREGULATOR_ON);
      |   ^~~~~~~~~~~~~~
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::deepSleep(uint32_t)':
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp:99:3: error: 'LowPower_stop' was not declared in this scope; did you mean 'LowPower'?
   99 |   LowPower_stop(_serial);
      |   ^~~~~~~~~~~~~
      |   LowPower
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::shutdown(uint32_t)':
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp:113:3: error: 'LowPower_shutdown' was not declared in this scope
  113 |   LowPower_shutdown();
      |   ^~~~~~~~~~~~~~~~~
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::attachInterruptWakeup(uint32_t, voidFuncPtrVoid, uint32_t, LP_Mode)':
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp:130:5: error: 'LowPower_EnableWakeUpPin' was not declared in this scope; did you mean 'HAL_PWR_EnableWakeUpPin'?
  130 |     LowPower_EnableWakeUpPin(pin, mode);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~
      |     HAL_PWR_EnableWakeUpPin
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::enableWakeupFrom(HardwareSerial*, voidFuncPtrVoid)':
.pio/libdeps/nucleo_l476rg/STM32duino Low Power/src/STM32LowPower.cpp:147:5: error: 'LowPower_EnableWakeUpUart' was not declared in this scope
  147 |     LowPower_EnableWakeUpUart(_serial, callback);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
*** [.pio/build/nucleo_l476rg/libf31/STM32duino Low Power/STM32LowPower.cpp.o] Error 1
================================================================================================= [FAILED] Took 2.58 seconds =================================================================================================

Environment           Status    Duration
--------------------  --------  ------------
microduino_stm32f103  IGNORED
nucleo_l476rg         FAILED    00:00:02.577
=========================================================================================== 1 failed, 0 succeeded in 00:00:02.577 ===========================================================================================

any suggestions?

wakeup from deep sleep with RTC or pin

Hey, I want to use deep sleep in my project.
I want to use RTC and pin interrupt to wake up from deep sleep.
I want it to wake up from the thing that happens the first.
Is that even possible?
(I can manage it on my own, I just want to know if that's possible)

attachInterruptWakeup pin works only for PA0 on bluepill

Seems that attachInterruptWakeup pin works only for PA0 pin on BluePill.
I have tried other pins but I can only trigger the wake up of the board from PA0 (even if I set other pins e.g PA1 at below code)
Do I miss something here?

const int BUTTON_PIN = PA1;
LowPower.attachInterruptWakeup(BUTTON_PIN, repetitionsIncrease, RISING);

Strange adc behaviour after deepSleep

In my setup i need to measure voltage between 0v and 5v. I used resistive devider with two 10kOm resistors. And used analogRead to measure analog input. After waking up recived value is around 10% lower then before deepSleep. I am using board blue pill with this chip CKS32F 103C8T6 NK1M5 1845 E. I tried different variants to initialize ADC again after sleep, but without luck. Now i do software reset after waking up, but i want to do it properly.

Fails to compile in Platform.IO

It seems it cannot find the function prototypes. Is there something extra I need to do after installing this library?

Compiling .pio/build/rak811_tracker/libda9/STM32duino Low Power/STM32LowPower.cpp.o
.pio/libdeps/rak811_tracker/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::begin()':
.pio/libdeps/rak811_tracker/STM32duino Low Power/src/STM32LowPower.cpp:56:3: error: 'LowPower_init' was not declared in this scope; did you mean 'LowPower'?
   56 |   LowPower_init();

Clarification on what functions map to what modes

The STM32L071 has 5 low-power modes: Low-power Run, Sleep, Low-power Sleep, Stop, and Standby. The STM32LowPower library only has 4 modes: Idle, Sleep, DeepSleep, and Shutdown. The code's comments are not consistent in describing what STM mode corresponds to what library mode, leading to confusion on which should be used. I had thought I had found bugs in the library code until I realized it was the comments that were incorrect which had led me to invoke the wrong functions.

In STM32LowPower.cpp:

Line 63 says that Idle = STM Sleep
Line 77 says that Sleep = STM Sleep, conflicting with Idle
Line 91 says that DeepSleep = STM Stop
Line 105 says that Shutdown = STM Standby

Line 128 says that Idle = STM Sleep and Sleep = STM Stop, conflicting with the prior description of Stop
Line 131 says that DeepSleep = STM Standby, which conflicts with the prior description of DeepSleep

If the comments could be revised to clarify these issues it would be appreciated. Note that none of these descriptions claim to invoke Low-power Run or Low-Power sleep, so these descriptions link 4 Arduino functions to only 3 of the 5 STM low-power functions.

Bluepill F103C8: Build fails on platformio for version 1.1.0

Hello,
thank you for providing us with the library. Unfortunately, STM32duino Low [email protected] fails to build using the following configuration:

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino

lib_deps =
    STM32duino Low [email protected]
    STM32duino RTC

Error message:

Compiling .pio/build/bluepill_f103c8/libae0/Wire/utility/twi.c.o
Compiling .pio/build/bluepill_f103c8/lib1bf/STM32duino Low Power/STM32LowPower.cpp.o
Compiling .pio/build/bluepill_f103c8/lib1bf/STM32duino Low Power/low_power.c.o
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::begin()':
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp:56:3: error: 'LowPower_init' was not declared in this scope; did you mean 'LowPower'?
   56 |   LowPower_init();
      |   ^~~~~~~~~~~~~
      |   LowPower
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::idle(uint32_t)':
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp:71:3: error: 'LowPower_sleep' was not declared in this scope
   71 |   LowPower_sleep(PWR_MAINREGULATOR_ON);
      |   ^~~~~~~~~~~~~~
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::sleep(uint32_t)':
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp:85:3: error: 'LowPower_sleep' was not declared in this scope
   85 |   LowPower_sleep(PWR_LOWPOWERREGULATOR_ON);
      |   ^~~~~~~~~~~~~~
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::deepSleep(uint32_t)':
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp:99:3: error: 'LowPower_stop' was not declared in this scope; did you mean 'LowPower'?
   99 |   LowPower_stop(_serial);
      |   ^~~~~~~~~~~~~
      |   LowPower
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::shutdown(uint32_t)':
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp:113:3: error: 'LowPower_shutdown' was not declared in this scope
  113 |   LowPower_shutdown();
      |   ^~~~~~~~~~~~~~~~~
Archiving .pio/build/bluepill_f103c8/libae0/libWire.a
Archiving .pio/build/bluepill_f103c8/libed8/libSTM32duino RTC.a
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::attachInterruptWakeup(uint32_t, voidFuncPtrVoid, uint32_t, LP_Mode)':
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp:130:5: error: 'LowPower_EnableWakeUpPin' was not declared in this scope; did you mean 'HAL_PWR_EnableWakeUpPin'?
  130 |     LowPower_EnableWakeUpPin(pin, mode);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~
      |     HAL_PWR_EnableWakeUpPin
Indexing .pio/build/bluepill_f103c8/libae0/libWire.a
Indexing .pio/build/bluepill_f103c8/libed8/libSTM32duino RTC.a
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp: In member function 'void STM32LowPower::enableWakeupFrom(HardwareSerial*, voidFuncPtrVoid)':
.pio/libdeps/bluepill_f103c8/STM32duino Low Power/src/STM32LowPower.cpp:147:5: error: 'LowPower_EnableWakeUpUart' was not declared in this scope
  147 |     LowPower_EnableWakeUpUart(_serial, callback);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
*** [.pio/build/bluepill_f103c8/lib1bf/STM32duino Low Power/STM32LowPower.cpp.o] Error 1

Am I doing something wrong, or is there any further info I can provide?

millis() does not return the correct time

My Envitonment

STM32F103(8MHz Xtal) + platformIO

Platform Manager
================
Platform ststm32
--------
Checking platformio/ststm32                   15.2.0                             [Up-to-date]
Checking platformio/toolchain-gccarmnoneeabi  1.70201.0 @ >=1.60301.0,<1.80000.0 [Up-to-date]
Checking platformio/framework-arduinoststm32  4.20100.211028 @ ~4.20100.0        [Up-to-date]
Checking platformio/framework-arduinoststm32-maple 3.10000.201129 @ ~3.10000.0        [Up-to-date]
Checking platformio/tool-stm32duino           1.0.1 @ ~1.0.1                     [Up-to-date]
Checking platformio/tool-openocd              2.1100.211028 @ ~2.1100.0          [Up-to-date]
Checking platformio/tool-dfuutil              1.9.200310 @ ~1.9.190708           [Up-to-date]

My config

[platformio]
default_envs = blackpill_f103c8

[env:blackpill_f103c8]
platform = ststm32
board = blackpill_f103c8
framework = arduino
lib_deps =
  https://github.com/stm32duino/STM32LowPower
  https://github.com/stm32duino/STM32RTC

My code

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

void setup() {
  LowPower.begin();
  Serial.begin(115200);
  Serial.println("serial (same as 1)");
  Serial.println("*****");
}

void loop() {
  unsigned long nowMillis = millis();
  Serial.println(nowMillis);
  //Serial.println("serial printing 2");
  //for(int i=0;i<20;i++) LowPower.deepSleep(1000);
  //for(int i=0;i<10;i++) LowPower.sleep(1000);
  for(int i=0;i<10;i++) LowPower.idle(1000);
  //delay(1000);
}

Problem

millis() does not return the correct time.
idle can stop the clock.

Screen Shot

LowPoert+Millis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.