diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino
index 53cb55b..ef0b311 100644
--- a/Arduino/CanGrow/CanGrow.ino
+++ b/Arduino/CanGrow/CanGrow.ino
@@ -67,8 +67,8 @@ bool configured;
// NTP Offset
int ntpOffset;
// MoistureSensor_Type - contains which moisture sensor to use
-// 0: analog capacitive sensor
-// 1: I2C chirp sensor from catnip electronics
+// 1: analog capacitive sensor
+// 2: I2C chirp sensor from catnip electronics
byte MoistureSensor_Type;
// SoilmoistureLow - contains the value , when soil moisture is assumed to be low,
byte SoilmoistureLow;
@@ -78,6 +78,10 @@ bool UsePump;
byte PumpOnTime;
bool UseFan;
+// In case the user uses no 12V LED on the LED output and an relais instead
+// we have to disable PWM. So we ask here for what kind of light user is going
+bool UseLEDrelais;
+
//
// Grow Stuff
//
@@ -427,10 +431,10 @@ int getWaterlevel() {
* 0 : OK
*/
- int waterlevelWARN = 200;
- int waterlevelOK = 400;
- int waterlevelRAW = 0;
- int waterlevel = 0;
+ byte waterlevelWARN = 200;
+ byte waterlevelOK = 400;
+ byte waterlevelRAW = 0;
+ byte waterlevel = 0;
// enable Vcc for water level sensor
digitalWrite(PINwaterlevel, HIGH);
@@ -453,22 +457,28 @@ int getWaterlevel() {
return waterlevel;
}
-float getTemperature(bool tempSensor) {
+float getTemperature(byte tempSensor) {
/*
* tempSensor
* ==========
- * 0/false : DHT11 temp sensor
- * 1/true : chirp I2C temp sensor
+ * 1 : DHT11 temp sensor
+ * 2 : chirp I2C temp sensor
*/
float temperature = 0;
- if(tempSensor == false ) {
- // read temperature from DHT11
- temperature = dht.readTemperature();
- } else {
- // read temperature from chrip I2C
- temperature = readI2CRegister16bit(0x20, 5) * 0.10 ;
+ switch(tempSensor) {
+ case 1:
+ // read temperature from DHT11
+ temperature = dht.readTemperature();
+ break;
+ case 2:
+ // read temperature from chrip I2C
+ temperature = readI2CRegister16bit(0x20, 5) * 0.10 ;
+ break;
+ default:
+ // if sensor type is not recognized, return 99
+ temperature = 99.99;
}
return temperature;
@@ -483,8 +493,8 @@ int getSoilmoisture(byte moistureSensor) {
/*
* moistureSensor
* ==============
- * 0 : analog capacitive moisture sensor
- * 1 : chirp I2C moisture sensor
+ * 1 : analog capacitive moisture sensor
+ * 2 : chirp I2C moisture sensor
*/
// value to return
@@ -494,25 +504,32 @@ int getSoilmoisture(byte moistureSensor) {
// value for dry
int dry;
- if(moistureSensor == 0 ) {
- // read analog value from analog moisture sensor
- wet = 180;
- dry= 590;
-
- digitalWrite(PINsoilmoisture, HIGH);
- // wait a bit to let the circuit stabilize
- delay(100);
- // get analog input value
- soilmoisture = analogRead(PINanalog);
- // disable Vcc for the sensor to release analog pin
- digitalWrite(PINsoilmoisture, LOW);
- } else {
- // read soil moisture from chrip I2C
- wet = 560;
- dry= 250;
-
- // get raw value from I2C chirp sensor
- soilmoisture = readI2CRegister16bit(0x20, 0);
+ switch(moistureSensor) {
+ case 1:
+ // read analog value from analog moisture sensor
+ wet = 180;
+ dry= 590;
+
+ digitalWrite(PINsoilmoisture, HIGH);
+ // wait a bit to let the circuit stabilize
+ delay(100);
+ // get analog input value
+ soilmoisture = analogRead(PINanalog);
+ // disable Vcc for the sensor to release analog pin
+ digitalWrite(PINsoilmoisture, LOW);
+ break;
+ case 2:
+ // read soil moisture from chrip I2C
+ wet = 560;
+ dry= 250;
+
+ // get raw value from I2C chirp sensor
+ soilmoisture = readI2CRegister16bit(0x20, 0);
+ break;
+ default:
+ wet = 0;
+ dry = 1;
+ soilmoisture = -1;
}
return map(soilmoisture, wet, dry, 100, 0);
@@ -942,7 +959,25 @@ void WebAuthApi() {
}
}
+
+/*
+ * returnSelected(bool)
+ * returns char[] "selected" if bool is true
+ * useful for html forms, to preset a saved value as selected
+ */
+String returnStrSelected(byte savedValue, byte selectId) {
+ String returnStr;
+ if(configured == true) {
+ if(savedValue == selectId) {
+ returnStr = "selected";
+ } else {
+ returnStr = "";
+ }
+ }
+
+ return returnStr;
+}
/*
*
* Web pages
@@ -1020,11 +1055,8 @@ void WEBwifiSettings() {
for(int i = 0 ; i < ssidsAvail; i++) {
String wifiName = WiFi.SSID(i);
Serial.println(wifiName);
- body += "\n";
+ body += "\n";
}
body += "
\n";
body += "Password:
\n";
@@ -1055,48 +1087,48 @@ void WEBsystemSettings() {
body += "
here you can set which features and sensors you use
";
body += "