diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 62c3d4d..058615f 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -167,22 +167,34 @@ float getHumidity() { } int getSoilmoisture(bool moistureSensor) { + // value to return int soilmoisture; + // value for wet + int wet; + // value for dry + int dry; if(moistureSensor == false ) { // read analog value from analog moisture sensor + wet = 185; + 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 = 580; + dry= 250; + // get raw value from I2C chirp sensor soilmoisture = readI2CRegister16bit(0x20, 0); } - return soilmoisture; + return map(soilmoisture, wet, dry, 100, 0); } int getLightchirp() { @@ -285,7 +297,7 @@ void loop() { display.display(); Serial.println("Test"); - delay(1000); + //delay(1000); }