per-sensor calibration, indicator leds
This commit is contained in:
parent
6fec798425
commit
2470935e11
1 changed files with 91 additions and 73 deletions
62
config.hpp
62
config.hpp
|
|
@ -2,17 +2,26 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
int sensor_pin;
|
||||
int valve_pin;
|
||||
uint8_t pin;
|
||||
/// The value sensors read when completely dry
|
||||
int calibration_dry;
|
||||
/// The value sensors read when completely wet
|
||||
int calibration_wet;
|
||||
} Sensor;
|
||||
|
||||
typedef struct {
|
||||
uint8_t valve_pin;
|
||||
uint8_t led_pin;
|
||||
Sensor sensor;
|
||||
// define additional per-pot config here
|
||||
} PotConfig;
|
||||
|
||||
/// The value sensors read when completely dry
|
||||
constexpr int SENSOR_CALIBRATION_DRY = 520;
|
||||
constexpr unsigned int SECOND = 1000;
|
||||
constexpr unsigned int MINUTE = SECOND * 60;
|
||||
constexpr unsigned int HOUR = MINUTE * 60;
|
||||
|
||||
/// The value sensors read when completely wet
|
||||
constexpr int SENSOR_CALIBRATION_WET = 236;
|
||||
constexpr unsigned int MEASUREMENT_COUNT = 3;
|
||||
constexpr int MEASUREMENT_DELAY = 10;
|
||||
|
||||
/// Pots will always be watered below this humidity
|
||||
constexpr int MIN_HUMIDITY_PERCENT = 10;
|
||||
|
|
@ -21,34 +30,47 @@ constexpr int MIN_HUMIDITY_PERCENT = 10;
|
|||
constexpr int MAX_HUMIDITY_PERCENT = 70;
|
||||
|
||||
/// the amount of time a valve needs to open/close
|
||||
constexpr int VALVE_DELAY_MS = 500;
|
||||
constexpr int VALVE_DELAY_MS = 1 * SECOND;
|
||||
|
||||
/// the amount of time the pump needs to start/stop
|
||||
constexpr int PUMP_DELAY_MS = 1000;
|
||||
constexpr int PUMP_DELAY_MS = 1 * SECOND;
|
||||
|
||||
/// the amount of time to water the plot (valve open and pump running)
|
||||
constexpr int WATER_TIME_MS = 1500;
|
||||
constexpr int WATER_TIME_MS = 3 * SECOND;
|
||||
|
||||
/// how long to wait between loops
|
||||
constexpr int LOOP_DELAY_MS = 1000;
|
||||
constexpr int LOOP_DELAY_MS = 1 * SECOND; // TODO set higher once it is working
|
||||
|
||||
/// minimum amount of time to wait between watering each pot, even when minimum wetness has been reached
|
||||
constexpr int MIN_WATERING_INTERVAL_MS = 1000 * 60; // 1 min
|
||||
constexpr int MIN_WATERING_INTERVAL_MS = 1 * MINUTE;
|
||||
|
||||
/// maximum amount of time to wait between watering each pot, as long as maximum wetness has not been reaached
|
||||
constexpr int MAX_WATERING_INTERVAL_MS = 1000 * 60 * 60 * 24; // 1 day
|
||||
constexpr int MAX_WATERING_INTERVAL_MS = 24 * HOUR;
|
||||
|
||||
constexpr uint8_t PUMP_PIN = 22;
|
||||
constexpr uint8_t PUMP_LED_PIN = 23;
|
||||
|
||||
/// Per-pot configuration
|
||||
constexpr PotConfig POT_CONFIGS[] = {
|
||||
{
|
||||
.name = "Pflanze 1",
|
||||
.sensor_pin = A0,
|
||||
.valve_pin = 23, // TODO
|
||||
.valve_pin = 2,
|
||||
.led_pin = 42,
|
||||
.sensor = {
|
||||
.pin = A0,
|
||||
.calibration_dry = 520,
|
||||
.calibration_wet = 236,
|
||||
}
|
||||
},
|
||||
{
|
||||
.name = "Pflanze 2",
|
||||
.sensor_pin = A1,
|
||||
.valve_pin = 42, // TODO
|
||||
}
|
||||
.valve_pin = 3,
|
||||
.led_pin = 43,
|
||||
.sensor = {
|
||||
.pin = A1,
|
||||
.calibration_dry = 520,
|
||||
.calibration_wet = 236,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
constexpr unsigned int POT_COUNT = sizeof(POT_CONFIGS) / sizeof(POT_CONFIGS[0]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue