SapFlow Probe
A low-cost HRM probe for measuring a tree's water consumption
|
Data Structures | |
struct | temperature |
Stores a tuple of temperature values. More... | |
struct | measure_stack |
Holds the persistent variables for a particular tree. More... | |
Functions | |
int | measure (struct pt *pt, struct measure_stack &m) |
Captures a measurement from the three probes. More... | |
int | baseline (struct pt *pt, struct measure_stack &m, char &rdv) |
Calculates baseline temperature. More... | |
int | delta (struct pt *pt, struct measure_stack &m, char &rdv) |
Calculates temperature delta and sapflow. More... | |
double | rtd_calc (int32_t raw) |
Converts raw measurement into degrees Celcius. More... | |
int | mcp3424_measure (struct pt *pt, uint8_t addr, uint8_t channel, int32_t &result) |
Measures the value of a single ADC channel. More... | |
int baseline | ( | struct pt * | pt, |
struct measure_stack & | m, | ||
char & | rdv | ||
) |
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. Don't forget to initialize the control structure in setup(). |
m | Persistent storage for this thread, like a private stack. |
rdv | Rendezvous to ensure all baseline() instances stop at the same point |
References cout(), measure_stack::i, measure_stack::latest, temperature::lower, measure_stack::maxtemp, measure_stack::reference, measure_stack::sem, measure_stack::treeID, and temperature::upper.
Referenced by schedule().
int delta | ( | struct pt * | pt, |
struct measure_stack & | m, | ||
char & | rdv | ||
) |
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. |
m | Persistent storage for this thread, like a private stack. |
rdv | Rendezvous to ensure all delta() instances stop at the same point |
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.
References cout(), measure_stack::flow, measure_stack::i, int2str(), measure_stack::latest, temperature::lower, measure_stack::reference, rtc_ds, measure_stack::sem, measure_stack::treeID, and temperature::upper.
Referenced by schedule().
int mcp3424_measure | ( | struct pt * | pt, |
uint8_t | addr, | ||
uint8_t | channel, | ||
int32_t & | result | ||
) |
Measures the value of a single ADC channel.
pt | A pointer to the protothread control structure |
addr | The 7-bit I2C address of the ADC. If you choose, you can enter only the last three bits (0-7). |
channel | The measurement channel. Valid inputs are 1-4. |
result | The raw 18-bit signed ADC value. Result is bit-extended to 32 bits. |
References CHAN, DEPTH, PGA, and RDY.
Referenced by measure().
int measure | ( | struct pt * | pt, |
struct measure_stack & | m | ||
) |
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 struct paramter "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(). |
m | Persistent storage for this thread, like a private stack. |
References measure_stack::addr, measure_stack::child, cout(), temperature::heater, int2str(), measure_stack::latest, temperature::lower, measure_stack::maxtemp, mcp3424_measure(), measure_stack::raw, rtc_ds, rtd_calc(), measure_stack::sem, measure_stack::treeID, and temperature::upper.
Referenced by loop().
double rtd_calc | ( | int32_t | raw | ) |
Converts raw measurement into degrees Celcius.
raw | The value measured by the ADC |
Referenced by measure().