개발자/라즈베리파이4

아쿠아포닉스 ORP 센서 개요 1

지구빵집 2023. 1. 26. 15:46
반응형

 

 

 

산화 환원 전위 (ORP) 는 산화 환원이라고도 하며 물질(일반적으로 액체)이 산화 또는 환원되는지를 측정하는 전자 교환 전위입니다. 산화제는 항상 양의 ORP 값을 갖는 반면 환원제는 항상 음의 ORP 값을 갖습니다.

 

ORP는 일반적으로 물 시스템의 청결도와 폐기물, 파편 및 오염 물질의 분해를 측정하는 데 사용됩니다. Atlas Scientific은 로봇 응용 분야, 산업 공정 제어 또는 전자 제품 및 가전 제품의 대량 생산에서 ORP를 읽어야 하는 엔지니어를 위한 임베디드 솔루션을 제공합니다. 당사의 ORP 프로브 라인은 측정 환경의 정확도 및 강도 수준에 따라 소비자 등급 ORP에서 산업용 등급까지 다양한 등급으로 제공됩니다. 

 

Atlas Scientific Micro-ORP Probe 키트에는 임베디드 미세유체 ORP 모니터링 시스템을 만드는 데 필요한 모든 것이 포함되어 있습니다. 이 키트를 사용하면 micro-ORP 프로브에서 교정된 고정밀 판독값을 쉽게 얻을 수 있습니다.

 

Atlas Scientific Micro-ORP Probe는 미세 유체 공학 및 기타 소규모 응용 분야용으로 설계되었습니다. 프로브가 너무 작기 때문에 하프 셀 ORP 프로브로 제작해야 했습니다. ½ 셀 프로브는 일반 ORP 프로브처럼 작동하지만 작업 전극과 기준 전극의 두 부분으로 구성됩니다. 제공된 커넥터 보드는 일반 ORP 프로브처럼 두 개의 절반을 하나로 병합합니다. 

 

 

Embedded ORP Circuit

 

Specification

 

  • Reads ORP
  • Range -1019.9mV − 1019.9mV
  • Accuracy +/– 1mV
  • Response time1 reading per sec
  • Supported probes Any type & brand
  • Calibration Single point
  • Temp. compensation N/A
  • Data protocol UART & I2C
  • Default I2C address 98 (0x62)
  • Operating voltage 3.3V − 5V
  • Data format ASCII
  • Circuit dimensions 13.97mm x 20.16mm (0.55″ x 0.79″)
  • Weight 1.86 grams

 

수작업으로 I2C 모드로 설정하는 방법(I2C 모드 -> UART 모드, UART 모드 -> I2C 모드 토글링) 

 

아래 절차를 간단히 설명하면 전원 OFF 하고 모든 연결이 없는 상태에서 VCC와 GND를 연결하고, TX와 PGND 를 연결하고 전원을 ON하면 LED 색이 녹색에서 파란색으로 변경된다. 그러면 I2C 설정으로 완료한 상태다. 모든 연결선과 전원을 분리한다. 

 

 

Manually switching to I2C will set the I2C address to 98 (0x62)

 

 

만약 다시 위와 똑같이 연결하고 전원을 넣으면 이번에는 반대로 LED가 파란색에서 녹색으로 바뀌는데 바로 UART 모드로 설정이 된다. 토글 방식으로 설정된다는 것을 알 수 있다.  

 

1. Disconnect ground (power off)

2. Disconnect TX and RX

3. Connect TX to PGND

4. Confirm RX is disconnected

5. Connect ground (power on)

6. Wait for LED to change from Green to Blue

7. Disconnect ground (power off)

8. Reconnect all data and power 

 

 

아래 코드는 I2C 모드로 세팅하고 아두이노 sample 코드를 업로딩하여 실행했는데 no data 만 나온다. 4.7K 저항을 달지 않았는데 다시 테스트 하기로 하고 코드만 올려둔다. 코드 출처는 아래 참고 링크를 참고한다.

 

//This code will work on an Arduino Uno and Mega
//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 ORP circuit.
//This code was written in the Arduino 1.8.9 IDE
//This code was last tested 7/2019


#include <Wire.h>                //enable I2C.
#define address 98               //default I2C ID number for EZO ORP Circuit.

char computerdata[20];           //we make a 20 byte character array to hold incoming data from a pc/mac/other.
byte received_from_computer = 0; //we need to know how many characters have been received.
byte serial_event = 0;           //a flag to signal when data has been received from the pc/mac/other.
byte code = 0;                   //used to hold the I2C response code.
char ORP_data[20];               //we make a 20 byte character array to hold incoming data from the ORP circuit.
byte in_char = 0;                //used as a 1 byte buffer to store inbound bytes from the ORP Circuit.
byte i = 0;                      //counter used for ORP_data array.
int time_ = 815;                 //used to change the delay needed depending on the command sent to the EZO Class ORP Circuit.
float ORP_float;                 //float var used to hold the float value of the ORP.


void setup()                    //hardware initialization.
{
  Serial.begin(9600);           //enable serial port.
  Wire.begin();                 //enable I2C port.
}


void serialEvent() {                                                              //this interrupt will trigger when the data coming from the serial monitor(pc/mac/other) is received.
  received_from_computer = Serial.readBytesUntil(13, computerdata, 20);           //we read the data sent from the serial monitor(pc/mac/other) until we see a <CR>. We also count how many characters have been received.
  computerdata[received_from_computer] = 0;                                       //stop the buffer from transmitting leftovers or garbage.
  serial_event = true;                                                            //set the serial event flag.
}


void loop() {      
  
                                                                                  //the main loop.
  //if (serial_event == true) {                                                     //if a command was sent to the EZO device.
    for (i = 0; i <= received_from_computer; i++) {                               //set all char to lower case, this is just so this exact sample code can recognize the "sleep" command.
      computerdata[i] = tolower(computerdata[i]);                                 //"Sleep" ≠ "sleep"
    }
    i=0;                                                                          //reset i, we will need it later 
    if (computerdata[0] == 'c' || computerdata[0] == 'r')time_ = 815;             //if a command has been sent to calibrate or take a reading we wait 815ms so that the circuit has time to take the reading.
    else time_ = 250;                                                             //if any other command has been sent we wait only 250ms.

    
    Wire.beginTransmission(address);                                              //call the circuit by its ID number.
    Wire.write(computerdata);                                                     //transmit the command that was sent through the serial port.
    Wire.endTransmission();                                                       //end the I2C data transmission.


    if (strcmp(computerdata, "sleep") != 0) {  	                                  //if the command that has been sent is NOT the sleep command, wait the correct amount of time and request data.
                                                                                  //if it is the sleep command, we do nothing. Issuing a sleep command and then requesting data will wake the circuit.
      
      delay(time_);								                                                //wait the correct amount of time for the circuit to complete its instruction.

      Wire.requestFrom(address, 20, 1); 		                                      //call the circuit and request 20 bytes (this may be more than we need)
      code = Wire.read();               		                                      //the first byte is the response code, we read this separately.

      switch (code) {							          //switch case based on what the response code is.
        case 1:                         		//decimal 1.
          Serial.println("Success");        //means the command was successful.
          break;                        		//exits the switch case.

        case 2:                         		//decimal 2.
          Serial.println("Failed");     		//means the command has failed.
          break;                        		//exits the switch case.

        case 254:                       		//decimal 254.
          Serial.println("Pending");    		//means the command has not yet been finished calculating.
          break;                        		//exits the switch case.

        case 255:                       		//decimal 255.
          Serial.println("No Data");    		//means there is no further data to send.
          break;                        		//exits the switch case.
      }

      while (Wire.available()) {            //are there bytes to receive.
        in_char = Wire.read();           		//receive a byte.
        ORP_data[i] = in_char;					    //load this byte into our array.
        i += 1;                          		//incur the counter for the array element.
        if (in_char == 0) {              		//if we see that we have been sent a null command.
          i = 0;                         		//reset the counter i to 0.
          break;                         		//exit the while loop.
        }
      }

      Serial.println(ORP_data);          		//print the data.
    }
    serial_event = false;                   //reset the serial event flag.
 // }
  //Uncomment this section if you want to take the ORP value and convert it into floating point number.
  //ORP_float=atof(ORP_data);
}

 

 

참고

ORP 산화환원전위란? Oxidation Reduction Potential, ORP 

샘플 코드 EZO ORP Cuit 

 

 

 

 

반응형