Arduino Dissolved Oxygen Sensor Calibration

Arduino Dissolved Oxygen Sensor Calibration © CC BY-NC

Calibrating Atlas Scientifc's EZO D.O sensor using Arduino Uno.

  • 1,246 views
  • 0 comments
  • 5 respects

Components and supplies

Apps and online services

About this project

Calibration Theory

The most important part of calibration is watching the readings during the calibration process. It is easiest to calibrate the device in its default state (UART mode, with continuous readings enabled). Switching the device to I2C mode after calibration will not affect the stored calibration. If the device must be calibrated in I2C mode be sure to continuously request readings so you can see the output from the probe. In this tutorial, the calibration will be done in UART mode.

The Atlas dissolved oxygen circuit has a flexible calibration protocol, allowing fora single point or dual point (optional) calibration. Temperature, salinity and pressure compensation values have no effect on calibration. Do the calibration first and compensate for these parameters later.

Assemble Hardware

The kit includes 1 EZO D.O circuit, 1 D.O probe, 1 female BNC connector, 1- 4oz calibration solution.

Ensure that the D.O circuit is in UART mode. For instructions on switching between protocols, refer to the following LINK.

Use a breadboard to mount the circuit and BNC connector. Wire the D.O circuit to the Arduino Uno as shown in the schematic above and connect the probe to the BNC connector.

Load Program Onto Arduino Uno

a) Download the sample code from this LINK. It will be in a folder titled "arduino_UNO_DO_sample_code"

b) Connect the Arduino to your computer.

c) Open the code downloaded from step a, in your Arduino IDE. If you do not have the IDE you can download it from HERE.

d) Compile and upload the code to Arduino.

e) Open the serial monitor. For access go to Tools -> Serial Monitor or press Ctrl+Shift+M on your keyboard. Set the baud rate to 9600 and select "Carriage return". You should now be able to communicate with the D.O circuit. As a test, enter the command i which will return the device information.

Single Point Calibration

a) Carefully pull off and discard the cap from the D.O probe.

b) Let the probe sit, exposed to air until the readings stabilize. Note: Small movement from one reading to the next is normal.

c) Once the readings have stabilized issue the calibration command cal in the serial monitor.

After calibration is complete, you should see readings between 9.09 - 9.1x mg/L, only if temperature, salinity and pressure compensation are at the default values.

default temperature = 20°C, default salinity = 0, default pressure = 101.3kPa

Dual Point Calibration

Note: Only perform this calibration if you require accurate readings below 1 mg/L.

a) After you have calibrated the D.O circuit using the "cal" command; place the probe into the calibration solution. Stir the probe around to remove trapped air (which could cause readings to go high).

b) Let the probe sit in the calibration solution until the readings stabilize. Note: Small movement from one reading to the next is normal.

c) Once the readings have stabilized issue the calibration command cal,0 in the serial monitor.

Code

arduino dissolved oxygen sensor calibration codeC/C++
//This code was written to be easy to understand.
//Modify this code as you see fit.
//This code will output data to the Arduino serial monitor.
//Type commands into the Arduino serial monitor to control the D.O. circuit.
//This code was written in the Arduino 1.8.9 IDE
//An Arduino UNO was used to test this code.
//This code was last tested 6/2019


#include <SoftwareSerial.h>                           //we have to include the SoftwareSerial library, or else we can't use it
#define rx 2                                          //define what pin rx is going to be
#define tx 3                                          //define what pin tx is going to be

SoftwareSerial myserial(rx, tx);                      //define how the soft serial port is going to work


String inputstring = "";                              //a string to hold incoming data from the PC
String sensorstring = "";                             //a string to hold the data from the Atlas Scientific product
boolean input_string_complete = false;                //have we received all the data from the PC
boolean sensor_string_complete = false;               //have we received all the data from the Atlas Scientific product
float DO;                                             //used to hold a floating point number that is the DO



void setup() {                                        //set up the hardware
  Serial.begin(9600);                                 //set baud rate for the hardware serial port_0 to 9600
  myserial.begin(9600);                               //set baud rate for the software serial port to 9600
  inputstring.reserve(10);                            //set aside some bytes for receiving data from the PC
  sensorstring.reserve(30);                           //set aside some bytes for receiving data from Atlas Scientific product
}


void serialEvent() {                                  //if the hardware serial port_0 receives a char
  inputstring = Serial.readStringUntil(13);           //read the string until we see a <CR>
  input_string_complete = true;                       //set the flag used to tell if we have received a completed string from the PC
}


void loop() {                                         //here we go...

  if (input_string_complete == true) {                //if a string from the PC has been received in its entirety
    myserial.print(inputstring);                      //send that string to the Atlas Scientific product
    myserial.print('\r');                             //add a <CR> to the end of the string
    inputstring = "";                                 //clear the string
    input_string_complete = false;                    //reset the flag used to tell if we have received a completed string from the PC
  }

  if (myserial.available() > 0) {                     //if we see that the Atlas Scientific product has sent a character
    char inchar = (char)myserial.read();              //get the char we just received
    sensorstring += inchar;                           //add the char to the var called sensorstring
    if (inchar == '\r') {                             //if the incoming character is a <CR>
      sensor_string_complete = true;                  //set the flag
    }
  }


  if (sensor_string_complete == true) {               //if a string from the Atlas Scientific product has been received in its entirety
    Serial.println(sensorstring);                     //send that string to the PC's serial monitor
    /*                                                //uncomment this section to see how to convert the DO reading from a string to a float 
    if (isdigit(sensorstring[0])) {                   //if the first character in the string is a digit
      DO = sensorstring.toFloat();                    //convert the string to a floating point number so it can be evaluated by the Arduino
      if (DO >= 6.0) {                                //if the DO is greater than or equal to 6.0
        Serial.println("high");                       //print "high" this is demonstrating that the Arduino is evaluating the DO as a number and not as a string
      }
      if (DO <= 5.99) {                               //if the DO is less than or equal to 5.99
        Serial.println("low");                        //print "low" this is demonstrating that the Arduino is evaluating the DO as a number and not as a string
      }
    }
   */
    sensorstring = "";                                //clear the string
    sensor_string_complete = false;                   //reset the flag used to tell if we have received a completed string from the Atlas Scientific product
  }
}

Schematics

arduino dissolved oxygen sensor calibration wiring diagram
Do probe calibration wiring diagram hb1vqraygu

Comments

Similar projects you might like

DIY pH Dosing Pump

by Atlas Scientific

  • 1,668 views
  • 2 comments
  • 14 respects

Smoke Detection using MQ-2 Gas Sensor

by Aritro Mukherjee

  • 270,182 views
  • 47 comments
  • 169 respects

How To Use DS18B20 Water Proof Temperature Sensor

Project showcase by IoTBoys

  • 71,406 views
  • 13 comments
  • 20 respects
Add projectSign up / Login