Arduino code explaination
Arduino code explaination
monitors pH, EC, and water levels. The code assumes you are using analog
sensors for pH and EC, and digital sensors for water levels. It also controls
dosing pumps for nutrients A and B based on the pH and EC readings, and a
water pump for irrigation.
// Pin Definitions
// pH and EC thresholds
Serial.begin(9600);
pinMode(pHPumpPin, OUTPUT);
pinMode(basePumpPin, OUTPUT);
pinMode(waterPumpPin, OUTPUT);
pinMode(nutrientAPumpPin, OUTPUT);
pinMode(nutrientBPumpPin, OUTPUT);
pinMode(waterLevelPin, INPUT);
void loop() {
Serial.print("pH: ");
Serial.println(pH);
Serial.print("EC: ");
Serial.println(EC);
Serial.println("Low");
} else {
Serial.println("High");
if (waterLevel == LOW) {
float readPH() {
return pH;
float readEC() {
int sensorValue = analogRead(ECPin); // Read the EC sensor value (0-1023)
return EC;
1. Pin Assignments: The analog and digital pins are assigned to the pH
sensor, EC sensor, water level sensor, and actuators (pumps and
valves).
3. Control Logic:
4. Pump Timing: The pumps are activated for 1 second (or 2 seconds for
the water pump), but this can be adjusted according to your system's
requirements.
Key Notes:
This Arduino code is a basic framework for your hydroponic irrigation system.
You may need to fine-tune the sensor reading logic and pump control based
on your specific hardware and system design.