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
12static const uint8_t Version = 9;
13
15
17static const uint8_t MaxWordLength = 32;
18static const uint8_t MaxShortTextLength = 64;
19static const uint16_t MaxLongTextLength = 256;
20static const uint8_t QueueDepth = 8;
21static const uint8_t MovingAverageDepth = 10;
22
24extern char LongMessage[MaxLongTextLength]; // Temp storage for assembling long messages (REST API - Google Sheets reporting)
25extern char ShortMessage[MaxShortTextLength]; // Temp storage for assembling short messages (Log entries, Error messages)
26extern char CurrentTime[MaxWordLength]; // Buffer for storing current time in text format
27
29static const uint8_t WirelessCSNPin = 9;
30static const uint8_t WirelessCEPin = 10;
31static const uint8_t WirelessChannel[6] = {"Aero1"};
32static const uint8_t WirelessPayloadSize = 32;
33static const uint16_t WirelessMessageTimeout = 500;
34static const uint16_t WirelessReceiveTimeout = 60000;
35
38
39typedef struct
40{
41 bool Debug = true;
42 bool Metric = true;
43
44 //<initialized via Designated initializer https://riptutorial.com/c/example/18609/using-designated-initializers
53 struct AeroponicsModuleSettings Aero1 = {.SerialReportDate = true, .SerialReportMemory = true, .SerialReportJSONFriendly = true, .SerialReportJSON = true, .SerialReportWireless = true};
54
68 struct AeroponicsSettings AeroT1 = {.SpraySolenoidPin = 5, .SpraySolenoidNegativeLogic = true, .SpraySolenoidClosingDelay = 600, .TankDrainingTimeout = 180, .SprayEnabled = true, .Duration = 1.0, .DayInterval = 6, .NightInterval = 10, .MinPressure = 5.0, .MaxPressure = 7.0};
69
71 {
72 uint8_t Pin;
73 float Offset;
74 float Ratio;
75 };
76 struct PressureSensorSettings Pres1 = {.Pin = A7, .Offset = 0.57, .Ratio = 2.7};
77
78 struct SoundSettings
79 {
80 uint8_t Pin;
81 bool Enabled;
82 };
83 struct SoundSettings Sound1 = {.Pin = 2, .Enabled = true};
84
101 struct PressurePumpSettings AeroPump1 = {.PumpPin = 3, .PumpPinNegativeLogic = false, .BypassSolenoidPin = 4, .BypassSolenoidNegativeLogic = true, .BypassSolenoidMaxOpenTime = 180, .BypassSolenoidClosingDelay = 600, .PumpEnabled = true, .Speed = 70, .SpeedLimitLow = 30, .SpeedLimitHigh = 100, .PumpTimeOut = 420, .PrimingTime = 10, .BlowOffTime = 3};
102
103 struct WeightSensorSettings
104 {
105 uint8_t DTPin;
106 uint8_t SCKPin;
107 long Offset;
108 float Scale;
109 };
110 struct WeightSensorSettings Weight1 = {.DTPin = A0, .SCKPin = A1, .Offset = -288069, .Scale = -22280.70};
111
112 uint8_t CompatibilityVersion = Version;
113} Settings;
114
119void saveSettings(Settings *ToSave);
125Settings *loadSettings(bool ResetEEPROM = false);
126void 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
bool SerialReportJSON
Enable/disable sending JSON formatted reports to the Serial output.
Definition Settings.h:50
bool SerialReportJSONFriendly
Enable/disable sending Text formatted reports to the Serial output.
Definition Settings.h:49
bool SerialReportMemory
Enable/disable reporting the remaining free memory to the Serial output.
Definition Settings.h:48
bool SerialReportDate
Enable/disable reporting the current time to the Serial output.
Definition Settings.h:47
bool SerialReportWireless
Enable/disable sending wireless package exchange reports to the Serial output.
Definition Settings.h:51
< Aeroponics_Tank default settings
Definition Settings.h:56
uint16_t DayInterval
Spray every X minutes - When the lights are ON.
Definition Settings.h:63
uint16_t NightInterval
Spray every X minutes - When the lights are OFF.
Definition Settings.h:64
uint16_t TankDrainingTimeout
(sec) How long does it take to fully drain the pressure tank by opening the spray and bypass solenoid...
Definition Settings.h:60
bool SprayEnabled
Enable/disable spraying cycle.
Definition Settings.h:61
uint16_t SpraySolenoidClosingDelay
(ms) Time required for the solenoid to close. To avoid draining the tank the bypass valve is not allo...
Definition Settings.h:59
uint8_t SpraySolenoidPin
Relay controlling DC power to the solenoid.
Definition Settings.h:57
float Duration
Spray time in seconds (Actual duration is ~0.5sec longer due to thread + solenoid delay)
Definition Settings.h:62
bool SpraySolenoidNegativeLogic
true - Relay turns on to LOW signal, false - Relay turns on to HIGH signal
Definition Settings.h:58
float MinPressure
Turn on pump below this pressure.
Definition Settings.h:65
float MaxPressure
Turn off pump above this pressure.
Definition Settings.h:66
< PressurePump default settings
Definition Settings.h:86
uint16_t BypassSolenoidMaxOpenTime
(sec) Max time the bypass can stay open
Definition Settings.h:91
bool PumpPinNegativeLogic
true - Relay turns on to LOW signal, false - Relay turns on to HIGH signal
Definition Settings.h:88
bool BypassSolenoidNegativeLogic
true - Relay turns on to LOW signal, false - Relay turns on to HIGH signal
Definition Settings.h:90
uint16_t PrimingTime
(Sec) For how long to keep the bypass solenoid on when starting the pump - Remove air bubbles from pu...
Definition Settings.h:98
uint8_t PumpPin
Pump relay pin.
Definition Settings.h:87
bool PumpEnabled
Enable/disable pump. false= Block running the pump.
Definition Settings.h:93
uint16_t BlowOffTime
(Sec) For how long to open the bypass solenoid on after turning the pump off - Release pressure from ...
Definition Settings.h:99
uint8_t SpeedLimitHigh
Maximum allowed speed to prevent over-revving.
Definition Settings.h:96
uint8_t BypassSolenoidPin
Bypass solenoid relay pin.
Definition Settings.h:89
uint8_t SpeedLimitLow
Duty cycle limit, does not allow lowering the speed too much. Avoids stalling the motor.
Definition Settings.h:95
uint8_t Speed
Duty cycle of the PWM Motor speed.
Definition Settings.h:94
uint16_t BypassSolenoidClosingDelay
(ms) How long it takes for the solenoid to close
Definition Settings.h:92
uint16_t PumpTimeOut
(Sec) Max pump run time
Definition Settings.h:97
< PressureSensor default settings
Definition Settings.h:71
float Offset
Pressure sensor calibration: voltage reading at 0 pressure.
Definition Settings.h:73
uint8_t Pin
Pressure sensor Pin: Signal(yellow)
Definition Settings.h:72
float Ratio
Pressure sensor voltage to pressure ratio.
Definition Settings.h:74
< WeightSensor default settings
Definition Settings.h:88
uint8_t DTPin
Weight sensor DT pin.
Definition Settings.h:89