Sitemap / Advertise

Information



Tags



Share

How to use and calibrate DFRobot Analog ORP Sensor Meter for Arduino

Advertisement:


read_later

Read Later

Keywords



Keywords



read_later

Read Later

Information

Tags

Share





Advertisement

Advertisement




Definition

In this tutorial, I will show you how to use and calibrate the Analog ORP Sensor Meter with Arduino.

Introduction(1)

ORP(Oxidation-Reduction Potential) is a measure of the ability of oxidation and reduction of an aqueous solution, which is the relative degree of the oxidizing or reducing - unit is mV. If the oxidation-reduction potential is high, then chemical oxidation is strong. And, if the potential is lower, then oxidation is weaker. The positive potential means that the solution shows a certain degree of oxidation. And, the negative potential indicates that the solution shows a certain degree of reduction.

ORP is an important index of water quality detection, although it is not enough to predict water quality-related environmental side effects. However, it can be combined with other water quality indexes to reflect the ecological environment better.

The measuring element is an ORP composite electrode made of gold or platinum electrode. It used to measure Oxidation-Reduction Potential of the solution.

Connections and Calibration(1)

Connect the ORP probe circuit board to the Arduino Uno.

If needed, to calibrate the ORP sensor, press the calibration button on the board and keep it pressed until seeing a small ORP value printed on the serial monitor. Then according to this value, modify the offset in the code. For instance, if it generates 8mV, then change the offset (OFFSET) from 0 to 8 in the code.

Do not calibrate the sensor while the ORP probe (BNC connector) is connected to the ORP electrode.

article-image
Figure - 135.1

For more information, click here.

Code

You can inspect the algorithm I used to generate ORP values from here.


-------------- Arduino --------------


// Define the default variables of the ORP sensor.
#define VOLTAGE 5.00    //system voltage
#define OFFSET 0        //zero drift voltage
#define ArrayLenth  40  //times of collection
#define orpPin A0       //orp meter output,connect to Arduino controller ADC pin
int orpArray[ArrayLenth];
int orpArrayIndex=0;
double orpValue;


void read_ORP_Sensor(){
  static unsigned long orpTimer=millis();   //analog sampling interval
  static unsigned long printTime=millis();
    if(millis() >= orpTimer){
      orpTimer=millis()+20;
      orpArray[orpArrayIndex++]=analogRead(orpPin);    //read an analog value every 20ms
      if (orpArrayIndex==ArrayLenth) {
        orpArrayIndex=0;
      }   
      orpValue=((30*(double)VOLTAGE*1000)-(75*avergearray(orpArray, ArrayLenth)*VOLTAGE*1000/1024))/75-OFFSET;   //convert the analog value to orp according the circuit
    }
    if(millis() >= printTime){   //Every 800 milliseconds, print a numerical
      printTime=millis()+800;
      ORP = String((int)orpValue);
      String line = "      " + ORP + "     ";
      // Convert the data from string to unsingned char to be able to print it.
      String_to_UnChar(line, 16, _ORP);
  }

}

  double avergearray(int* arr, int number){
    int i;
    int max,min;
    double avg;
    long amount=0;
    if(number<=0){
      printf("Error number for the array to avraging!/n");
      return 0;
    }
    if(number<5){   //less than 5, calculated directly statistics
      for(i=0;i<number;i++){
        amount+=arr[i];
      }
      avg = amount/number;
      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<number;i++){
        if(arr[i]<min){
          amount+=min;        //arr<min
          min=arr[i];
        }else {
          if(arr[i]>max){
            amount+=max;    //arr>max
            max=arr[i];
          }else{
            amount+=arr[i]; //min<=arr<=max
          }
        }//if
      }//for
      avg = (double)amount/(number-2);
    }//if
    return avg;
  }

Result:

You can inspect my electronics project in which I used DFRobot Analog ORP Sensor Meter from here.

References

(1) https://wiki.dfrobot.com/Analog_ORP_Meter_SKU_SEN0165_