One wire is initialized directly after start
This commit is contained in:
parent
b8b8cf84d5
commit
31229594fe
@ -75,10 +75,6 @@ DS18B20 one wire temp sensor
|
|||||||
* alle Pumpen & Sensoren deaktiviert
|
* alle Pumpen & Sensoren deaktiviert
|
||||||
|
|
||||||
## Masterplan 2.0
|
## Masterplan 2.0
|
||||||
* 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
|
* Partitionslayout
|
||||||
* OW-search address in topic nutzen
|
* OW-search address in topic nutzen
|
||||||
* Wifi bei timout deaktivieren (damit wir entweder wlan spielen oder fallback: nur pflanzen giessen)
|
* Wifi bei timout deaktivieren (damit wir entweder wlan spielen oder fallback: nur pflanzen giessen)
|
||||||
|
@ -97,7 +97,8 @@
|
|||||||
#define MAX_CONFIG_SETTING_ITEMS 50 /**< Parameter, that can be configured in Homie */
|
#define MAX_CONFIG_SETTING_ITEMS 50 /**< Parameter, that can be configured in Homie */
|
||||||
|
|
||||||
#define TEMPERATUR_TIMEOUT 3000 /**< 3 Seconds timeout for the temperatur sensors */
|
#define TEMPERATUR_TIMEOUT 3000 /**< 3 Seconds timeout for the temperatur sensors */
|
||||||
#define TEMP_SENSOR_MEASURE_SERIES 5
|
#define DS18B20_RESOLUTION 9 /**< 9bit temperature resolution -> 0.5°C steps */
|
||||||
|
|
||||||
/* @} */
|
/* @} */
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -193,30 +193,10 @@ void readDistance()
|
|||||||
*/
|
*/
|
||||||
void readSensors()
|
void readSensors()
|
||||||
{
|
{
|
||||||
|
int sensorCount = sensors.getDS18Count();
|
||||||
Serial << "Read Sensors" << endl;
|
Serial << "Read Sensors" << endl;
|
||||||
/* activate all sensors */
|
/* activate all sensors */
|
||||||
digitalWrite(OUTPUT_ENABLE_SENSOR, HIGH);
|
digitalWrite(OUTPUT_ENABLE_SENSOR, HIGH);
|
||||||
/* wait before reading something */
|
|
||||||
delay(20);
|
|
||||||
|
|
||||||
int timeoutTemp = millis() + TEMPERATUR_TIMEOUT;
|
|
||||||
uint8_t sensorCount = 0U;
|
|
||||||
|
|
||||||
/* Required to read the temperature at least once */
|
|
||||||
while ((sensorCount == 0 || !battery.isFound()) && millis() < timeoutTemp)
|
|
||||||
{
|
|
||||||
sensors.begin();
|
|
||||||
battery.begin();
|
|
||||||
sensorCount = sensors.getDS18Count();
|
|
||||||
delay(50);
|
|
||||||
}
|
|
||||||
|
|
||||||
Serial << "One wire count: " << sensorCount << " found in " << (millis() - timeoutTemp) << "ms" << endl;
|
|
||||||
/* Measure temperature */
|
|
||||||
if (sensorCount > 0)
|
|
||||||
{
|
|
||||||
sensors.requestTemperatures();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < sensorCount; i++)
|
for (uint8_t i = 0; i < sensorCount; i++)
|
||||||
{
|
{
|
||||||
@ -428,6 +408,26 @@ void setup()
|
|||||||
Serial << "Limits.hpp" << endl;
|
Serial << "Limits.hpp" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************************* Start One-Wire bus ***************/
|
||||||
|
int timeoutTemp = millis() + TEMPERATUR_TIMEOUT;
|
||||||
|
uint8_t sensorCount = 0U;
|
||||||
|
|
||||||
|
/* Required to read the temperature at least once */
|
||||||
|
while ((sensorCount == 0 || !battery.isFound()) && millis() < timeoutTemp)
|
||||||
|
{
|
||||||
|
sensors.begin();
|
||||||
|
battery.begin();
|
||||||
|
sensorCount = sensors.getDS18Count();
|
||||||
|
delay(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial << "One wire count: " << sensorCount << " found in " << (millis() - timeoutTemp) << "ms" << endl;
|
||||||
|
/* Measure temperature TODO idea: move this into setup */
|
||||||
|
if (sensorCount > 0)
|
||||||
|
{
|
||||||
|
sensors.setResolution(DS18B20_RESOLUTION);
|
||||||
|
sensors.requestTemperatures();
|
||||||
|
}
|
||||||
|
|
||||||
/************************* Start Homie Framework ***************/
|
/************************* Start Homie Framework ***************/
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
|
Loading…
Reference in New Issue
Block a user