SapFlow Probe
A low-cost HRM probe for measuring a tree's water consumption
|
Go to the documentation of this file.
11 Serial.println(
"Initialized timer thread");
17 PT_TIMER_DELAY(pt,1000);
25 Serial.print(
"Initializing measurement thread... ");
26 static Adafruit_MAX31865 upper_rtd = Adafruit_MAX31865(
UPPER_CS);
27 static Adafruit_MAX31865 lower_rtd = Adafruit_MAX31865(
LOWER_CS);
28 static Adafruit_MAX31865 heater_rtd = Adafruit_MAX31865(
HEATER_CS);
29 upper_rtd.begin(MAX31865_2WIRE);
30 lower_rtd.begin(MAX31865_2WIRE);
31 heater_rtd.begin(MAX31865_2WIRE);
32 Serial.println(
"Done");
51 cout <<
" Time: " << t.text() << endl;
MARK();
53 ofstream logfile = ofstream(
"demo_log.csv",
54 ios::out | ios::app );
MARK();
55 logfile << t.text() <<
", ";
MARK();
59 logfile.close();
MARK();
68 Serial.print(
"Initializing baseline thread... ");
75 Serial.println(
"Done");
77 for(i = 0; i < 10; ++i){
MARK();
94 Serial.print(
"Initializing delta thread... ");
100 Serial.println(
"Done");
112 for(i = 0; i < 40; ++i ){
MARK();
118 cout <<
"Delta: " << udelt <<
", " << ldelt << endl;
MARK();
120 flow += udelt / ldelt;
122 cout<<
"Finished measurements."<<endl;
MARK();
125 flow = log(flow) * (3600.*2e-6/7e-3);
MARK();
127 cout<<
"Flow is "<<flow<<endl;
MARK();
129 ofstream sapfile = ofstream(
"demo.csv", ios::out | ios::app);
MARK();
134 cout << flow <<
", " << endl;
MARK();
137 sapfile.close();
MARK();
float heater
Temperature (Celcius) at the heater probe.
void send_msg(void)
Sends a LoRa packet to the base station.
static RTC_DS3231 rtc_ds
Instance of our real-time clock.
int sample_timer(struct pt *pt)
Controls timing of the measurements.
float upper
Temperature (Celcius) at the upper probe.
static bool sample_trigger
global flag for synchronizing live data processing. Set by sample_timer()
void lora_init(void)
Initialize the LoRa radio.
@ HEATER_CS
Heater RTD amplifier chip select. Output.
static struct temperature reference
The baseline temperature reading, computed by the baseline() protothread.
int measure(struct pt *pt)
Captures a measurement from the three probes.
float lower
Temperature (Celcius) at the lower probe.
static ArduinoOutStream cout(Serial)
Allows use of streams to print to Serial via cout.
int baseline(struct pt *pt)
Calculates baseline temperature.
#define Rref
Nominal reference resistor in ohms.
#define MARK()
This macro records the line number and function name.
@ UPPER_CS
Upper RTD amplifier chip select. Output.
#define Rnom
Nominal RTD resistance in ohms.
static struct temperature latest
The most recent temperature reading, measured by the measure() protothread.
int delta(struct pt *pt)
Calculates temperature delta and sapflow.
@ LOWER_CS
Lower RTD amplifier chip select. Output.
void build_msg(float flow, char *weight, float temp, float maxtemp)
Builds a JSON string to send over LoRa.