config working sensors

This commit is contained in:
Vinzenz Schroeter 2025-05-27 12:04:06 +02:00
parent 0523250906
commit 794c17052f

View file

@ -2,6 +2,7 @@
#include <Arduino.h> #include <Arduino.h>
typedef struct { typedef struct {
/// Which analog pin this is connected to (A0, A1, ...)
uint8_t pin; uint8_t pin;
/// The value sensors read when completely dry /// The value sensors read when completely dry
int calibration_dry; int calibration_dry;
@ -36,10 +37,10 @@ constexpr int VALVE_DELAY_MS = 1 * SECOND / 4;
constexpr int PUMP_DELAY_MS = 1 * SECOND / 4; constexpr int PUMP_DELAY_MS = 1 * SECOND / 4;
/// the amount of time to water the plot (valve open and pump running) /// the amount of time to water the plot (valve open and pump running)
constexpr int WATER_TIME_MS = 1 * SECOND / 4; constexpr int WATER_TIME_MS = 1 * SECOND;
/// how long to wait between loops /// how long to wait between loops
constexpr int LOOP_DELAY_MS = 1 * SECOND; 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 /// minimum amount of time to wait between watering each pot, even when minimum wetness has been reached
constexpr int MIN_WATERING_INTERVAL_MS = 10 * SECOND; // TODO set higher once it is working constexpr int MIN_WATERING_INTERVAL_MS = 10 * SECOND; // TODO set higher once it is working
@ -63,33 +64,33 @@ constexpr PotConfig POT_CONFIGS[] = {
.calibration_wet = 250, .calibration_wet = 250,
} }
}, },
{ //{
.valve_pin = 25, // .valve_pin = 25,
.led_pin = 24, // .led_pin = 24,
.sensor = { // .sensor = {
.pin = A1, // .pin = A1,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
{ //{
.valve_pin = 27, // .valve_pin = 27,
.led_pin = 26, // .led_pin = 26,
.sensor = { // .sensor = {
.pin = A2, // .pin = A2,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
{ //{
.valve_pin = 29, // .valve_pin = 29,
.led_pin = 28, // .led_pin = 28,
.sensor = { // .sensor = {
.pin = A3, // .pin = A3,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
{ {
.valve_pin = 31, .valve_pin = 31,
.led_pin = 30, .led_pin = 30,
@ -99,42 +100,42 @@ constexpr PotConfig POT_CONFIGS[] = {
.calibration_wet = 100, .calibration_wet = 100,
} }
}, },
{ //{
.valve_pin = 33, // .valve_pin = 33,
.led_pin = 32, // .led_pin = 32,
.sensor = { // .sensor = {
.pin = A5, // .pin = A5,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
{ //{
.valve_pin = 35, // .valve_pin = 35,
.led_pin = 34, // .led_pin = 34,
.sensor = { // .sensor = {
.pin = A6, // .pin = A6,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
{ //{
.valve_pin = 37, // .valve_pin = 37,
.led_pin = 36, // .led_pin = 36,
.sensor = { // .sensor = {
.pin = A7, // .pin = A7,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
{ //{
.valve_pin = 39, // .valve_pin = 39,
.led_pin = 38, // .led_pin = 38,
.sensor = { // .sensor = {
.pin = A8, // .pin = A8,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
{ {
.valve_pin = 41, .valve_pin = 41,
.led_pin = 40, .led_pin = 40,
@ -144,24 +145,24 @@ constexpr PotConfig POT_CONFIGS[] = {
.calibration_wet = 100, .calibration_wet = 100,
} }
}, },
{ //{
.valve_pin = 43, // .valve_pin = 43,
.led_pin = 42, // .led_pin = 42,
.sensor = { // .sensor = {
.pin = A10, // .pin = A10,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
{ //{
.valve_pin = 45, // .valve_pin = 45,
.led_pin = 44, // .led_pin = 44,
.sensor = { // .sensor = {
.pin = A11, // .pin = A11,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
{ {
.valve_pin = 47, .valve_pin = 47,
.led_pin = 46, .led_pin = 46,
@ -180,25 +181,24 @@ constexpr PotConfig POT_CONFIGS[] = {
.calibration_wet = 100, .calibration_wet = 100,
} }
}, },
{ //{
.valve_pin = 51, // .valve_pin = 51,
.led_pin = 50, // .led_pin = 50,
.sensor = { // .sensor = {
.pin = A14, // .pin = A14,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
{ //{
.valve_pin = 53, // .valve_pin = 53,
.led_pin = 52, // .led_pin = 52,
.sensor = { // .sensor = {
.pin = A15, // .pin = A15,
.calibration_dry = 520, // .calibration_dry = 520,
.calibration_wet = 100, // .calibration_wet = 100,
} // }
}, //},
}; };
constexpr unsigned int POT_COUNT = sizeof(POT_CONFIGS) / sizeof(POT_CONFIGS[0]); constexpr unsigned int POT_COUNT = sizeof(POT_CONFIGS) / sizeof(POT_CONFIGS[0]);