SapFlow Probe
A low-cost HRM probe for measuring a tree's water consumption
|
Go to the documentation of this file.
10 detachInterrupt(digitalPinToInterrupt(
ALARM_PIN));
17 Serial.print(
"Waiting on alarm pin...");
23 pinMode(
SD_CS, INPUT);
25 digitalWrite(
EN_3v3, HIGH);
26 digitalWrite(
EN_5v, LOW);
28 Serial.println(
"Sleeping");
57 digitalWrite(
EN_5v, HIGH);
68 Serial.print(
"Sleeping until nearest multiple of ");
69 Serial.print(interval);
70 Serial.println(
" minutes");
MARK();
72 t = t + TimeSpan( interval * 60 );
MARK();
73 uint8_t minutes = interval*(t.minute()/interval);
MARK();
74 rtc_ds.setAlarm(ALM2_MATCH_MINUTES, minutes, 0, 0);
MARK();
75 Serial.print(
"Alarm set to ");
MARK();
77 Serial.println(t.text());
MARK();
84 Serial.print(
"Initializing schedule thread... ");
87 Serial.println(
"Couldn't find RTC");
91 Serial.println(
"RTC lost power, lets set the time!");
93 rtc_ds.adjust(DateTime(F(__DATE__), F(__TIME__)));
95 Serial.println(
"Done");
99 Serial.print(
"Awoke at ");
MARK();
103 Serial.print(
"Heater On at ");
MARK();
105 PT_TIMER_DELAY(pt,6000);
MARK();
107 Serial.print(
"Heater Off at ");
MARK();
109 PT_TIMER_DELAY(pt,100);
MARK();
110 Serial.println(
"Temperature probably reached plateau");
MARK();
112 Serial.println(
"Finished logging");
MARK();
@ EN_5v
Control pin for 5v Power rail. Output, Active-high.
@ STATUS_LED
Built-in LED on feather. Active-high.
void sleep_cycle(int interval)
Sleep function for periodic sleeping.
@ EN_3v3
Control pin for 3.3V power rail. Output, Active-low.
static RTC_DS3231 rtc_ds
Instance of our real-time clock.
@ SPI_MOSI
SPI data pin. Output.
void alarmISR()
Interrupt handler for RTC alarm.
void feather_sleep(void)
Maximizes power savings during sleep.
void print(void)
Prints the most recently recorded value.
void resume(void)
Re-enable the watchdog. You should do this right after waking from sleep.
int baseline(struct pt *pt)
Calculates baseline temperature.
void pause(void)
Pause the watchdog. You'll want to do this before sleeping.
static SdFat sd
File system object.
@ HEATER
Control pin for heater switch. Output, Active-high.
#define MARK()
This macro records the line number and function name.
static class FunctionMarker halt_location
Singleton of our debug class.
int delta(struct pt *pt)
Calculates temperature delta and sapflow.
bool read(void)
Read the recorded value from flash.
int schedule(struct pt *pt)
Controls general measurement schedule.
static bool sleep
Global flag to prep for sleep.
@ SPI_SCK
SPI clock pin. Output.
@ ALARM_PIN
Interrupt pin from RTC. Pull-up, Active-low.
@ SD_CS
SPI chip select for SD card. Output, Active-low.