Example Code for Arduino-Measure ORP Value

Last revision 2026/01/07

This article provides a comprehensive guide on measuring ORP (Oxidation-Reduction Potential) values using Arduino. It covers the necessary hardware and software preparations, wiring diagrams, and sample code to help users accurately measure ORP values.

Hardware Preparation

Software Preparation

Wiring Diagram

Analog_Sensor_Connect_Diagram

Other Preparation Work

  • Please use a stable and accurate 5.0 V DC power supply.
    The more accurate the voltage, the higher the measurement accuracy.

  • The ORP electrode can be used without calibration.
    Only if you suspect issues with the electrode quality or test results should you verify the electrode potential using an ORP standard solution to determine the error.

  • Before using the ORP electrode to measure different solutions, rinse it thoroughly.
    Deionized water is recommended.

  • Do not press the calibration button while the ORP probe is connected to the ORP meter board.
    Doing so may damage the ORP probe.

Sample Code

/*
# This sample codes is for testing the ORP meter V1.0.
 # Editor : YouYou
 # Date   : 2013.11.26
 # Product: ORP meter
 # SKU    : SEN0165
*/
#define VOLTAGE 5.00    //system voltage
#define OFFSET 0        //zero drift voltage
#define LED 13         //operating instructions

double orpValue;

#define ArrayLenth  40    //times of collection
#define orpPin 1          //orp meter output,connect to Arduino controller ADC pin

int orpArray[ArrayLenth];
int orpArrayIndex=0;

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;
}


void setup(void) {
  Serial.begin(9600);
  pinMode(LED,OUTPUT);
}

void loop(void) {
  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, convert the state of the LED indicator
  {
    printTime=millis()+800;
    Serial.print("ORP: ");
    Serial.print((int)orpValue);
        Serial.println("mV");
        digitalWrite(LED,1-digitalRead(LED));
  }
}

Result

Open the serial monitor of Arduino IDE , you will see the current ORP value.

Additional Information

Calibration Step

  • Immerse the ORP probe into the ORP standard solution.

  • Press and hold the calibration button to view the raw ORP value on the serial monitor (e.g., "ORP: 8mV").

  • Update the sample code by changing the value in #define OFFSET 0 to match the reading from above step (e.g., change to #define OFFSET 8).

  • Recompile and upload the code to complete the calibration.

  • Clean and immerse the probe into your target solution to view the accurate ORP measurements on the serial monitor.

Relationip between Temperature and ORP

Temperature_ORP_Relationship

Probe Maintenance

  • Before and after measurement, it is necessary to use deionized water to wash the electrode, in order to ensure precision. When measured in thick samples, you should wash the electrode with hot deionized water and repeatedly rinsed several times to remove anything sticking to the platinum sheet specimen.

  • Passivation will occur when the electrode has been used for a long time.The phenomenon can be seen when the sensitivity gradient decreases, has slow responses, or is reading data is not accurate. At this time,you should immerse the bottom electrode platinum sheet into 0.1M hydrochloric acid for 24 hours.

  • Electrode pollution or the liquid junction jam also can make the electrode passivation. At this time,you should select the appropriate cleaning solution based on the nature of the pollutant.

  • The electrode use cycle is about one year. After aging, it should be replaced with a new electrode in a timely manner.

Was this article helpful?

TOP