OpenSource Section | SB.Chetak Innovation | Research • Engineering • Responsible Knowledge Sharing

SAKSHAM

Smart Adaptive Knowledge-based Soil Hydration & Automation Module

Smart Agriculture • Climate-Adaptive Irrigation • Embedded Systems • Water Conservation

Project ID: 0612 Controller: Arduino Mega 2560 reference implementation Application: Smart Irrigation Open-Source Project
Theme: Inspired by Nature. For Climate. For Our Future.

SAKSHAM is a climate-adaptive smart plant water-management project designed to monitor soil and environmental conditions and automate irrigation decisions. Its documented objective is to reduce unnecessary watering while supporting healthy plant growth and more efficient water use.

Project Overview

Water availability and plant requirements change with soil moisture and environmental conditions. SAKSHAM addresses this by combining soil-moisture sensing with temperature, humidity, rainfall, light and water-tank monitoring so that irrigation can be adjusted according to current conditions.

The documented system continuously reads sensors, checks water availability, applies irrigation decision logic, controls a pump, displays information locally, stores data and can send alerts when required.

Keywords: Smart Agriculture, Soil Moisture, Irrigation Automation, Rain Detection, Temperature, Humidity, Light Monitoring, Water Conservation, Arduino, Data Logging.
SAKSHAM project prototype images
SAKSHAM project image supplied for the project portfolio.

Objectives

Automated WateringAutomate plant watering according to measured soil conditions.
Water ConservationAvoid unnecessary irrigation and reduce water wastage.
Climate AwarenessConsider rain, temperature, humidity and sunlight during irrigation decisions.
System MonitoringDisplay, record and communicate operating information where required.

Reference Hardware Architecture

The project materials identify soil and environmental sensing, pump control, a local display, data storage and alert capability. The reference implementation in this OpenSource Section uses the following representative modules.

Arduino Mega 2560Central microcontroller for sensor acquisition and irrigation logic.
Soil Moisture SensorEstimates soil-moisture level for irrigation decisions.
DHT11 / DHT22Temperature and humidity monitoring.
Rain SensorStops watering when rainfall is detected.
Ambient-Light Sensor / LDRSupports strong-sunlight awareness.
Water-Level SensorChecks whether the irrigation tank has sufficient water.
Relay + DC PumpProvides low-voltage pump switching under controller command.
16×2 I²C LCDDisplays soil and operating status locally.
SD Card ModuleStores readings and irrigation decisions for later review.
SIM800L / SIM900 GSMReference option for event and alert messaging.

Documented Irrigation Decision Logic

The following soil-moisture ranges are taken from the SAKSHAM project presentation and are shown here as the core decision framework.

Soil MoistureConditionDocumented Action
0–20%Very dryHigh watering
20–50%Slightly dryPulse watering
50–70%OptimalNo watering
Above 70%WetNo watering
Rain DetectionIf rain is detected, watering stops automatically.
TemperatureHigher temperature can increase watering demand.
HumidityHigher humidity can reduce watering demand.
Strong SunlightWatering can be deferred during strong sunlight to reduce water loss.
Empty TankThe pump is turned off and an alert is generated if the tank is empty.

Circuit / Interconnection Diagram

The diagram below is an OpenSource Section reference interconnection diagram based on the modules and operating functions documented for SAKSHAM. It is not presented as a reproduction of an unreleased original schematic.

SAKSHAM reference circuit and interconnection diagram
Reference mapping: soil sensor A0, rain A1, light A2, tank-level A3, DHT D22, relay D7, I²C LCD SDA20/SCL21, SD via SPI with CS53, and GSM through Arduino Mega Serial1. Verify the datasheet of each actual module before connection.
Electrical-safety note: Keep irrigation water away from electronics, use regulated low-voltage supplies appropriate to the actual modules, and ensure the pump/load side is electrically handled according to the relay and power-supply specifications.

System Operation Flow

Step 01Initialize sensors and modules
Step 02Read sensor data
Step 03Check water-tank level
Step 04Apply irrigation decision logic
Step 05Control the water pump
Step 06Display data on LCD
Step 07Store data on SD card
Step 08Send alerts if required and repeat

Arduino Reference Implementation

Download .ino

The project presentation states that original code and a circuit diagram are intended to be available through the OpenSource Section, but the supplied presentation does not contain the source code itself. The file below is therefore clearly labelled as a reference implementation aligned with the documented logic rather than claimed as the unretrieved original firmware.

/*
  SAKSHAM — Smart Adaptive Knowledge-based Soil Hydration & Automation Module
  OpenSource Section | SB.Chetak Innovation

  REFERENCE IMPLEMENTATION
  ---------------------------------------------------------------------------
  This sketch is a reference implementation created from the documented
  SAKSHAM operating logic. Calibrate all sensors and verify module datasheets
  before practical use.

  Documented logic represented here:
  - Soil 0–20%  : very dry -> high watering
  - Soil 20–50% : slightly dry -> pulse watering
  - Soil 50–70% : optimal -> no watering
  - Soil >70%   : wet -> no watering
  - Rain detected -> watering stops
  - High temperature -> watering demand may increase
  - High humidity -> watering demand may decrease
  - Strong sunlight -> watering may be deferred
  - Empty tank -> pump OFF and alert
  - LCD display + SD logging + GSM alert capability
*/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <SPI.h>
#include <SD.h>

// ---------------------------------------------------------------------------
// Pin configuration — Arduino Mega 2560 reference mapping
// ---------------------------------------------------------------------------

const uint8_t PIN_SOIL      = A0;
const uint8_t PIN_RAIN      = A1;
const uint8_t PIN_LIGHT     = A2;
const uint8_t PIN_TANK      = A3;
const uint8_t PIN_DHT       = 22;
const uint8_t PIN_RELAY     = 7;
const uint8_t PIN_SD_CS     = 53;

#define DHTTYPE DHT22
DHT dht(PIN_DHT, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Arduino Mega Serial1: RX1 = 19, TX1 = 18
#define gsm Serial1

// ---------------------------------------------------------------------------
// Calibration values — MUST be calibrated for the actual sensors
// ---------------------------------------------------------------------------

const int SOIL_DRY_RAW = 850;   // example calibration point
const int SOIL_WET_RAW = 350;   // example calibration point

const int RAIN_THRESHOLD_RAW = 500;   // example only
const int LIGHT_STRONG_RAW   = 780;   // example only
const int TANK_EMPTY_RAW     = 180;   // example only

const bool RELAY_ACTIVE_LOW = true;
const bool AVOID_STRONG_SUN = true;

// Example controlled watering windows. Adjust after testing.
const unsigned long HIGH_WATER_MS  = 12000UL;
const unsigned long PULSE_WATER_MS = 5000UL;
const unsigned long CYCLE_DELAY_MS = 5000UL;

// Optional environmental modifiers
const float HIGH_TEMP_C = 32.0;
const float HIGH_HUMIDITY_PERCENT = 80.0;

unsigned long lastLogTime = 0;
const unsigned long LOG_INTERVAL_MS = 15000UL;

// ---------------------------------------------------------------------------
// Utility helpers
// ---------------------------------------------------------------------------

void setPump(bool on) {
  if (RELAY_ACTIVE_LOW) {
    digitalWrite(PIN_RELAY, on ? LOW : HIGH);
  } else {
    digitalWrite(PIN_RELAY, on ? HIGH : LOW);
  }
}

int soilPercentFromRaw(int raw) {
  long mapped = map(raw, SOIL_DRY_RAW, SOIL_WET_RAW, 0, 100);
  return constrain((int)mapped, 0, 100);
}

void sendGsmLine(const String &line) {
  gsm.println(line);
  delay(150);
}

void sendSms(const String &message) {
  // Enter a verified recipient number before enabling practical SMS alerts.
  const char PHONE_NUMBER[] = "+000000000000";

  sendGsmLine("AT");
  sendGsmLine("AT+CMGF=1");
  gsm.print("AT+CMGS=\"");
  gsm.print(PHONE_NUMBER);
  gsm.println("\"");
  delay(250);
  gsm.print(message);
  gsm.write(26); // Ctrl+Z
  delay(1200);
}

void showStatus(int soil, float temperature, bool pumpOn) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Soil:");
  lcd.print(soil);
  lcd.print("% T:");
  if (isnan(temperature)) {
    lcd.print("--");
  } else {
    lcd.print((int)temperature);
  }

  lcd.setCursor(0, 1);
  lcd.print("Pump:");
  lcd.print(pumpOn ? "ON " : "OFF");
}

void logToSd(
  int soil,
  int rainRaw,
  int lightRaw,
  int tankRaw,
  float temperature,
  float humidity,
  const String &decision
) {
  if (millis() - lastLogTime < LOG_INTERVAL_MS) return;
  lastLogTime = millis();

  File file = SD.open("saksham.csv", FILE_WRITE);
  if (!file) return;

  file.print(millis()); file.print(',');
  file.print(soil); file.print(',');
  file.print(rainRaw); file.print(',');
  file.print(lightRaw); file.print(',');
  file.print(tankRaw); file.print(',');
  file.print(temperature); file.print(',');
  file.print(humidity); file.print(',');
  file.println(decision);
  file.close();
}

// ---------------------------------------------------------------------------
// Setup
// ---------------------------------------------------------------------------

void setup() {
  pinMode(PIN_RELAY, OUTPUT);
  setPump(false);

  Serial.begin(115200);
  gsm.begin(9600);

  dht.begin();
  lcd.init();
  lcd.backlight();

  if (SD.begin(PIN_SD_CS)) {
    File file = SD.open("saksham.csv", FILE_WRITE);
    if (file && file.size() == 0) {
      file.println("ms,soil_percent,rain_raw,light_raw,tank_raw,temp_c,humidity_percent,decision");
      file.close();
    }
  }

  lcd.setCursor(0, 0);
  lcd.print("SAKSHAM");
  lcd.setCursor(0, 1);
  lcd.print("Initializing...");
  delay(1500);
}

// ---------------------------------------------------------------------------
// Main control loop
// ---------------------------------------------------------------------------

void loop() {
  const int soilRaw = analogRead(PIN_SOIL);
  const int rainRaw = analogRead(PIN_RAIN);
  const int lightRaw = analogRead(PIN_LIGHT);
  const int tankRaw = analogRead(PIN_TANK);

  const int soil = soilPercentFromRaw(soilRaw);
  const float temperature = dht.readTemperature();
  const float humidity = dht.readHumidity();

  const bool rainDetected = rainRaw < RAIN_THRESHOLD_RAW;
  const bool strongSun = lightRaw > LIGHT_STRONG_RAW;
  const bool tankEmpty = tankRaw < TANK_EMPTY_RAW;

  String decision = "NO_WATER";
  unsigned long wateringTime = 0;

  // Safety / stop conditions have priority.
  if (tankEmpty) {
    decision = "TANK_EMPTY";
    setPump(false);
    showStatus(soil, temperature, false);
    sendSms("SAKSHAM alert: Water tank is empty. Pump stopped.");
  }
  else if (rainDetected) {
    decision = "RAIN_STOP";
    setPump(false);
    showStatus(soil, temperature, false);
  }
  else if (AVOID_STRONG_SUN && strongSun) {
    decision = "STRONG_SUN_DEFER";
    setPump(false);
    showStatus(soil, temperature, false);
  }
  else if (soil < 20) {
    decision = "HIGH_WATER";
    wateringTime = HIGH_WATER_MS;

    // Documented qualitative modifier: high temperature may increase watering.
    if (!isnan(temperature) && temperature > HIGH_TEMP_C) {
      wateringTime += 3000UL;
    }

    // Documented qualitative modifier: high humidity may reduce watering.
    if (!isnan(humidity) && humidity > HIGH_HUMIDITY_PERCENT && wateringTime > 3000UL) {
      wateringTime -= 3000UL;
    }

    setPump(true);
    showStatus(soil, temperature, true);
    delay(wateringTime);
    setPump(false);
  }
  else if (soil < 50) {
    decision = "PULSE_WATER";
    wateringTime = PULSE_WATER_MS;

    if (!isnan(temperature) && temperature > HIGH_TEMP_C) {
      wateringTime += 2000UL;
    }
    if (!isnan(humidity) && humidity > HIGH_HUMIDITY_PERCENT && wateringTime > 2000UL) {
      wateringTime -= 2000UL;
    }

    setPump(true);
    showStatus(soil, temperature, true);
    delay(wateringTime);
    setPump(false);
  }
  else {
    // 50–70% optimal and >70% wet are both no-watering states.
    decision = (soil <= 70) ? "OPTIMAL" : "WET";
    setPump(false);
    showStatus(soil, temperature, false);
  }

  Serial.print("Soil: "); Serial.print(soil); Serial.print("% | ");
  Serial.print("RainRaw: "); Serial.print(rainRaw); Serial.print(" | ");
  Serial.print("LightRaw: "); Serial.print(lightRaw); Serial.print(" | ");
  Serial.print("TankRaw: "); Serial.print(tankRaw); Serial.print(" | ");
  Serial.print("Temp: "); Serial.print(temperature); Serial.print(" C | ");
  Serial.print("Humidity: "); Serial.print(humidity); Serial.print("% | ");
  Serial.print("Decision: "); Serial.println(decision);

  logToSd(
    soil,
    rainRaw,
    lightRaw,
    tankRaw,
    temperature,
    humidity,
    decision
  );

  delay(CYCLE_DELAY_MS);
}

Open-Source Resources

Download the SAKSHAM reference firmware and circuit/interconnection diagram for educational and research study.

Download Reference Code Download Circuit Diagram GitHub →

OpenSource Section — SB.Chetak Innovation

This project resource is shared for educational and research purposes. Calibrate sensors for the actual soil and hardware, verify component specifications, and clearly identify modified versions of the published reference implementation.