SapFlow Probe
A low-cost HRM probe for measuring a tree's water consumption
|
#include "pinout.h"
#include "schedule.h"
#include "sd_log.h"
#include "debug.h"
#include <Adafruit_MAX31865.h>
Go to the source code of this file.
Data Structures | |
struct | temperature |
Stores a tuple of temperature values. More... | |
Macros | |
#define | Rnom 100.0 |
Nominal RTD resistance in ohms. | |
#define | Rref 430.0 |
Nominal reference resistor in ohms. | |
Functions | |
int | measure (struct pt *pt=&measure_thd) |
Captures a measurement from the three probes. More... | |
int | sample_timer (struct pt *pt=&sample_timer_thd) |
Controls timing of the measurements. More... | |
int | baseline (struct pt *pt=&baseline_thd) |
Calculates baseline temperature. More... | |
int | delta (struct pt *pt=&delta_thd) |
Calculates temperature delta and sapflow. More... | |
Variables | |
static bool | sample_trigger |
global flag for synchronizing live data processing. Set by sample_timer() | |
static struct temperature | latest |
The most recent temperature reading, measured by the measure() protothread. | |
static struct temperature | reference |
The baseline temperature reading, computed by the baseline() protothread. | |
static struct pt | measure_thd |
Protothread control structure for measure() | |
static struct pt | sample_timer_thd |
Protothread control structure for sample_timer() | |
static struct pt | baseline_thd |
Protothread control structure for baseline() | |
static struct pt | delta_thd |
Protothread control structure for delta() | |
int baseline | ( | struct pt * | pt = &baseline_thd | ) |
Calculates baseline temperature.
This is a protothread that averages 10 samples of data to determine the "initial" or "baseline" temperature of the tree. It should be used before the heater is turned on.
pt | A pointer to the protothread control structure. The default parameter is correct. Don't forget to initialize the control structure in setup(). |
Definition at line 65 of file measure.cpp.
int delta | ( | struct pt * | pt = &delta_thd | ) |
Calculates temperature delta and sapflow.
This is a protothread that calculates the sap flow by averaging measurements over 40 seconds. It also calls other functions to get the weight, package the data, log to an SD card, and send the information over LoRa.
pt | A pointer to the protothread control structure. The default parameter is correct. Don't forget to initialize the control structure in setup(). |
We compute sapflow using the following formula:: sapflow = k / x * log(v1 / v2) / 3600
In order to get a smoother result, we are takng the average of this calculation over a period of 40 seconds. Burges et. al. (2001) suggests that this value should converge.
Definition at line 91 of file measure.cpp.
int measure | ( | struct pt * | pt = &measure_thd | ) |
Captures a measurement from the three probes.
This is a protothread that reads the temperature from three RTD amplifiers connected to the probes in the tree. It stores the result in the global variable "latest", and logs to the SD card.
pt | A pointer to the protothread control structure. The default parameter is correct. Don't forget to initialize the control structure in setup(). |
Definition at line 22 of file measure.cpp.
int sample_timer | ( | struct pt * | pt = &sample_timer_thd | ) |
Controls timing of the measurements.
This is a protothread that creates a pulse every second on the global variable sample_trigger in order to sychronize sample-based processing. Protothreads that sample or process sampled data can latch this signal using PT_WAIT_UNTIL(pt, sample_trigger); PT_WAIT_WHILE(pt, sample_trigger); to synchronize execution without impacting the sample frequency.
pt | A pointer to the protothread control structure. The default parameter is correct. Don't forget to initialize the control structure in setup(). |
Definition at line 8 of file measure.cpp.