Gbox 4.20
Grow box automation and monitoring - <a href='https://sites.google.com/site/growboxguy/'>https://sites.google.com/site/growboxguy/</a>
 
Loading...
Searching...
No Matches
Settings.h
Go to the documentation of this file.
1#pragma once
2
12constexpr uint8_t Version = 17;
13
15
17constexpr uint8_t MaxWordLength = 32;
18constexpr uint8_t MaxShortTextLength = 64;
19constexpr uint16_t MaxLongTextLength = 168;
20constexpr uint8_t QueueDepth = 6;
21
23extern char LongMessage[MaxLongTextLength]; // Temp storage for assembling long messages (REST API - Google Sheets reporting)
24extern char ShortMessage[MaxShortTextLength]; // Temp storage for assembling short messages (Log entries, Error messages)
25extern char CurrentTime[MaxWordLength]; // Buffer for storing current time in text format
26
28constexpr uint8_t WirelessCSNPin = 9;
29constexpr uint8_t WirelessCEPin = 10;
30constexpr uint8_t WirelessChannel[6] = {"Hemp1"};
31constexpr uint8_t WirelessPayloadSize = 32;
32constexpr uint16_t WirelessMessageTimeout = 500;
33constexpr uint16_t WirelessReceiveTimeout = 60000;
34
37
38typedef struct
39{
40 bool Debug = true;
41 bool Metric = true;
42
43 // initialized via Designated initializer https://riptutorial.com/c/example/18609/using-designated-initializers
44 struct HempyModuleSettings
45 {
51 };
52 struct HempyModuleSettings Hemp1 = {.SerialReportDate = true, .SerialReportMemory = true, .SerialReportJSONFriendly = true, .SerialReportJSON = true, .SerialReportWireless = true};
53
55 {
57 float EvaporationTarget; //< (kg/lbs) Amount of water that should evaporate before starting the watering cycles
58 float MaxWeight;
62 uint16_t DrainWaitTime;
63 };
64 struct HempyBucketSettings Bucket1 = {.DisabledState = false, .EvaporationTarget = 2.0, .MaxWeight = 20.0, .StartWeight = 18.0, .WateringIncrement = 0.3, .DrainTargetWeight = 0.1, .DrainWaitTime = 180};
65 struct HempyBucketSettings Bucket2 = {.DisabledState = false, .EvaporationTarget = 2.0, .MaxWeight = 20.0, .StartWeight = 18.0, .WateringIncrement = 0.3, .DrainTargetWeight = 0.1, .DrainWaitTime = 180};
66
67 struct SoundSettings
68 {
69 uint8_t Pin;
70 bool Enabled;
71 };
72 struct SoundSettings Sound1 = {.Pin = 2, .Enabled = true};
73
75 {
76 uint8_t PumpPin;
79 uint16_t PumpTimeOut;
80 uint8_t Speed;
81 uint8_t SpeedLimitLow;
83 };
84 struct WaterPumpSettings HempyPump1 = {.PumpPin = 3, .PumpPinNegativeLogic = false, .PumpEnabled = true, .PumpTimeOut = 20, .Speed = 100, .SpeedLimitLow = 30, .SpeedLimitHigh = 100};
85 struct WaterPumpSettings HempyPump2 = {.PumpPin = 5, .PumpPinNegativeLogic = false, .PumpEnabled = true, .PumpTimeOut = 20, .Speed = 100, .SpeedLimitLow = 30, .SpeedLimitHigh = 100};
86
88 {
89 uint8_t DTPin;
90 uint8_t SCKPin;
91 long Offset;
92 float Scale;
93 };
94 struct WeightSensorSettings WeightB1 = {.DTPin = 4, .SCKPin = 6, .Offset = -176962, .Scale = -22654.00};
95 struct WeightSensorSettings WeightB2 = {.DTPin = 7, .SCKPin = 8, .Offset = 377473, .Scale = -21506.86};
96
97 uint8_t CompatibilityVersion = Version;
98} Settings;
99
104void saveSettings(Settings *ToSave);
110Settings *loadSettings(bool ResetEEPROM = false);
111void restoreDefaults();
Settings * loadSettings(bool ResetEEPROM=false)
Load settings from EEPROM.
Definition Settings.cpp:20
void restoreDefaults()
Load sketch default settings into EEPROM.
Definition Settings.cpp:45
char CurrentTime[MaxWordLength]
Buffer for storing current time in text format.
char LongMessage[MaxLongTextLength]
Temp storage for assembling long messages (REST API, MQTT reporting, Serial reporting,...
void saveSettings(Settings *ToSave)
Store settings in EEPROM - Only updates changed bits.
Definition Settings.cpp:10
char ShortMessage[MaxShortTextLength]
Temp storage for assembling short text messages (Log entries, Error messages,..etc)
bool & Debug
True - Turns on extra debug messages on the Serial Output.
bool & Metric
True - Use metric units, False - Use imperial units.
constexpr uint8_t Version
Default Settings for each component within the module. Loaded when the Arduino starts.
Definition Settings.h:12
constexpr uint16_t WirelessMessageTimeout
(ms) One package should be exchanged within this timeout (Including retries and delays)
Definition Settings.h:32
constexpr uint8_t WirelessPayloadSize
Size of the wireless packages exchanged with the Main module. Max 32 bytes are supported on nRF24L01+...
Definition Settings.h:31
constexpr uint8_t WirelessCEPin
nRF24l01+ wireless transmitter CE pin - Pre-connected on RF-Nano
Definition Settings.h:29
constexpr uint8_t QueueDepth
Limits the maximum number of active modules. Memory intense!
Definition Settings.h:20
constexpr uint8_t MaxShortTextLength
Default char * buffer length for storing mutiple words. Memory intense!
Definition Settings.h:18
constexpr uint8_t MaxWordLength
Default char * buffer length for storing a word + null terminator. Memory intense!
Definition Settings.h:17
constexpr uint16_t MaxLongTextLength
Default char * buffer length for storing a long text. Memory intense!
Definition Settings.h:19
constexpr uint16_t WirelessReceiveTimeout
(ms) If no packages are received from the Main module over this limit, try reseting the nRF24L01+ wir...
Definition Settings.h:33
constexpr uint8_t WirelessCSNPin
< nRF24L01+ wireless receiver
Definition Settings.h:28
constexpr uint8_t WirelessChannel[6]
This needs to be unique and match with the Name of the HempyModule_Web object in the MainModule_Web....
Definition Settings.h:30
< HempyBucket default settings
Definition Settings.h:55
float WateringIncrement
How much water to pump in one cycle, then wait for DrainWaitTime seconds before either starting a new...
Definition Settings.h:60
float DrainTargetWeight
(kg/lbs) Amount of water that should go to the waste reservoir after a watering cycle
Definition Settings.h:61
bool DisabledState
Store if the watering logic is disabled.
Definition Settings.h:56
float MaxWeight
Waste reservoir full weight -> Pump gets disabled if reached.
Definition Settings.h:58
uint16_t DrainWaitTime
(sec) How long to wait after watering for the water to drain
Definition Settings.h:62
float StartWeight
(kg/lbs) When the module starts up start watering if Bucket weight is below this. Set to 0 to instant...
Definition Settings.h:59
< Hempy default settings
Definition Settings.h:138
bool SerialReportJSONFriendly
Enable/disable sending Text formatted reports to the Serial output.
Definition Settings.h:48
bool SerialReportWireless
Enable/disable sending wireless package exchange reports to the Serial output.
Definition Settings.h:50
bool SerialReportJSON
Enable/disable sending JSON formatted reports to the Serial output.
Definition Settings.h:49
bool SerialReportDate
Enable/disable reporting the current time to the Serial output.
Definition Settings.h:46
bool SerialReportMemory
Enable/disable reporting the remaining free memory to the Serial output.
Definition Settings.h:47
< WaterPump default settings
Definition Settings.h:75
uint8_t Speed
Duty cycle of the PWM Motor speed.
Definition Settings.h:80
bool PumpEnabled
Enable/disable pump. false= Block running the pump.
Definition Settings.h:78
uint16_t PumpTimeOut
(Sec) Max pump run time (one watering cycle)
Definition Settings.h:79
uint8_t SpeedLimitHigh
Duty cycle limit, does not allow raising the speed too high.
Definition Settings.h:82
bool PumpPinNegativeLogic
true - Relay turns on to LOW signal, false - Relay turns on to HIGH signal
Definition Settings.h:77
uint8_t PumpPin
Pump relay pin.
Definition Settings.h:76
uint8_t SpeedLimitLow
Duty cycle limit, does not allow lowering the speed too much. Avoids stalling the motor.
Definition Settings.h:81
< WeightSensor default settings
Definition Settings.h:88
float Scale
Scale factor.
Definition Settings.h:92
uint8_t DTPin
Weight sensor DT pin.
Definition Settings.h:89
long Offset
Reading at 0 weight on the scale.
Definition Settings.h:91
uint8_t SCKPin
Weight sensor SCK pin.
Definition Settings.h:90