diff --git a/.DS_Store b/.DS_Store index 813e27a..0c7ec6b 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Arduino to Pi Testing/.DS_Store b/Arduino to Pi Testing/.DS_Store index 49a5c19..66857de 100644 Binary files a/Arduino to Pi Testing/.DS_Store and b/Arduino to Pi Testing/.DS_Store differ diff --git a/Arduino to Pi Testing/pump_primer/pump_primer.ino/pump_primer.ino.ino b/Arduino to Pi Testing/pump_primer/pump_primer.ino/pump_primer.ino.ino new file mode 100644 index 0000000..de6f8a1 --- /dev/null +++ b/Arduino to Pi Testing/pump_primer/pump_primer.ino/pump_primer.ino.ino @@ -0,0 +1,68 @@ +#include +#include + +// Define the pumps +Ezo_board PMP1 = Ezo_board(56, "PMP1"); // pH up +Ezo_board PMP2 = Ezo_board(57, "PMP2"); // pH down +Ezo_board PMP3 = Ezo_board(58, "PMP3"); // Nutrient pump + +// Track the state of each pump +bool pmp1_running = false; +bool pmp2_running = false; +bool pmp3_running = false; + +void setup() { + Serial.begin(9600); + Wire.begin(); + Serial.println("Enter pump number (1, 2, or 3) to toggle it on/off."); +} + +void loop() { + if (Serial.available() > 0) { + char command = Serial.read(); + + switch (command) { + case '1': // Toggle PMP1 + if (!pmp1_running) { + PMP1.send_cmd("d,100"); // Start PMP1 with indefinite dispensing rate + pmp1_running = true; + Serial.println("PMP1 ON"); + } else { + PMP1.send_cmd("d,0"); // Stop PMP1 + pmp1_running = false; + Serial.println("PMP1 OFF"); + } + break; + + case '2': // Toggle PMP2 + if (!pmp2_running) { + PMP2.send_cmd("d,100"); // Start PMP2 with indefinite dispensing rate + pmp2_running = true; + Serial.println("PMP2 ON"); + } else { + PMP2.send_cmd("d,0"); // Stop PMP2 + pmp2_running = false; + Serial.println("PMP2 OFF"); + } + break; + + case '3': // Toggle PMP3 + if (!pmp3_running) { + PMP3.send_cmd("d,100"); // Start PMP3 with indefinite dispensing rate + pmp3_running = true; + Serial.println("PMP3 ON"); + } else { + PMP3.send_cmd("d,0"); // Stop PMP3 + pmp3_running = false; + Serial.println("PMP3 OFF"); + } + break; + + default: + Serial.println("Invalid input. Enter 1, 2, or 3 to toggle a pump."); + break; + } + } + + delay(100); // Short delay to avoid rapid serial checks +} \ No newline at end of file diff --git a/Engine/wired_to_pi/.DS_Store b/Arduino to Pi Testing/wired_to_pi/.DS_Store similarity index 100% rename from Engine/wired_to_pi/.DS_Store rename to Arduino to Pi Testing/wired_to_pi/.DS_Store diff --git a/Engine/wired_to_pi/wired_to_pi.ino b/Arduino to Pi Testing/wired_to_pi/wired_to_pi.ino similarity index 100% rename from Engine/wired_to_pi/wired_to_pi.ino rename to Arduino to Pi Testing/wired_to_pi/wired_to_pi.ino diff --git a/Arduino to Pi Testing/wired_to_pi_no_PMP3/wired_to_pi_no_PMP3/wired_to_pi_no_PMP3.ino b/Arduino to Pi Testing/wired_to_pi_no_PMP3/wired_to_pi_no_PMP3/wired_to_pi_no_PMP3.ino new file mode 100644 index 0000000..f4c9783 --- /dev/null +++ b/Arduino to Pi Testing/wired_to_pi_no_PMP3/wired_to_pi_no_PMP3/wired_to_pi_no_PMP3.ino @@ -0,0 +1,101 @@ +#include +#include + +// Define the sensors and pumps +Ezo_board PH = Ezo_board(99, "PH"); +Ezo_board EC = Ezo_board(100, "EC"); +Ezo_board RTD = Ezo_board(102, "RTD"); +Ezo_board PMP1 = Ezo_board(56, "PMP1"); // pH up +Ezo_board PMP2 = Ezo_board(57, "PMP2"); // pH down + +// Thresholds for pump control +float PH_LOWER_LIMIT = 5.5; +float PH_UPPER_LIMIT = 6.5; +float EC_LOWER_LIMIT = 1000.0; +float EC_UPPER_LIMIT = 2000.0; +float PUMP_DOSE = -0.5; // Example dose + +void setup() { + Serial.begin(9600); + Wire.begin(); + Serial.println("Arduino Ready"); // Signal that Arduino is ready +} + +void loop() { + if (Serial.available() > 0) { + char command = Serial.read(); + if (command == 'R') { // 'R' for Read sensors + poll_sensors(); + } + else if (command == 'P') { // 'P' for Pump control + control_pumps(); + } + } + delay(100); // Small delay for stability +} + +// Function to read and print sensor values +void poll_sensors() { + float ph_value = read_ph(); + float ec_value = read_ec(); + float temp_value = read_temp(); + + Serial.print("pH: "); Serial.println(ph_value); + Serial.print("EC: "); Serial.println(ec_value); + Serial.print("Temperature: "); Serial.println(temp_value); +} + +// Function to control pumps based on thresholds +void control_pumps() { + float ph_value = read_ph(); + + // pH control logic + if (ph_value < PH_LOWER_LIMIT) { + Serial.println("pH below limit. Triggering PMP1..."); + PMP1.send_cmd_with_num("d,", PUMP_DOSE); // Dispense pH up + } else if (ph_value > PH_UPPER_LIMIT) { + Serial.println("pH above limit. Triggering PMP2..."); + PMP2.send_cmd_with_num("d,", PUMP_DOSE); // Dispense pH down + } else { + Serial.println("pH is within range."); + } +} + +// Function to read pH value +float read_ph() { + char sensordata_buffer[32]; + PH.send_read_cmd(); + delay(1000); // Wait for sensor response + if (PH.receive_cmd(sensordata_buffer, sizeof(sensordata_buffer)) == Ezo_board::SUCCESS) { + return String(sensordata_buffer).toFloat(); + } else { + Serial.println("Error reading pH sensor."); + return -1; + } +} + +// Function to read EC value +float read_ec() { + char sensordata_buffer[32]; + EC.send_read_cmd(); + delay(1000); + if (EC.receive_cmd(sensordata_buffer, sizeof(sensordata_buffer)) == Ezo_board::SUCCESS) { + return String(sensordata_buffer).toFloat(); + } else { + Serial.println("Error reading EC sensor."); + return -1; + } +} + +// Function to read Temperature value +float read_temp() { + char sensordata_buffer[32]; + RTD.send_read_cmd(); + delay(1000); + if (RTD.receive_cmd(sensordata_buffer, sizeof(sensordata_buffer)) == Ezo_board::SUCCESS) { + return String(sensordata_buffer).toFloat(); + } else { + Serial.println("Error reading Temperature sensor."); + return -1; + } +} \ No newline at end of file diff --git a/Engine/.DS_Store b/Engine/.DS_Store index e0d30ac..6fde80e 100644 Binary files a/Engine/.DS_Store and b/Engine/.DS_Store differ diff --git a/Engine/wired_to_pi_v5/.DS_Store b/Engine/wired_to_pi_v5/.DS_Store new file mode 100644 index 0000000..8abf525 Binary files /dev/null and b/Engine/wired_to_pi_v5/.DS_Store differ