SapFlow Probe
A low-cost HRM probe for measuring a tree's water consumption
sleep.h File Reference
#include <OPEnS_RTC.h>
#include <LowPower.h>
#include "pinout.h"

Functions

void alarmISR (void)
 Interrupt handler for RTC alarm. More...
 
void feather_sleep (void)
 Maximizes power savings during sleep. More...
 
void sleep_cycle (int interval=5)
 Sleep function for periodic sleeping. More...
 

Variables

static RTC_DS3231 rtc_ds
 Instance of our real-time clock.
 

Function Documentation

◆ alarmISR()

void alarmISR ( void  )

Interrupt handler for RTC alarm.

Called when the feather wakes up from sleep. Disables the RTC interrupt.

References ALARM_PIN, and rtc_ds.

Referenced by feather_sleep().

◆ feather_sleep()

void feather_sleep ( void  )

Maximizes power savings during sleep.

Steps for going to sleep:

  1. Attach interrupt to RTC pin
  2. Disconnect from the SD card
  3. Disconnect from Serial and USB
  4. Turn off power rails and status LED
  5. Begin deep sleep

Steps for waking up:

  1. Attach USB and Serial
  2. Turn on power rails and status LED
  3. Open SD card

References ALARM_PIN, alarmISR(), hardware_deinit(), and hardware_init().

Referenced by sleep_cycle().

◆ sleep_cycle()

void sleep_cycle ( int  interval = 5)

Sleep function for periodic sleeping.

Sleep until the time is a round multiple of the minute inteval. Produces unexpected bevahior for non-factors of 60 (7, 8, 9, 11, etc). For example, if it's 5:39 and you select an interval of 15, the microcontroller will wake up at 5:45, since 3*15 = 45. This function internally calls feather_sleep() to handle prep and resume from sleeping

Parameters
intervalThe increment to sleep for.

References feather_sleep(), and rtc_ds.

Referenced by schedule().