SapFlow Probe
A low-cost HRM probe for measuring a tree's water consumption
|
#include "lora.h"
#include <RHReliableDatagram.h>
#include <SPI.h>
#include <RH_RF95.h>
#include <ArduinoJson.h>
#include <ftoa.h>
Go to the source code of this file.
Functions | |
RH_RF95 | rf95 (RFM95_CS, RFM95_INT) |
static RHReliableDatagram | manager (rf95, CLIENT_ADDRESS) |
void | lora_init (void) |
Initialize the LoRa radio. More... | |
void | build_msg (float flow, char *weight, float temp, float maxtemp) |
Builds a JSON string to send over LoRa. More... | |
void | send_msg (void) |
Sends a LoRa packet to the base station. More... | |
Variables | |
static int16_t | packetnum = 0 |
static char | radiopacket [RH_RF95_MAX_MESSAGE_LEN] |
static uint8_t | packet_len |
void build_msg | ( | float | flow, |
char * | weight, | ||
float | temp, | ||
float | maxtemp | ||
) |
Builds a JSON string to send over LoRa.
Builds a JSON string containing sapflow, weight, temperature, time, and tree ID. The string is stored in a global variable to be read by send_msg()
flow | The calculated sapflow |
weight | The text received from the scale. Use "0" if scale is not connected. |
temp | The baseline temperature of the tree |
time | The date and time from the Real-Time Clock |
Definition at line 58 of file lora.cpp.
void lora_init | ( | void | ) |
Initialize the LoRa radio.
This function turns on the radio, sets the frequency, and prepares it for use. It does not take any parameters.
Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
The default transmitter power is 13dBm, using PA_BOOST. If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then you can set transmitter powers from 5 to 23 dBm:
Definition at line 17 of file lora.cpp.
void send_msg | ( | void | ) |
Sends a LoRa packet to the base station.
Sends the string made by build_json() to the base station over LoRa. Calling this function without first calling build_msg() produces undefined behavior.
Definition at line 83 of file lora.cpp.