Allsensing Docs
올센싱 쇼핑몰올센싱 블로그
한국어
한국어
  • 올센싱 기술 문서
  • Product document
    • Allsensing
      • AGSM 사용 설명서
      • AGSM 아두이노 활용
      • AGSM IoT 활용(ESP32)
      • 올센싱 가스센서 모듈
      • 온습도센서(아날로그)
      • 온습도센서(디지털)
    • Nevadanano
      • 센서 특징
      • 디바이스 연결 방법
      • 통신프로토콜
      • 3.0/4.0/5.0 Version 변경사항
    • GSS
      • 설명
      • CozIR-LP2
      • CozIR-LP3
      • CozIR-Blink
        • 디바이스 연결 방법
        • 통신 프로토콜
          • 모드 설정 및 CO2 값 읽기
          • 인터페이스 유형별(UART,I2C) CO2값 읽기
          • Digital filter
          • UART Command
      • ExplorIR
        • 디바이스 연결 방법
        • 통신 프로토콜
          • 모드 설정 및 CO2 값 읽기
          • Digital filter
          • UART Command
      • SprintIR 6S
        • 디바이스 연결 방법
        • 통신 프로토콜
          • 모드 설정 및 CO2 값 읽기
          • Digital filter
          • UART Command
    • EC-Sens
      • 제품 종류 및 이론
      • EC Sense 센서 구동 회로
      • 가스 센서 모듈
      • TB600B(C),TB200B
      • TB420
      • DGM10
      • EC Sense DS4 Series
    • SST
    • Temp&Humi
      • ETH-01DV
      • ETH-01D
        • 디바이스 연결 방법
        • 통신 프로토콜
          • 온·습도 읽기
          • 온·습도 Resolution 읽기 및 쓰기
          • Sensor ID 읽기
          • Address 읽기 및 쓰기
        • Thingspeak 활용방법
    • Plantower
      • 디바이스 연결 방법
      • 통신 프로토콜
        • UART
        • I2C
    • DD Scientific
      • 배경지식
      • 회로도
        • 2전극 센서
        • 3전극 센서
        • DUAL Toxic
        • O2
        • 바이어스 센서
      • 애플리케이션
      • Q&A
  • 참고문서
    • 전기화학식 가스센서
      • 전기 화학식 가스 센서 Q&A
Powered by GitBook
On this page
  • 모드
  • 소스 코드
  • 시리얼 모니터
  • 시리얼 모니터
  1. Product document
  2. GSS
  3. ExplorIR
  4. 통신 프로토콜

모드 설정 및 CO2 값 읽기

모드

1. COMMAND 모드

- COMMAND를 기다리는 상태, 측정 X

2. Streaming 모드(default)

- 연속적으로 값을 측정함(초당 2회 측정), 측정 외 다른 Command시 100ms delay가 필요함

3. Polling 모드

- 센서 값 요청 시에만 응답, 센서 값 요청하지 않을 때에는 백그라운드에서 계속 측정을 수행함

Mode
Command
Description
Response

Command

K 0

명령어 기다리는 상태

K 00000

Streaming

K 1

연속적으로 값 측정

K 00001

Polling

K 2

센서 값 요청 시 에만 응답

K 00002

소스 코드

  • Streaming mode에서 CO2 값 읽기

#include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 13); //Uno Rx Tx (12 13) = SoftwareSerial
const char* Polling_mode = "K 2\r\n";
const char* Stream_mode = "K 1\r\n";
const char* Standby_mode = "K 0\r\n";  
bool tx_ready;
bool rx_ready; 
String str;
void setup() {
  Serial.begin(9600); //시리얼 통신 초기화
  mySerial.begin(9600); 
  while(!mySerial){} //시리얼 통신 포트가 연결되기 전까지 대기
  delay(14); // power on data ready
  mySerial.print(Stream_mode); //Polling 모드로 변경
  mySerial.print("Z\r\n");  //CO2값 읽기 명령
}                              
 
void loop() 
{
 if(rx_ready == 0) // overflow 처리
 {
   delay(31); // Measurement data ready
   if(mySerial.available()>0) //수신받은 데이터가 0 초과, 즉 데이터가 존재한다면
   { //버퍼에서 읽어드린 char의 데이터를 String 형태로 반환
    str = "";
    str = mySerial.readStringUntil('\n'); 
    Serial.println(str);
    rx_ready = 1;   
    tx_ready = 1;
   }
 }
 else if(tx_ready == 1)
  {
     mySerial.print("Z\r\n"); //CO2값 읽기 명령
     tx_ready = 0;
     rx_ready = 0;
  }
}

시리얼 모니터

  • Polling mode에서 CO2값 읽기

#include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 13); //Uno Rx Tx (12 13) = SoftwareSerial
const char* Polling_mode = "K 2\r\n";
const char* Stream_mode = "K 1\r\n";
const char* Standby_mode = "K 0\r\n";   
String str;
void setup() {
  Serial.begin(9600); //시리얼 통신 초기화
  mySerial.begin(9600); 
  while(!mySerial){} //시리얼 통신 포트가 연결되기 전까지 대기
  delay(14); // power on data ready
  mySerial.print(Polling_mode); //Polling 모드로 변경
}                              
 
void loop() 
{
 if(Serial.read() == 'R') 
 {
  mySerial.print("Z\r\n"); //CO2값 읽기 명령
 }
  if(mySerial.available()>0) //수신받은 데이터가 0 초과, 즉 데이터가 존재한다면
   { //버퍼에서 읽어드린 char의 데이터를 String 형태로 반환
    str = "";
    str = mySerial.readStringUntil('\n'); 
    Serial.println(str);
   }
}

시리얼 모니터

  • 시리얼 모니터에 'R' 입력 후 엔터

  • 응답

Previous통신 프로토콜NextDigital filter

Last updated 1 year ago