Skip to content
Snippets Groups Projects
Commit ef9b0477 authored by Stefan Gehr's avatar Stefan Gehr
Browse files

bugfixes and stuff for testing

parent 9c65511a
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ static int8_t checkButton() {
}
// 5 C temperature difference turns a pump on
const float ONTEMPDIFF = 5.0;
const float ONTEMPDIFF = 20.0;
// At 1 C difference it turns off again
const float OFFTEMPDIFF = 1.0;
......@@ -35,13 +35,13 @@ void controlPump(uint8_t pumpPin, float tempUp, float tempDown) {
// pump is turned on
if (digitalRead(pumpPin)) {
// turn it off if the difference is less than OFFTEMPDIFF
if (tempUp - tempDown < ONTEMPDIFF) {
if (tempUp < tempDown + OFFTEMPDIFF) {
digitalWrite(pumpPin, LOW);
}
// pump is turned off
} else {
// turn it on if the difference is more than ONTEMPDIFF
if (tempUp - tempDown > ONTEMPDIFF) {
if (tempUp > tempDown + ONTEMPDIFF) {
digitalWrite(pumpPin, HIGH);
}
}
......@@ -159,8 +159,12 @@ void displayLight(bool turnOn) {
void setup(void) {
lcd.init();
Serial.begin(9600);
// start the relevant libraries used by temperature.cpp
temperatureBegin();
// TESTING: temp1up with a poti
pinMode(A0, INPUT);
// start the mp3 library
mp3Setup();
......
......@@ -6,6 +6,7 @@
/* No new valid temperature for < 60 seconds? I sleep.
* No new valid temperature for > 60 seconds? REAL PROBLEM!
*/
// TESTING: only 10 seconds for testing
const uint32_t ERRORTIME = 10000;
// Update the temperature only every second
const uint32_t TEMPUPDATETIME = 1000;
......@@ -20,6 +21,7 @@ const uint32_t TEMPUPDATETIME = 1000;
* function below work the same, except that they use another
* temperature sensor library
*/
/*
static OneWire oneWireT1up(T1UP);
static DallasTemperature dallasTemps(&oneWireT1up);
UPDATESTATE t1up(float* temp) {
......@@ -52,6 +54,36 @@ UPDATESTATE t1up(float* temp) {
prevMillis = curMillis;
return SUCCESS;
}
*/
// TESTING: Using poti for testing
UPDATESTATE t1up(float* temp) {
static uint32_t prevMillis = 0;
static uint32_t errorStartMillis = 0;
uint32_t curMillis = millis();
// only update once a second
if (curMillis - prevMillis < TEMPUPDATETIME) {
return UNCHANGED;
}
float tempC = (float)map(analogRead(A0), 0, 1023, 0, 100);
// check if error occured
if (tempC == 0 || tempC == 100) {
if (errorStartMillis) {
// check if error occurred longer than some seconds (10s)
if (curMillis - errorStartMillis > ERRORTIME) {
return LONG_TIME_ERROR;
}
} else {
errorStartMillis = curMillis;
}
return ERROR;
}
// update temperature and time variables
*temp = tempC;
errorStartMillis = 0;
prevMillis = curMillis;
return SUCCESS;
}
// DOWN temperature for solar system 1
static DHT dhtT1down(T1DOWN, DHT11);
......@@ -136,7 +168,8 @@ UPDATESTATE t2down(float* temp) {
// start the relevant libraries
void temperatureBegin(void) {
dallasTemps.begin();
// TESTING
//dallasTemps.begin();
dhtT1down.begin();
dhtT2up.begin();
dhtT2down.begin();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment