공기질 센서는 NH3, NOx, 알코올, 벤젠, 연기 및 CO2를 포함한 광범위한 가스를 감지하기 위한 것입니다. 사무실이나 공장에서 사용하기에 이상적이며 간단한 구동 및 공기질 모니터링 센서입니다.
MQ135 센서를 사용하기 전에 예열해야 합니다. 즉, 5V에 연결하고 최소 12-24 시간 동안 실행해야 합니다. 그 후 측정 값을 보정해야 합니다.
센서 파트 넘버: MQ-135 Air quality hazardous gas sensor module
MQ135 공기질 센서 이미지


LM393 칩셋, MQ135 가스 센서 기반 / 이산화탄소(CO2), 암모니아(NH3), 질소 산화물(NOx), 알콜류, 벤젠 및 연기 등 유해가스, 공기질 센서 / DC 5V / Size: 32mm * 22mm
Technical Specification
- 메인 칩: LM393, MQ135
- 가스 감지 프로브 작동 전압: DC 5V
- 신호 출력 표시기 지침; 이중 신호 출력(아날로그 출력 및 TTL 레벨 출력);
- TTL 출력 유효 신호가 낮습니다. (마이크로 컨트롤러 IO 포트에 액세스할 수 있는 출력 낮은 신호 표시등)
- 농도가 증가하면 아날로그 출력이 증가하고 농도가 높을수록 전압이 높아집니다.
- 황화물, 벤젠 고감도의 증기, 연기 및 기타 유해 가스
- 수명이 길고 안정적인 안정성이 있습니다.
- 신속한 응답 회복 특성;
MQ 시리즈 가스 센서 종류
MQ-2 Methane, Butane, LPG, Smoke
MQ-3 Alcohol, Ethanol, Smoke
MQ-4 Methane, CNG Gas
MQ-5 Natural gas, LPG
MQ-6 LPG, butane
MQ-7 Carbon Monoxide
MQ-8 Hydrogen Gas
MQ-9 Carbon Monoxide, flammable gasses
MQ131 Ozone
MQ135 Air Quality
MQ136 Hydrogen Sulphide gas
MQ137 Ammonia
MQ138 Benzene, Toluene, Alcohol, Propane, Formaldehyde gas, Hydrogen
MQ214 Methane, Natural Gas
MQ216 Natural gas, Coal Gas
MQ303 AAlcohol, Ethanol, smoke
MQ306 ALPG, butane
MQ307 ACarbon Monoxide
MQ309 ACarbon Monoxide, flammable gas
연결도
- 파일 이름: gasdetect.c
- 소스코드: 할당된 gpio 번호는 예고없이 변경할 수 있습니다.
공기질 센서 출력을 폴링 방식으로 데이터 얻는 코드
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <wiringPi.h>
// Use GPIO Pin 7, which is Pin 11 for wiringPi library
#define AIRCHECK 6 //gpio7
// the event counter
volatile int eventCounter = 0;
// -------------------------------------------------------------------------
// myInterrupt: called every time an event occurs
void myInterrupt(void) {
eventCounter++;
}
// main
int main(void)
{
// sets up the wiringPi library
if (wiringPiSetup () < 0)
{
fprintf (stderr, "Unable to setup wiringPi: %s\n", strerror (errno));
return 1;
}
pinMode(AIRCHECK, INPUT);
// set Pin 17/0 generate an interrupt on high-to-low transitions
// and attach myInterrupt() to the interrupt
/*if ( wiringPiISR (LIGHTSEN_OUT, INT_EDGE_RISING, &myInterrupt) < 0 )
{
fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno));
return 1;
}*/
// display counter value every second.
while ( 1 )
{
//printf( "%d\n", eventCounter );
//eventCounter = 0;
if(digitalRead(AIRCHECK) == 0)
printf("Air Check-Bad !!!!!!!!!!!\n");
if(digitalRead(AIRCHECK) == 1)
printf("Air Check-Good \n");
delay( 100 ); // wait 1 second
}
return 0;
}
아래는 인터럽트 방식으로 데이터를 얻는 코드
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <wiringPi.h>
// Use GPIO Pin 17, which is Pin 0 for wiringPi library
#define AIRCHECK 6 //gpio17
// the event counter
volatile int eventCounter = 0;
// -------------------------------------------------------------------------
// myInterrupt: called every time an event occurs
void myInterrupt(void) {
eventCounter++;
}
// -------------------------------------------------------------------------
// main
int main(void) {
// sets up the wiringPi library
if (wiringPiSetup () < 0) {
fprintf (stderr, "Unable to setup wiringPi: %s\n", strerror (errno));
return 1;
}
// set Pin 17/0 generate an interrupt on high-to-low transitions
// and attach myInterrupt() to the interrupt
if ( wiringPiISR (AIRCHECK, INT_EDGE_FALLING, &myInterrupt) < 0 ) {
fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno));
return 1;
}
// display counter value every second.
while ( 1 ) {
printf( "%d\n", eventCounter );
//eventCounter = 0;
delay( 1000 ); // wait 1 second
}
return 0;
}
참고
MQ-135 Air quality hazardous gas sensor module 공기질/위험가스
'개발자 > 라즈베리파이4' 카테고리의 다른 글
| 라즈베리파이4 센서 8종 테스트 코드 C언어 (0) | 2022.06.09 |
|---|---|
| 라즈베리파이 4 워터 펌프 코드 (0) | 2022.06.08 |
| 라즈베리파이4 소리 센서, 사운드 센서 실습 (0) | 2022.06.07 |
| 라즈베리파이4 온도 습도센서 실습 코드 (0) | 2022.06.01 |
| 라즈베리파이4 화염 불꽃 감지 센서 모듈 Flame Sensor (4) | 2022.05.27 |
| 라즈베리파이 4 조도 센서, 빛 센서 실습 (0) | 2022.05.25 |
| 라즈베리파이 4 근접 센서 실습 코드 (0) | 2022.05.23 |
| 라즈베리파이4 데이터베이스 브라우저 연동 테스트 에러 해결 (0) | 2022.05.22 |
취업, 창업의 막막함, 외주 관리, 제품 부재!
당신의 고민은 무엇입니까? 현실과 동떨어진 교육, 실패만 반복하는 외주 계약,
아이디어는 있지만 구현할 기술이 없는 막막함.
우리는 알고 있습니다. 문제의 원인은 '명확한 학습, 실전 경험과 신뢰할 수 있는 기술력의 부재'에서 시작됩니다.
이제 고민을 멈추고, 캐어랩을 만나세요!
코딩(펌웨어), 전자부품과 디지털 회로설계, PCB 설계 제작, 고객(시장/수출) 발굴과 마케팅 전략으로 당신을 지원합니다.
제품 설계의 고수는 성공이 만든 게 아니라 실패가 만듭니다. 아이디어를 양산 가능한 제품으로!
귀사의 제품을 만드세요. 교육과 개발 실적으로 신뢰할 수 있는 파트너를 확보하세요.
캐어랩