// For Mega you can add al of the commands and uncomment. For nano you will need to comment // out some of the script. //// pump digital pins, 16 digital pins but grove only seems to have the //// split mapped diferent on the split cables. So only using 8. //const int pumpPin0 = 0; //const int pumpPin1 = 1; //const int pumpPin2 = 2; //const int pumpPin3 = 3; //const int pumpPin4 = 4; //const int pumpPin5 = 5; //const int pumpPin6 = 6; //const int pumpPin7 = 7; // soil moisture analog pins, 16 analog pins but grove only seems to have the // split mapped diferent on the split cables. So only using 8. const int soilSensorA0 = A0; const int soilSensorA1 = A2; const int soilSensorA2 = A4; //const int soilSensorA3 = A6; //const int soilSensorA4 = A8; //const int soilSensorA5 = A10; //const int soilSensorA6 = A12; //const int soilSensorA7 = A14; // soil moisture reading that is dry const int dry = 670; // soil moisture reading that is moist const int moist = 680; // print delay const int printDelay = 5000; // per sensor script delay //const int sensorsDelay = 5000; // Serial write speak const int serialWrite = 19200; // site number if you have more than one const int siteNumber = 2; // Cycle Delay every 2 hours //const int cycleDelay = 7200000; // water delay //const in waterDelay = 10000; void setup() { // pinMode(pumpPin1, OUTPUT); // pinMode(soilSensor0, INPUT); // Serial.begin(serialwrite); // digitalWrite(pumpPin1, HIGH); // delay(sensordelay); // pinMode(pumpPin1, OUTPUT); // pinMode(soilSensor1, INPUT); // Serial.begin(serialwrite); // digitalWrite(pumpPin2, HIGH); // delay(sensordelay); // pinMode(pumpPin2, OUTPUT); // pinMode(soilSensor2, INPUT); // Serial.begin(serialwrite); // digitalWrite(pumpPin3, HIGH); // delay(sensordelay); // pinMode(pumpPin3, OUTPUT); // pinMode(soilSensor3, INPUT); // Serial.begin(serialwrite); // digitalWrite(pumpPin4, HIGH); // delay(sensordelay); // pinMode(pumpPin4, OUTPUT); // pinMode(soilSensor4, INPUT); // Serial.begin(serialwrite); // digitalWrite(pumpPin5, HIGH); // delay(sensordelay); // pinMode(pumpPin5, OUTPUT); // pinMode(soilSensor5, INPUT); // Serial.begin(serialwrite); // digitalWrite(pumpPin6, HIGH); // delay(sensordelay); // pinMode(pumpPin6, OUTPUT); // pinMode(soilSensor6, INPUT); // Serial.begin(serialwrite); // digitalWrite(pumpPin6, HIGH); // delay(sensordelay); // pinMode(pumpPin7, OUTPUT); // pinMode(soilSensor7, INPUT); // Serial.begin(serialwrite); // digitalWrite(pumpPin7, HIGH); // delay(sensordelay); Serial.begin(serialWrite); } void loop() { // Delay to allow any reboots to happen delay(120000); Serial.println("Sensing Moisture on Zone " + String(siteNumber) + "!"); delay(printDelay); // Moisture Sensor A0 int moisture0 = analogRead(soilSensorA0); Serial.println("Pot 9: " + String(moisture0)); delay(5000); if (moisture0 >= dry) { // the soil is too dry, water! Serial.println("Pot 9 is dry"); delay(5000); } if (moisture0 <= moist) { // the soil is too dry, water! Serial.println("Pot 9 is moist"); delay(5000); } // Moisture Sensor A2 int moisture1 = analogRead(soilSensorA1); Serial.println("Pot 10: " + String(moisture1)); delay(5000); if (moisture1 >= dry) { // the soil is too dry, water! Serial.println("Pot 10 is dry"); delay(5000); } if (moisture1 <= moist) { // the soil is too dry, water! Serial.println("Pot 10 is moist"); delay(5000); } // Moisture Sensor A4 int moisture2 = analogRead(soilSensorA2); Serial.println("Pot 11: " + String(moisture2)); delay(5000); if (moisture2 >= dry) { // the soil is too dry, water! Serial.println("Pot 11 is dry"); delay(5000); } if (moisture2 <= moist) { // the soil is too dry, water! Serial.println("Pot 11 is moist"); delay(5000); } // // Moisture Sensor A6 // int moisture3 = analogRead(soilSensorA3); // Serial.println("Pot 4: " + String(moisture3)); // delay(5000); // // if (moisture3 >= dry) { // // the soil is too dry, water! // Serial.println("Pot 4 is dry"); // delay(5000); // } // // if (moisture3 <= moist) { // // the soil is too dry, water! // Serial.println("Pot 4 is moist"); // delay(5000); // } // // // Moisture Sensor A8 // int moisture4 = analogRead(soilSensorA4); // Serial.println("Pot 5: " + String(moisture4)); // delay(5000); // // if (moisture4 >= dry) { // // the soil is too dry, water! // Serial.println("Pot 5 is dry"); // delay(5000); // } // // if (moisture4 <= moist) { // // the soil is too dry, water! // Serial.println("Pot 5 is moist"); // delay(5000); // } // // // Moisture Sensor A10 // int moisture5 = analogRead(soilSensorA5); // Serial.println("Pot 6: " + String(moisture5)); // delay(5000); // // if (moisture5 >= dry) { // // the soil is too dry, water! // Serial.println("Pot 6 is dry"); // delay(5000); // } // // if (moisture5 <= moist) { // // the soil is too dry, water! // Serial.println("Pot 6 is moist"); // delay(5000); // } // // // Moisture Sensor A11 // int moisture6 = analogRead(soilSensorA6); // Serial.println("Pot 7: " + String(moisture6)); // delay(5000); // // if (moisture6 >= dry) { // // the soil is too dry, water! // Serial.println("Pot 7 is dry"); // delay(5000); // } // // if (moisture6 <= moist) { // // the soil is too dry, water! // Serial.println("Pot 7 is moist"); // delay(5000); // } // // // Moisture Sensor A12 // int moisture7 = analogRead(soilSensorA7); // Serial.println("Pot 8: " + String(moisture7)); // delay(5000); // // if (moisture7 >= dry) { // // the soil is too dry, water! // Serial.println("Pot 8 is dry"); // delay(5000); // } // // if (moisture7 <= moist) { // // the soil is too dry, water! // Serial.println("Pot 8 is moist"); // delay(5000); // } Serial.println("Done Sensing Moisture!"); delay(5000); Serial.println("Next moisture check is in a couple hrs!"); delay(printDelay); delay(3600000); }