Combatting a Real World Problem

 

Project: pH Regulator

About this Project:

This project was designed to help stimulate a solution to the rising problem with acidification in small bodies of water. The purpose of this project is to help protect marine life so that they do not perish due to unsuitable aquatic conditions. We created a smaller scale, fully functional project to illustrate how the pH levels can stay regulated. By applying this concept on a bigger scale to ensure that the optimal pH level of the water is from 6.5 to 9, larger bodies of water, such as lakes or ponds can be a safer environment.

Material Needed for this Project:


Overview/ Explanation of Set Up:
For our smaller scaled experiment, we tested the pH level of diluted acid using the pH sensor given in an Arduino kit. By writing our own code through prior knowledge, the help of a website, and documentation, given by the kit, we managed to connect a hand made and self programmed water pump to the Arduino as well. When the pH of the acidic solution to neutralize the existing solution. The handmade water pump uses fast spinning blades located at the open bottom of the tube to create a vacuum through which the base solution rises. This basic solution is later transferred using tubes(in this case straws) into the acidic liquid. The pH levels and voltage are displayed on the serial monitor on the computer screen as a visual throughout the whole experiment.

To set up this project, we used the following material:
  • pH Sensor/ Meter(pH Probe ad pH Circuit Board)
  • Water Pump(built completely by hand)
  • 9V Battery
  • UNO R3 Arduino
  • Jumper wires
  • 5 Volt Relay
  • Computer with Arduino Software(I have mentioned how to download Arduino software previously on my blog)
  • USB Cord
  • Bread Board

Design Process and Diagram Set Up:

While coming up with a design for the set up, Nishka and I talked about all the different ways we could possibly set up our project so that it would work efficiently. We first thought of using a Raspberry Pi to connect the water motor, but that tactic proves fruitless.






We saw that we could connect the motor directly to the Arduino which would make our design more efficient and simple, eliminating other components what could possibly fail. This final design was the layout of our finished project.


As seen in the image, we thought that connecting the motor(which we indicated as at the location of "LIME WATER") to the Raspberry Pi would be the most efficient way, but later realized that there was an easier way.

Picture of Project Laid Out:



Arduino Code Needed for this Project:

//Some pH meter code from https://2020.igem.org/wiki/images/6/64/T--Botchan_Lab_Tokyo--Poster_Arduinosketch_pdf_pdf.pdf

// 5 Volt DC motor code was written using prior knowledge from previous projects


//Initial required setup

const int inPin = A1;  

const int outPin = 9; 

 

//Initializing needed variables

int sensorValue = 0;        

int outputValue = 0;        

#define SensorPin A1            

#define Offset 0.00           

#define interval 20

#define printInt 800

#define len  40    

int pH[len];  

int pHIndex=0;  

int motor = 4;

//initializes the program with the motor being off

bool motorON = false;


//Basic Setup

void setup(void) {

  pinMode(motor, OUTPUT);

  Serial.begin(9600);

  //Show that the program is starting

  Serial.println("pH Regulator has started:");    


}


 

//calculate the pH and voltage while considering millis()

void loop() {   

  static unsigned long firstTime = millis();

  static unsigned long printTime = millis();

  static float pHValue,voltage;

  if(millis()-firstTime > interval)


  {

      //calculate voltage and pH value

      pH[pHIndex++]=analogRead(SensorPin);

      if(pHIndex==len)pHIndex=0;

      voltage = avergearray(pH, len)*5.0/1024;

      pHValue = 3.5*voltage+Offset;

      firstTime=millis();


  }

  //Condition to print the voltage and pH value

  if(millis() - printTime > printInt)   

  {

        //prints voltage and pH values

        Serial.print("Voltage:");

        Serial.print(voltage,2);

        Serial.print("    pH value: ");

        Serial.println(pHValue);

        //Condition to start the motor

        if(pHValue <= 5.00){

          analogWrite(motor,255);

          delay(5000);

          //prints so the user knows that the motor has started

          Serial.println("Inside if condition");

            //adds a delay to the code so that the sensor has time to collect its data

            delay(1000);

        }

        //turns the motor off

        else {

          analogWrite(motor,0);

        }

        printTime=millis();

  }

}


 

//Determining and returning the voltage

double avergearray(int* arr, int num){


  int i;

  int max,min;

  double avg;

  long amount=0;

  

  //Return an error if the  value is not determinable

  if(num<=0){

    Serial.println("Error");

    return 0;

  }

  if(num<5){

    for(i=0;i<num;i++){

      amount+=arr[i];

    }

    avg = amount/num;

    return avg;

  }else{

    if(arr[0]<arr[1]){

      min = arr[0];max=arr[1];

    }

    else{

      min=arr[1];max=arr[0];

    }

    for(i=2;i<num;i++){

      if(arr[i]<min){

        amount+=min;      

        min=arr[i];

      }else {

        if(arr[i]>max){

          amount+=max;    

          max=arr[i];

        }else{

          amount+=arr[i]; 

        }

      }

    }

    avg = (double)amount/(num-2);

  }

  return avg;

}


By: Niti and Nishka Mirkhelkar







Comments

Popular posts from this blog

Arduino Project: Keypad