Renamed constants
This commit is contained in:
parent
6da0e0268e
commit
284fb4907d
@ -74,3 +74,12 @@ DS18B20 one wire temp sensor
|
||||
* Deepsleep verboten (MQTT topic, retained)
|
||||
* alle Pumpen & Sensoren deaktiviert
|
||||
|
||||
## Masterplan 2.0
|
||||
* ESP heruntertakten Mhz heruntertakten
|
||||
* kein WLAN
|
||||
* Bewässerung muss immer laufen
|
||||
* Timeout um nicht ewig aufs WLAN zu warten
|
||||
* Nicht mehrere Messungen vom Temp-Sensor nur warten, bis wir einen Wert bekommen
|
||||
* Partitionslayout
|
||||
|
||||
|
||||
|
@ -43,21 +43,9 @@
|
||||
*/
|
||||
#ifndef CONTROLLER_CONFIG_H
|
||||
#define CONTROLLER_CONFIG_H
|
||||
/** \addtogroup Configuration
|
||||
/** \addtogroup GPIO Settings
|
||||
* @{
|
||||
*/
|
||||
#define FIRMWARE_VERSION "1.1.0"
|
||||
|
||||
#define ADC_TO_VOLT(adc) ((adc) * 3.3 ) / 4095)
|
||||
#define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc)*3.3 * (multi)) / 4095)
|
||||
#define MOIST_SENSOR_MAX_ADC (85 * 4095 / 100)
|
||||
#define MOIST_SENSOR_MIN_ADC (25 * 4095 / 100)
|
||||
|
||||
#define SOLAR_VOLT_FACTOR 2
|
||||
#define BATTSENSOR_INDEX_SOLAR 0
|
||||
#define BATTSENSOR_INDEX_BATTERY 1
|
||||
#define MS_TO_S 1000
|
||||
|
||||
#define SENSOR_PLANT0 32 /**< GPIO 32 (ADC1) */
|
||||
#define SENSOR_PLANT1 33 /**< GPIO 33 (ADC1) */
|
||||
#define SENSOR_PLANT2 25 /**< GPIO 25 (ADC2) */
|
||||
@ -66,7 +54,7 @@
|
||||
#define SENSOR_PLANT5 39 /**< SENSOR_VIN */
|
||||
#define SENSOR_PLANT6 36 /**< SENSOR_VP */
|
||||
|
||||
#define OUTPUT_PUMP0 17 /**< GPIO 17 */
|
||||
#define OUTPUT_PUMP0 15 /**< GPIO 15 */
|
||||
#define OUTPUT_PUMP1 5 /**< GPIO 5 */
|
||||
#define OUTPUT_PUMP2 18 /**< GPIO 18 */
|
||||
#define OUTPUT_PUMP3 19 /**< GPIO 19 */
|
||||
@ -74,35 +62,40 @@
|
||||
#define OUTPUT_PUMP5 22 /**< GPIO 22 */
|
||||
#define OUTPUT_PUMP6 23 /**< GPIO 23 */
|
||||
|
||||
#define OUTPUT_SENSOR 16 /**< GPIO 16 - Enable Sensors */
|
||||
#define OUTPUT_PUMP 13 /**< GPIO 13 - Enable Pumps */
|
||||
#define OUTPUT_ENABLE_SENSOR 14 /**< GPIO 14 - Enable Sensors */
|
||||
#define OUTPUT_ENABLE_PUMP 13 /**< GPIO 13 - Enable Pumps */
|
||||
|
||||
#define SENSOR_DS18B20 2 /**< GPIO 2 - Temperatur sensor */
|
||||
#define BUTTON 0 /**< GPIO 0 - Fix button of NodeMCU */
|
||||
#define SENSOR_ONEWIRE 12 /**< GPIO 12 - Temperatur sensor, Battery and other cool onewire stuff */
|
||||
#define SENSOR_TANK_ECHO 16 /**< GPIO 16 - echo feedback of water sensor */
|
||||
#define SENSOR_TANK_TRG 17 /**< GPIO 17 - trigger for water sensor */
|
||||
#define BUTTON 0 /**< GPIO 0 - Fix button of NodeMCU */
|
||||
#define CUSTOM1_PIN3 2 /**< GPIO 2 - Custom GPIO controlling a MOSFET, connected to GND */
|
||||
#define CUSTOM1_PIN2 4 /**< GPIO 4 - custom GPIO directly connected to GPIO header */
|
||||
#define I2C1_PIN2 34 /**< GPIO 34 - I2C */
|
||||
#define I2C1_PIN3 35 /**< GPIO 35 - I2C */
|
||||
/* @} */
|
||||
|
||||
/** \addtogroup Configuration
|
||||
* @{
|
||||
*/
|
||||
#define FIRMWARE_VERSION "1.1.0"
|
||||
|
||||
#define MOIST_SENSOR_MAX_ADC (85 * 4095 / 100)
|
||||
#define MOIST_SENSOR_MIN_ADC (25 * 4095 / 100)
|
||||
|
||||
#define SOLAR_VOLT_FACTOR 2
|
||||
#define BATTSENSOR_INDEX_SOLAR 0
|
||||
#define BATTSENSOR_INDEX_BATTERY 1
|
||||
|
||||
#define MIN_TIME_RUNNING 5UL /**< Amount of seconds the controller must stay awoken */
|
||||
#define MAX_PLANTS 7
|
||||
#define MINIMUM_LIPO_VOLT 3.2f /**< Minimum voltage of the Lipo, that must be present */
|
||||
#define NO_LIPO_VOLT 2.0f /**< No Lipo connected */
|
||||
#define MINIMUM_SOLAR_VOLT 4.0f /**< Minimum voltage of the sun, to detect daylight */
|
||||
#define SOLAR_CHARGE_MIN_VOLTAGE 7 /**< Sun is rising (morning detected) */
|
||||
#define SOLAR_CHARGE_MAX_VOLTAGE 9 /**< Sun is shining (noon) */
|
||||
#define VOLT_MAX_BATT 4.2f
|
||||
|
||||
#define MAX_CONFIG_SETTING_ITEMS 50 /**< Parameter, that can be configured in Homie */
|
||||
|
||||
#define PANIK_MODE_DEEPSLEEP (60 * 60 * 5U) /**< 5 hours in usecond */
|
||||
#define PANIK_MODE_DEEPSLEEP_US (PANIK_MODE_DEEPSLEEP * 1000 * 1000)
|
||||
#define LIPO_MAX_TEMPERATUR 85
|
||||
#define LIPO_MAX_TEMPERATUR_DIFF 10
|
||||
|
||||
#define TEMPERATURE_DELTA_TRIGGER_IN_C 1.0f
|
||||
#define MOIST_DELTA_TRIGGER_ADC 10
|
||||
#define SOLAR_DELTA_VOLT_ADC 3
|
||||
#define LIPO_DELTA_VOLT_ADC 0.2 /**< trigger for lipo voltage */
|
||||
|
||||
#define TEMPERATUR_TIMEOUT 3000 /**< 3 Seconds timeout for the temperatur sensors */
|
||||
#define TEMP_SENSOR_MEASURE_SERIES 5
|
||||
|
||||
/* @} */
|
||||
|
||||
#endif
|
@ -74,7 +74,7 @@ float mChipTemp = 0.0f;
|
||||
|
||||
/*************************** Hardware abstraction *****************************/
|
||||
|
||||
OneWire oneWire(SENSOR_DS18B20);
|
||||
OneWire oneWire(SENSOR_ONEWIRE);
|
||||
DallasTemperature sensors(&oneWire);
|
||||
DS2438 battery(&oneWire, 0.1f);
|
||||
|
||||
@ -132,8 +132,8 @@ void espDeepSleepFor(long seconds, bool activatePump = false)
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
|
||||
gpio_hold_dis(GPIO_NUM_13); //pump pwr
|
||||
gpio_deep_sleep_hold_dis();
|
||||
digitalWrite(OUTPUT_PUMP, LOW);
|
||||
digitalWrite(OUTPUT_SENSOR, LOW);
|
||||
digitalWrite(OUTPUT_ENABLE_PUMP, LOW);
|
||||
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
||||
for (int i = 0; i < MAX_PLANTS; i++)
|
||||
{
|
||||
mPlants[i].deactivatePump();
|
||||
@ -152,7 +152,7 @@ void espDeepSleepFor(long seconds, bool activatePump = false)
|
||||
|
||||
void mode2MQTT()
|
||||
{
|
||||
digitalWrite(OUTPUT_PUMP, LOW);
|
||||
digitalWrite(OUTPUT_ENABLE_PUMP, LOW);
|
||||
for (int i = 0; i < MAX_PLANTS; i++)
|
||||
{
|
||||
mPlants[i].deactivatePump();
|
||||
@ -223,7 +223,7 @@ void mode2MQTT()
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(OUTPUT_PUMP, HIGH);
|
||||
digitalWrite(OUTPUT_ENABLE_PUMP, HIGH);
|
||||
//TODO setLastActivationForPump(lastPumpRunning, getCurrentTime());
|
||||
mPlants[lastPumpRunning].activatePump();
|
||||
}
|
||||
@ -260,11 +260,11 @@ void readDistance()
|
||||
{
|
||||
unsigned long duration = 0;
|
||||
|
||||
digitalWrite(triggerPin, HIGH);
|
||||
digitalWrite(SENSOR_TANK_TRG, HIGH);
|
||||
delayMicroseconds(20);
|
||||
cli();
|
||||
digitalWrite(triggerPin, LOW);
|
||||
duration = pulseIn(echoPin, HIGH);
|
||||
digitalWrite(SENSOR_TANK_TRG, LOW);
|
||||
duration = pulseIn(SENSOR_TANK_ECHO, HIGH);
|
||||
sei();
|
||||
|
||||
int mmDis = duration * 0.3432 / 2;
|
||||
@ -284,7 +284,7 @@ void readSensors()
|
||||
{
|
||||
Serial << "Read Sensors" << endl;
|
||||
/* activate all sensors */
|
||||
digitalWrite(OUTPUT_SENSOR, HIGH);
|
||||
digitalWrite(OUTPUT_ENABLE_SENSOR, HIGH);
|
||||
/* wait before reading something */
|
||||
delay(20);
|
||||
|
||||
@ -341,7 +341,7 @@ void readSensors()
|
||||
Serial << "Distance sensor " << waterRawSensor.getAverage() << " cm" << endl;
|
||||
|
||||
/* deactivate the sensors */
|
||||
digitalWrite(OUTPUT_SENSOR, LOW);
|
||||
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
||||
}
|
||||
|
||||
void onHomieEvent(const HomieEvent &event)
|
||||
@ -365,8 +365,8 @@ void onHomieEvent(const HomieEvent &event)
|
||||
break;
|
||||
case HomieEventType::OTA_STARTED:
|
||||
Homie.getLogger() << "OTA started" << endl;
|
||||
digitalWrite(OUTPUT_SENSOR, HIGH);
|
||||
digitalWrite(OUTPUT_PUMP, HIGH);
|
||||
digitalWrite(OUTPUT_ENABLE_SENSOR, HIGH);
|
||||
digitalWrite(OUTPUT_ENABLE_PUMP, HIGH);
|
||||
gpio_hold_dis(GPIO_NUM_13); //pump pwr
|
||||
gpio_deep_sleep_hold_dis();
|
||||
for (int i = 0; i < MAX_PLANTS; i++)
|
||||
@ -377,8 +377,8 @@ void onHomieEvent(const HomieEvent &event)
|
||||
break;
|
||||
case HomieEventType::OTA_SUCCESSFUL:
|
||||
Homie.getLogger() << "OTA successfull" << endl;
|
||||
digitalWrite(OUTPUT_SENSOR, LOW);
|
||||
digitalWrite(OUTPUT_PUMP, LOW);
|
||||
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
||||
digitalWrite(OUTPUT_ENABLE_PUMP, LOW);
|
||||
ESP.restart();
|
||||
break;
|
||||
default:
|
||||
@ -467,7 +467,6 @@ void systemInit()
|
||||
// Set default values
|
||||
|
||||
//in seconds
|
||||
|
||||
maxTimeBetweenMQTTUpdates.setDefaultValue(700);
|
||||
deepSleepTime.setDefaultValue(600);
|
||||
deepSleepNightTime.setDefaultValue(600);
|
||||
@ -560,8 +559,8 @@ void setup()
|
||||
pinMode(BUTTON, INPUT);
|
||||
|
||||
// Power pins
|
||||
pinMode(OUTPUT_PUMP, OUTPUT);
|
||||
pinMode(OUTPUT_SENSOR, OUTPUT);
|
||||
pinMode(OUTPUT_ENABLE_PUMP, OUTPUT);
|
||||
pinMode(OUTPUT_ENABLE_SENSOR, OUTPUT);
|
||||
|
||||
// Individual Pump pins
|
||||
|
||||
@ -605,7 +604,7 @@ void loop()
|
||||
if (nextBlink < millis())
|
||||
{
|
||||
nextBlink = millis() + 500;
|
||||
digitalWrite(OUTPUT_SENSOR, !digitalRead(OUTPUT_SENSOR));
|
||||
digitalWrite(OUTPUT_ENABLE_SENSOR, !digitalRead(OUTPUT_ENABLE_SENSOR));
|
||||
}
|
||||
}
|
||||
else if (!mDeepsleep)
|
||||
|
Loading…
Reference in New Issue
Block a user