Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Example sketch for using sleep mode with Arduino Pico RP2040

License

NotificationsYou must be signed in to change notification settings

matthias-bs/arduino-pico-sleep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Example sketch for using sleep mode (wake-up by RTC) with Arduino Pico RP2040

This example allows to implement a sleep function similar to the ESP32's.See the differences below:

No.TopicESP32RP2040
1Wake-up criterionSleep durationWake-up date & time
2Wake-up behaviourRestart sketchContinue sketch
3RTC reset by restartNoYes
4Retain data during sleep modeRTC RAMYes
5Retain data during restartRTC RAMa) Watchdog scratch registers
b) uninitialized RAM section1
  1. seerp2_common/pico_platform/include/pico/platform.h: Section attribute macro for data that is to be left uninitialized

RP2040 Workarounds/Solutions

  1. Create date and time from epoch, set HW RTCInstead of usingstruct tm,datetime_t has to be used for this.

  2. If the sketch needs to be restartet after wake-up,rp2040.restart() has to be called.

  3. A restart resets the RTC. This is a problem if you are using the RTC for providing time and date.

  4. The RP2040 retains all data during sleep mode - nothing to be done here.

  5. If you only have to keep a few bytes during restart, you can use the watchdog scratch registers. Please note that the bootloader used a few of them too.In the example, the epoch time (variabletime_saved) and a few application variables are retained this way.

RTC Setting / Resynchronization

In an embedded device, you would normally use

  • Internet (NTP)
  • A radio clock signal
  • GPS
  • LoRaWANas the time source for setting the RTC.

In this example, the user is requested to enter date/time via serial console.

Embedded RTCs (or more precisely: their crystal oscillators) tend to have certain inaccuracies which accumulate over time. Therefore it is often desired to resynchronize the RTC to the time source after a certain time (CLOCK_SYNC_INTERVAL). For this purpose, the variablertcLastClockSync is used to keep the timestamp of the last synchronization.

Extras

In some cases, it is useful to align the wake-up time to the wall clock time, e.g. at 5, 10, 15 minutes etc. after the full hour. This should even work with varying run-time after wake-up. The example provides this, too.

Notes

General

Adafruit Feather RP2040

Sleep Mode

Resets

  • ~/.arduino15/packages/rp2040/hardware/rp2040/3.6.0/pico-sdk/src/rp2_common/hardware_resets/include/hardware/resets.h
  • ~/.arduino15/packages/rp2040/hardware/rp2040/3.6.0/pico-sdk/src/rp2040/hardware_regs/include/hardware/regs/resets.h
  • ~/.arduino15/packages/rp2040/hardware/rp2040/3.6.0/pico-sdk/src/rp2040/hardware_structs/include/hardware/structs/vreg_and_chip_reset.h
  • Arduino Nano RP2040 Connect - determine reason for reset / read rp2040 chip_reset register - SOLVED - Nano Family / Nano RP2040 Connect - Arduino Forum
  • restart()/reboot():
    • ~/.arduino15/packages/rp2040/hardware/rp2040/3.6.0/cores/rp2040/RP2040Support.h
    • ~/.arduino15/packages/rp2040/hardware/rp2040/3.6.0/pico-sdk/src/rp2_common/hardware_watchdog/watchdog.c
    • bool watchdog_caused_reboot(void);
      • ~/.arduino15/packages/rp2040/hardware/rp2040/3.6.0/pico-sdk/src/rp2_common/hardware_watchdog/include/hardware/watchdog.h

RTC

About

Example sketch for using sleep mode with Arduino Pico RP2040

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp