• Twitter
  • Youtube
Rocket Scream
  • Blog
  • Shop
    • Arduino and Compatibles
      • Mini Ultra Series
      • osPID
    • Component
      • Connector
      • Interconnect & Cables
      • Wires
      • Sensors
        • Temperature
    • Wireless
      • Antenna
      • Module
  • Forums
  • Docs
  • Contact
  • About
  • My Account
  • Search
  • Menu Menu
  • 0Shopping Cart

Using RTC in Low Power Mode on Mini Ultra Pro

You are here: Home1 / Docs2 / Using RTC in Low Power Mode on Mini Ultra Pro
Overview

One of the most powerful feature of RTC is the ability to run in the lowest power mode possible on the ATSAMD21G18A-AU microcontroller. This allow the Mini Ultra Pro board to reside in ultra low power mode (21 µA or less of current only!) majority of the time and wake up upon alarm triggered by the RTC to perform scheduled tasks (sensor reading, data logging, radio communication, driving an actuator, etc).

Putting everything to sleep

Putting the Mini Ultra Pro into sleep mode (known as standby mode on the ATSAMD21 microcontroller series) will essentially stopping the main clock from running (which is also used to derived other clocks to drive peripherals). The important aspect of putting the Mini Ultra Pro into low power mode (a.k.a. sleep) is more than putting the microcontroller into standby mode. Identifying circuit components that could be driving excessive amount of current even when not in use is one of the crucial point to achieve the 21 μA or less of sleep current.

The following are the list of components on the Mini Ultra Pro that we need to take care of in order to achieve the low power current consumption in μA range.

  1. Radio module – either RFM95W or RFM69HCW:
    • Both radio module can be put into sleep mode and only draws 0.1 μA of current
  2. Serial flash – S25FL116K0XMFI041 16 Mbit (2 MByte):
    • The serial flash can be put into sleep mode and only draws 2 μA of current
  3. USB core of ATSAMD21G18A:
    • USB bus must be in idle mode and in suspend condition in order to achieve low current mode
  4. Pins not in use on the Mini Ultra Pro:
    • Pins that are not connected to any circuitry should be put into a defined state and not left floating

In this example, the RTC is configured to run in the background and an alarm is setup to wake up the microcontroller every 1 minute. Of course, this wake up interval can be configured as required by the application. The LED connected to pin D13 is toggle to indicate the sleep and wake up event. A Li-Ion/Pol 3.7 V is used to power the setup.

Important

Take note that a 15 s delay in the beginning of the example is defined to provide ample amount of time for user to upload code before the USB device module detaches itself from the host. Once the Mini Ultra Pro board goes into low power mode, the PC will not be able to detect the USB serial port of the board unless the reset tact switch is press.

The measured current during sleep mode using the example code will result in 21 μA of sleep current. The bulk of the 21 μA is contributed by the on-board battery power management IC (BQ24074) but it is crucial to have a proper Li-Ion/Pol battery power management like the BQ24074 is avoid shorter lifespan of the battery due to unnecessary charge and discharge cycle.

/*******************************************************************************
 Mini Ultra Pro Sleep RTC Alarm
 Version: 0.10
 Date: 20-02-2017
 Company: Rocket Scream Electronics
 Author: Lim Phang Moh
 Website: www.rocketscream.com

 An example code demonstrating the ultra low sleep current capability of the 
 Mini Ultra Pro while running the on-chip built-in RTC. Example puts the Mini
 Ultra Pro into standby mode (sleep) while RTC is allowed to run in the 
 background. Alarm is set to wake the processor on the 15 s of a minute.
 This results in sleep period of 1 minute. The LED on pin 13 is set to toggle
 on every alarm match state. In sleep state with the built-in LED turn off, 
 current measured is approximately 21.0 uA.

 Requirement:
 1. Mini Ultra Pro board powered by a single cell Li-Ion/Pol 3.7V battery.

 Important Note:
 1. Upon using the SerialFlash.sleep() function, the only function that the 
 serial flash chip response to is SerialFlash.wakeup(). 

 Revision Description
 ======== ===========
 0.10 Initial public release.
*******************************************************************************/

#include <SerialFlash.h>
#include <RTCZero.h>
#include <SPI.h>
#include <RH_RF95.h>
//#include <RH_RF69.h>

// ***** CONSTANTS *****
const int radioDio0 = 2;
const int flashChipSelect = 4;
const int radioChipSelect = 5;

// Choose correct on-board radio
RH_RF95 radio(radioChipSelect, radioDio0);
//RH_RF69 radio(radioChipSelect, radioDio0);
RTCZero rtc;

/* Change these values to set the current initial time */
const uint8_t seconds = 0;
const uint8_t minutes = 00;
const uint8_t hours = 10;

/* Change these values to set the current initial date */
const uint8_t day = 20;
const uint8_t month = 2;
const uint8_t year = 17;

// ***** VARIABLES *****
unsigned char pinNumber;

void setup()
{
 // Switch unused pins as input and enabled built-in pullup 
 for (pinNumber = 0; pinNumber < 23; pinNumber++)
 {
 pinMode(pinNumber, INPUT_PULLUP);
 }

 for (pinNumber = 32; pinNumber < 42; pinNumber++)
 {
 pinMode(pinNumber, INPUT_PULLUP);
 }

 pinMode(25, INPUT_PULLUP);
 pinMode(26, INPUT_PULLUP);

 if (!radio.init()){}
 radio.sleep();
 
 SerialFlash.begin(flashChipSelect);
 SerialFlash.sleep();

 pinMode(LED_BUILTIN, OUTPUT);
 
 digitalWrite(LED_BUILTIN, HIGH);

 // ***** IMPORTANT DELAY FOR CODE UPLOAD BEFORE USB PORT DETACH DURING SLEEP *****
 delay(15000);

 //***** UNCOMMENT FOR MINI ULTRA PRO VERSION 0V30 & ABOVE IF PINS ARE CONNECTED TO RADIO ****
 /*pinMode(6, INPUT);
 pinMode(7, INPUT);
 digitalWrite(3, HIGH);
 pinMode(3, OUTPUT);
 digitalWrite(3, HIGH);*/
 //*****

 // RTC initialization
 rtc.begin();
 rtc.setTime(hours, minutes, seconds);
 rtc.setDate(day, month, year);

 // RTC alarm setting on every 15 s resulting in 1 minute sleep period
 rtc.setAlarmSeconds(15);
 rtc.enableAlarm(rtc.MATCH_SS);
 rtc.attachInterrupt(alarmMatch);
 
 digitalWrite(LED_BUILTIN, LOW);
 USBDevice.detach();
 rtc.standbyMode();
}

void loop()
{
 // Initialize USB and attach to host (not required if not in use)
 USBDevice.init();
 USBDevice.attach();
 
 digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));

 // Detach USB from host (not required if not in use)
 USBDevice.detach();
 
 // Sleep until next alarm match
 rtc.standbyMode();
}

void alarmMatch()
{

}

Follow us on Twitter

Tweets by rocketscream

Subscribe to our newsletter

Information

  • About
  • Contact
  • Covid-19 Shipment Update
  • Ordering Info
  • Returns
  • Shipping Info
© Copyright - Rocket Scream Electronics
  • Twitter
  • Youtube
Using Real Time Clock (RTC) with Mini Ultra ProUsing Mini Ultra Pro with The Things Network (TTN)
Scroll to top

This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.

OK

Cookie and Privacy Settings



How we use cookies

We may request cookies to be set on your device. We use cookies to let us know when you visit our websites, how you interact with us, to enrich your user experience, and to customize your relationship with our website.

Click on the different category headings to find out more. You can also change some of your preferences. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.

Essential Website Cookies

These cookies are strictly necessary to provide you with services available through our website and to use some of its features.

Because these cookies are strictly necessary to deliver the website, refusing them will have impact how our site functions. You always can block or delete cookies by changing your browser settings and force blocking all cookies on this website. But this will always prompt you to accept/refuse cookies when revisiting our site.

We fully respect if you want to refuse cookies but to avoid asking you again and again kindly allow us to store a cookie for that. You are free to opt out any time or opt in for other cookies to get a better experience. If you refuse cookies we will remove all set cookies in our domain.

We provide you with a list of stored cookies on your computer in our domain so you can check what we stored. Due to security reasons we are not able to show or modify cookies from other domains. You can check these in your browser security settings.

Google Analytics Cookies

These cookies collect information that is used either in aggregate form to help us understand how our website is being used or how effective our marketing campaigns are, or to help us customize our website and application for you in order to enhance your experience.

If you do not want that we track your visit to our site you can disable tracking in your browser here:

Other external services

We also use different external services like Google Webfonts, Google Maps, and external Video providers. Since these providers may collect personal data like your IP address we allow you to block them here. Please be aware that this might heavily reduce the functionality and appearance of our site. Changes will take effect once you reload the page.

Google Webfont Settings:

Google Map Settings:

Google reCaptcha Settings:

Vimeo and Youtube video embeds:

Other cookies

The following cookies are also needed - You can choose if you want to allow them:

Privacy Policy

You can read about our cookies and privacy settings in detail on our Privacy Policy Page.

Privacy Policy
Accept settingsHide notification only