DO METER

Good day to everyone, A newbie in Programming in Arduino.

hi guys I am asking for help regarding Dissolved Oxygen meter. We have already established a connection between the DO meter and the Arduino, what we lack is the Program or code for the process we need, Our aim for this is to use the output of the DO meter which is a reading of dissolved oxygen and temp. we not so much concern about the temp. but we concern to the reading of Dissolved oxygen, what we want is to operate a relay On and Off using the a range of reading in the DO meter. for example if DO meter reads between 5-10 mG/L the relay must be ON otherwise if this is not obtain it will stop or off. Thats the only operation we need. I ask for help in other forum and they gave initial codes in order to establish a connection between the meter and the arduino. I attached here the Code that given to us and the picture of the meter.

this is my first topic raise in this forum.

Here it comes, we have a DO meter ( Lutron Oxygen Meter model: DO-5510 to be specific) and it has an RS232 serial connection to computer and we want to connect it to Arduino Uno board. I know how to interface the Do meter to the arduino board, but the problem is how can i use the output of the meter as an input or as a process so that we can make a program that control a relay which turns it on and off.

this meter has a 16 digit data stream in the format of this: D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0,

AND EACH digit indicate the following status:

D15 - Start Word= 02
D14 - Reading polarity for the Display
0 = Both upper and lower display value are "+"
1 = Upper "-", Lower "+"
2 = Upper "+", Lower "-"
3 = Both upper and lower display value are "-"

D13 - annunciator for lower display
0 = no symbol 1= degree celsius 2= degree farenheit

D12 & D11 - Annunciator for upper display
01 :degree celsius 07= mg/L
02 :degree farenheit 06= percent O2

D10 - Decimal Point (DP) for lower display
0 = No DP, 1=1DP, 2=2DP, 3= 3 DP

D10 - Decimal Point (DP) for Upper display
0 = No DP, 1=1DP, 2=2DP, 3= 3 DP

D8 to D5 Lower Display reading, D5=LSD, D8=MSD

D4 to D1 Upper Display reading, D1=LSD, D4=MSD

D0 = End Word =0D

RS232 setting
Baud rate 9600
parity No Parity
data bit no. 8 Data bits
stop bit 1 Stop bit.

MyProgram.ino (2.34 KB)

this is my first topic raise in this forum.

Don't be silly - I've already deleted at least one cross post, and your post count tells everyone that's nonsense.

DO NOT CROSS-POST, CROSS-POSTING WASTES TIME

Sorry I'll just trying in other Index maybe it will help me. I also posted it in the Sensor index.

Can you post a link to the datasheet for your DO meter.

This example seems to have 48 characters.

16 digit data stream in the format of this: D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0

If this is not a typical complete message please provide an example of a single complete message.

It is almost certainly easier to read all the data first and then try to figure out what it means rather than trying to figure it out as it arrives.

Have a look at the examples in Serial Input Basics. The second example may be appropriate for your project, but I will know better when I see the datasheet.

...R

Thank you for your response Sir/Maam Robin Ill appreciate your help.
here is the link for the manual of the DO meter, I just post a link because the manual size is more than the required mB for attachments, hope you consider it. here is the link DO-5510_Manual
that was the link for the manual of the DO meter. Thats the only thing we have with the USB 1.0 cable. In other forum they gave us a program which i Cannot interpret, to be honest I cant understand it at all. If ever can I ask for your guidance and some advices and techniques regarding the encoding of the program for this project. thank you in advance hope you consider my request. I will also attached here the code that given to us.

#include <SoftwareSerial.h>

int DigitCount;
char Polarity;
char Annun_lower,Annun_higher[2];
char DP_lower,DP_higher;
char Display_lower[4],Display_higher[4];

SoftwareSerial mySerial(2,3);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  mySerial.begin(9600);
  DigitCount = 15;
}

void ProcessData() {
//Put your code here to process received data
}

void loop() {
  // put your main code here, to run repeatedly:
  if (mySerial.available())
  {
    int RecvByte = mySerial.read();
    switch (DigitCount) {
      default:
        DigitCount = 15;
      case 15:
        if (RecvByte==2) DigitCount--;
        break;
      case 14:
        if (RecvByte>=0 && RecvByte<4)
        {
          Polarity = RecvByte;
          DigitCount--;
        }
        else
        {   //Out of range. Probably out of sync. Reset to start
          DigitCount = 15;
        }
        break;
      case 13:
        if (RecvByte>=0 && RecvByte<3)
        {
          Annun_lower = RecvByte;
          DigitCount--;
        }
        else
        {   //Out of range. Probably out of sync. Reset to start
          DigitCount = 15;
        }
        break;
      case 12:
      case 11:
        if (RecvByte>0 && RecvByte<8)
        {
          Annun_higher[12-DigitCount] = RecvByte;
          DigitCount--;
        }
        else
        {   //Out of range. Probably out of sync. Reset to start
          DigitCount = 15;
        }
        break;
      case 10:
        if (RecvByte>=0 && RecvByte<3)
        {
          DP_lower = RecvByte;
          DigitCount--;
        }
        else
        {   //Out of range. Probably out of sync. Reset to start
          DigitCount = 15;
        }
        break;
      case 9:
        if (RecvByte>=0 && RecvByte<3)
        {
          DP_higher = RecvByte;
          DigitCount--;
        }
        else
        {   //Out of range. Probably out of sync. Reset to start
          DigitCount = 15;
        }
        break;
      case 8:
      case 7:
      case 6:
      case 5:
        Display_lower[8-DigitCount] = RecvByte;
        DigitCount--;
        break;
      case 4:
      case 3:
      case 2:
      case 1:
        Display_higher[4-DigitCount] = RecvByte;
        DigitCount--;
        break;
      case 0:
        if (RecvByte==0x0d)
        {
          ProcessData();
        }
        DigitCount = 15;
        break;
    }
  }
}

that was the code given to us and I can interpret it a little bit but i dont know the function of each code, hope you can help me. Thank you and God bless.

First question - does the code you posted do anything useful (so I don't waste time repeating stuff)?

As far as I can see from page 13 of the manual the data uses 0x02 as a start marker and 0x0D as the end marker.

The 3rd example in Serial Input Basics should be able to receive the data if you change the start and end markers and if you change the datatype from char to byte.

...R

I don't know yet if that code is useful, because i don't know how to test it. When I run the program there is no Output written on the serial monitor. Can you teach me how can I know the output that the DO meter transmit to the arduino, I don't have any idea on how we can know the output given by the DO meter, how can I use this output to turn on/off a relay. please bear with me I am just starting with arduino programming and we need finish the program because the Final defense is on December, this project will decide whether we will graduate from our course or not. please help us. Thank you for your understanding.

Hi,

Can you please post a copy of your how you have the sensor connected, using a circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Tom.... :slight_smile:

sir tom i attached the drawing of our circuit. and we don't know if this circuit is correct, were just doing an experimentation. thanks.

chester25:
I don't know yet if that code is useful, because i don't know how to test it. When I run the program there is no Output written on the serial monitor.

For my purposes that means it is not doing anything useful.

Have you tried my code?

...R

Hi,
Your problem may be that the RS232 from the sensor is true 232, in that the signal goes from +5V to -5V.
The arduino input is setup for 0 to +5V signals.

You only need the TX output from the sensor. If you are using the jack plug, where are you getting the sensor Rx connection?

Tom.... :slight_smile:

Good day to Everyone,

I'm just asking for any help regarding to this topic, we decided as a group to change our Do meter into a DO sensor which is a product of Atlas Scientific, and has a code within, I asking for any help regarding the re-coding of this code,

//This code was written to be easy to understand.


#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){                         //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
    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
  }
}

I want to use PIN7 as an Output for the condition above which is only print High or Low in the serial monitor of the arduino, thank you in Advance for the help and learning that you will share to us. i will also attached a link for the sensor EZO™ Dissolved Oxygen Circuit | Atlas Scientific

I want to use PIN7 as an Output for the condition above

Just do it - you don't need to ask for permission.