Removed index to indentify temperatur sensors
This commit is contained in:
parent
284fb4907d
commit
dc5dc27ba5
@ -81,5 +81,6 @@ DS18B20 one wire temp sensor
|
||||
* Timeout um nicht ewig aufs WLAN zu warten
|
||||
* Nicht mehrere Messungen vom Temp-Sensor nur warten, bis wir einen Wert bekommen
|
||||
* Partitionslayout
|
||||
* OW-search address in topic nutzen
|
||||
|
||||
|
||||
|
@ -1,18 +1,6 @@
|
||||
/*
|
||||
* DS2438.h
|
||||
/**
|
||||
* @file DS2438.h
|
||||
*
|
||||
* by Joe Bechter
|
||||
*
|
||||
* (C) 2012, bechter.com
|
||||
*
|
||||
* All files, software, schematics and designs are provided as-is with no warranty.
|
||||
* All files, software, schematics and designs are for experimental/hobby use.
|
||||
* Under no circumstances should any part be used for critical systems where safety,
|
||||
* life or property depends upon it. You are responsible for all use.
|
||||
* You are free to use, modify, derive or otherwise extend for your own non-commercial purposes provided
|
||||
* 1. No part of this software or design may be used to cause injury or death to humans or animals.
|
||||
* 2. Use is non-commercial.
|
||||
* 3. Credit is given to the author (i.e. portions © bechter.com), and provide a link to the original source.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -19,43 +19,53 @@
|
||||
#define MAX_PLANTS 7
|
||||
|
||||
/**
|
||||
* @name Attributes
|
||||
* @name Homie Attributes
|
||||
* generated Information
|
||||
* @{
|
||||
**/
|
||||
|
||||
#define NUMBER_TYPE "number"
|
||||
#define TEMPERATUR_SENSOR_LIPO "lipo"
|
||||
#define TEMPERATUR_SENSOR_WATER "water"
|
||||
#define TEMPERATUR_SENSOR_OUTSIDE "temp"
|
||||
#define TEMPERATUR_SENSOR_CHIP "chip"
|
||||
#define NUMBER_TYPE "number" /**< numberic information, published or read in Homie */
|
||||
|
||||
/**
|
||||
* @name Temperatur Node
|
||||
* @{
|
||||
**/
|
||||
|
||||
#define TEMPERATURE_NAME "Temperature"
|
||||
#define TEMPERATURE_UNIT "°C"
|
||||
#define TEMPERATUR_SENSOR_LIPO "lipo" /**< Homie node: temperatur, setting: lipo temperatur (or close to it) */
|
||||
#define TEMPERATUR_SENSOR_CHIP "chip" /**< Homie node: temperatur, setting: battery chip */
|
||||
#define TEMPERATUR_SENSOR_WATER "water" /**< Homie node: temperatur, setting: water temperatur */
|
||||
/** @}
|
||||
*
|
||||
* @name Plant Nodes
|
||||
* @{
|
||||
*/
|
||||
|
||||
HomieNode plant0("plant0", "Plant 0", "Plant"); /**< dynamic Homie information for first plant */
|
||||
HomieNode plant1("plant1", "Plant 1", "Plant"); /**< dynamic Homie information for second plant */
|
||||
HomieNode plant2("plant2", "Plant 2", "Plant"); /**< dynamic Homie information for first plant */
|
||||
HomieNode plant3("plant3", "Plant 3", "Plant"); /**< dynamic Homie information for first plant */
|
||||
HomieNode plant4("plant4", "Plant 4", "Plant"); /**< dynamic Homie information for first plant */
|
||||
HomieNode plant5("plant5", "Plant 5", "Plant"); /**< dynamic Homie information for first plant */
|
||||
HomieNode plant6("plant6", "Plant 6", "Plant"); /**< dynamic Homie information for first plant */
|
||||
HomieNode plant2("plant2", "Plant 2", "Plant"); /**< dynamic Homie information for third plant */
|
||||
HomieNode plant3("plant3", "Plant 3", "Plant"); /**< dynamic Homie information for fourth plant */
|
||||
HomieNode plant4("plant4", "Plant 4", "Plant"); /**< dynamic Homie information for fivth plant */
|
||||
HomieNode plant5("plant5", "Plant 5", "Plant"); /**< dynamic Homie information for sixth plant */
|
||||
HomieNode plant6("plant6", "Plant 6", "Plant"); /**< dynamic Homie information for seventh plant */
|
||||
|
||||
HomieNode sensorLipo("lipo", "Battery Status", "Lipo");
|
||||
HomieNode sensorSolar("solar", "Solar Status", "Solarpanel");
|
||||
HomieNode sensorWater("water", "WaterSensor", "Water");
|
||||
HomieNode sensorTemp("temperature", "Temperature", "temperature");
|
||||
HomieNode startupReason("startupReason", "startupReason", "startupReason");
|
||||
HomieNode stayAlive("stay", "alive", "alive"); /**< Necessary for Mqtt Active Command */
|
||||
|
||||
/* @} */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name Settings
|
||||
* General settings for the controller
|
||||
* @{
|
||||
*/
|
||||
HomieSetting<long> maxTimeBetweenMQTTUpdates("mqttSleep", "time in seconds to start into mode2");
|
||||
HomieSetting<long> deepSleepTime("deepsleep", "time in seconds to sleep (0 deactivats it)");
|
||||
HomieSetting<long> deepSleepTime("deepsleep", "time in seconds to sleep");
|
||||
HomieSetting<long> deepSleepNightTime("nightsleep", "time in seconds to sleep (0 uses same setting: deepsleep at night, too)");
|
||||
HomieSetting<long> wateringDeepSleep("pumpdeepsleep", "time seconds to sleep, while a pump is running");
|
||||
|
||||
@ -63,12 +73,12 @@ HomieSetting<long> waterLevelMax("watermaxlevel", "distance (mm) at maximum wate
|
||||
HomieSetting<long> waterLevelMin("waterminlevel", "distance (mm) at minimum water level (pumps still covered)");
|
||||
HomieSetting<long> waterLevelWarn("waterlevelwarn", "warn (mm) if below this water level %");
|
||||
HomieSetting<long> waterLevelVol("waterVolume", "(ml) between minimum and maximum");
|
||||
HomieSetting<long> lipoSensorIndex("lipoTempIndex", "index onwire bus for lipo temperature sensor");
|
||||
HomieSetting<long> waterSensorIndex("waterTempIndex", "index onwire bus for water temperature sensor");
|
||||
HomieSetting<const char *> lipoSensorAddr("lipoTempAddr", "1wire address for lipo temperature sensor");
|
||||
HomieSetting<const char *> waterSensorAddr("waterTempIndex", "1wire address for water temperature sensor");
|
||||
HomieSetting<const char *> ntpServer("ntpServer", "NTP server (pool.ntp.org as default)");
|
||||
|
||||
/**
|
||||
*@}
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -46,15 +46,11 @@ int readTemp();
|
||||
******************************************************************************/
|
||||
|
||||
//only relevant if mode2 did start pumping before
|
||||
RTC_DATA_ATTR int lastPumpRunning = 0;
|
||||
RTC_DATA_ATTR long lastWaterValue = 0;
|
||||
RTC_DATA_ATTR int lastPumpRunning = 0; /**< store last successfully waterd plant */
|
||||
RTC_DATA_ATTR long lastWaterValue = 0; /**< to calculate the used water per plant */
|
||||
|
||||
RTC_DATA_ATTR int gBootCount = 0;
|
||||
|
||||
//FIXME use -1 and configure properly
|
||||
RTC_DATA_ATTR int rtcLipoTempIndex = 0;
|
||||
RTC_DATA_ATTR int rtcWaterTempIndex = -1;
|
||||
|
||||
/******************************************************************************
|
||||
* LOCAL VARIABLES
|
||||
******************************************************************************/
|
||||
@ -196,9 +192,6 @@ void mode2MQTT()
|
||||
sensorLipo.setProperty("CCA").send(String(battery.getCCA()));
|
||||
sensorSolar.setProperty("volt").send(String(mSolarVoltage));
|
||||
|
||||
rtcLipoTempIndex = lipoSensorIndex.get();
|
||||
rtcWaterTempIndex = waterSensorIndex.get();
|
||||
|
||||
sensorTemp.setProperty(TEMPERATUR_SENSOR_LIPO).send(String(mTempLipo));
|
||||
Serial << "Lipo Temperatur " << mTempLipo << " °C " << endl;
|
||||
|
||||
@ -310,12 +303,7 @@ void readSensors()
|
||||
for (int i = 0; i < sensorCount; i++) {
|
||||
float temp = sensors.getTempCByIndex(i);
|
||||
Serial << "OneWire sensor " << i << " has value " << temp << endl;
|
||||
if (rtcWaterTempIndex != -1 && rtcWaterTempIndex == i) {
|
||||
mTempWater = temp;
|
||||
}
|
||||
if (rtcLipoTempIndex != -1 && rtcLipoTempIndex == i) {
|
||||
mTempLipo = temp;
|
||||
}
|
||||
/** FIXME: handle via address */
|
||||
}
|
||||
|
||||
// Update battery chip data
|
||||
@ -467,8 +455,9 @@ void systemInit()
|
||||
// Set default values
|
||||
|
||||
//in seconds
|
||||
maxTimeBetweenMQTTUpdates.setDefaultValue(700);
|
||||
deepSleepTime.setDefaultValue(600);
|
||||
deepSleepTime.setDefaultValue(600).setValidator([] (long candidate) {
|
||||
return (candidate > 0) && (candidate < (60 * 60 * 2) /** 2h max sleep */ );
|
||||
});
|
||||
deepSleepNightTime.setDefaultValue(600);
|
||||
wateringDeepSleep.setDefaultValue(5);
|
||||
ntpServer.setDefaultValue("pool.ntp.org");
|
||||
@ -477,8 +466,8 @@ void systemInit()
|
||||
waterLevelMin.setDefaultValue(50); /* 5cm in mm */
|
||||
waterLevelWarn.setDefaultValue(500); /* 50cm in mm */
|
||||
waterLevelVol.setDefaultValue(5000); /* 5l in ml */
|
||||
lipoSensorIndex.setDefaultValue(0);
|
||||
waterSensorIndex.setDefaultValue(-1);
|
||||
lipoSensorAddr.setDefaultValue("");
|
||||
waterSensorAddr.setDefaultValue("");
|
||||
Homie.setLoopFunction(homieLoop);
|
||||
Homie.onEvent(onHomieEvent);
|
||||
//Homie.disableLogging();
|
||||
@ -522,7 +511,6 @@ void systemInit()
|
||||
.setDatatype(NUMBER_TYPE)
|
||||
.setUnit("V");
|
||||
sensorWater.advertise("remaining").setDatatype(NUMBER_TYPE).setUnit("%");
|
||||
startupReason.advertise("startupReason").setDatatype(NUMBER_TYPE).setUnit("Enum");
|
||||
}
|
||||
stayAlive.advertise("alive").setName("Alive").setDatatype(NUMBER_TYPE).settable(aliveHandler);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user