In this project, we will go over how to build a smoke sensor circuit with an arduino board.
The smoke sensor we will use is the MQ-2. This is a sensor that is not only sensitive to smoke, but also to flammable gas.
The MQ-2 smoke sensor reports smoke by the voltage level that it outputs. The more smoke there is, the greater the voltage that it outputs. Conversely, the less smoke that it is exposed to, the less voltage it outputs.
The MQ-2 smoke sensor is sensitive to smoke and to the following flammable gases:
The resistance of the sensor is different depending on the type of the gas.
The smoke sensor has a built-in potentiometer that allows you to adjust the sensor sensitivity according to how accurate you want to detect gas.
1. Wide detecting scope
2. High sensitivity and fast response
3. Long life and stable
4. Simple drive circuit
Due to its fast response time and high sensitivity, measurements can be taken as soon as possible. The sensor sensitivity can be adjusted by using the potentiometer.
| Symbol | Parameter Name | Technical Condition | Remarks |
| VC | Circuit voltage | 5V±0.1 | AC or DC |
| VH | Heating voltage | 5V±0.1 | AC or DC |
| RL | Load resistance | adjustable | |
| RH | Heater resistance | 33Kohm±5% | Room temperature |
| PH | Heating consumption | Less than 800mW |
| Symbol | Parameter Name | Technical Condition | Remarks |
| TO | Operating Temp. | -20°C-50°C | |
| TS | Storage Temp. | -20°C-70°C | |
| RH | Relative Humidity | <95% | |
| O2 | Oxygen Concentration | 21%(standard condition) Oxygen concentration can affect sensitivity | Minimum value is 2% |
| Symbol | Parameter Name | Technical Condition | Remarks |
| RS | Sensor Resistance | 3Kohm-30Kohm (1000ppm iso-butane) | Detecting concentration scope: 200ppm-5000ppm LPG and propane 300ppm-5000ppm butane 5000ppm-20000ppm methane 300ppm-5000ppm H2 100ppm-2000ppm Alcohol |
| α (3000ppm/1000ppm iso-butane) | Concentration slope rate | ≤0.6 | |
| Standard detecting Condition | Temp.: 20°C±2°C VC: 5V±0.1 Humidity:65%±5% VH:5V±0.1 |
||
| Preheating Time | Over 24 hours | ||
The MQ2 has an electrochemical sensor, which changes its resistance for different concentrations of varied gasses. The sensor is connected in series with a variable resistor to form a voltage divider circuit , and the variable resistor is used to change sensitivity. When one of the above gaseous elements comes in contact with the sensor after heating, the sensor’s resistance change. The change in the resistance changes the voltage across the sensor, and this voltage can be read by a microcontroller. The voltage value can be used to find the resistance of the sensor by knowing the reference voltage and the other resistor’s resistance. The sensor has different sensitivity for different types of gasses. The sensitivity characteristic curve is shown below for the different type of gasses.
The voltage that the sensor outputs changes accordingly to the smoke/gas level that exists in the atmosphere. The sensor outputs a voltage that is proportional to the concentration of smoke/gas.
In other words, the relationship between voltage and gas concentration is the following:
Working Mechanism
The output can be an analog signal (A0) that can be read with an analog input of the Arduino or a digital output (D0) that can be read with a digital input of the Arduino.
Note
The sensor value only reflects the approximated trend of gas concentration in a permissible error range, it DOES NOT represent the exact gas concentration. The detection of certain components in the air usually requires a more precise and costly instrument, which cannot be done with a single gas sensor. If your project is aimed at obtaining the gas concentration at a very precise level, then we don’t recommend this gas sensor.
In this example, the sensor is connected to A0 pin. The voltage read from the sensor is displayed. This value can be used as a threshold to detect any increase/decrease in gas concentration.
void setup() {
Serial.begin(9600);
}
void loop() {
float sensor_volt;
float sensorValue;
sensorValue = analogRead(A0);
sensor_volt = sensorValue/1024*5.0;
Serial.print("sensor_volt = ");
Serial.print(sensor_volt);
Serial.println("V");
delay(1000);
}
These examples demonstrate ways to know the approximate concentration of Gas. As per the data-sheet of the MQx sensors, these equations are tested for standard conditions and are not calibrated. It may vary based on change in temperature or humidity.
void setup() {
Serial.begin(9600);
}
void loop() {
float sensor_volt;
float RS_air; // Get the value of RS via in a clear air
float R0; // Get the value of R0 via in H2
float sensorValue;
/*--- Get a average data by testing 100 times ---*/
for(int x = 0 ; x < 100 ; x++)
{
sensorValue = sensorValue + analogRead(A0);
}
sensorValue = sensorValue/100.0;
/*-----------------------------------------------*/
sensor_volt = sensorValue/1024*5.0;
RS_air = (5.0-sensor_volt)/sensor_volt; // omit *RL
R0 = RS_air/9.8; // The ratio of RS/R0 is 9.8 in a clear air from Graph (Found using WebPlotDigitizer)
Serial.print("sensor_volt = ");
Serial.print(sensor_volt);
Serial.println("V");
Serial.print("R0 = ");
Serial.println(R0);
delay(1000);
}
void setup() {
Serial.begin(9600);
}
void loop() {
float sensor_volt;
float RS_gas; // Get value of RS in a GAS
float ratio; // Get ratio RS_GAS/RS_air
int sensorValue = analogRead(A0);
sensor_volt=(float)sensorValue/1024*5.0;
RS_gas = (5.0-sensor_volt)/sensor_volt; // omit *RL
/*-Replace the name "R0" with the value of R0 in the demo of First Test -*/
ratio = RS_gas/R0; // ratio = RS/R0
/*-----------------------------------------------------------------------*/
Serial.print("sensor_volt = ");
Serial.println(sensor_volt);
Serial.print("RS_ratio = ");
Serial.println(RS_gas);
Serial.print("Rs/R0 = ");
Serial.println(ratio);
Serial.print("\n\n");
delay(1000);
}
The circuit we will build is shown below.

So to power the smoke sensor, we connect pin 2 of the smoke sensor to the 5V terminal of the arduino and terminal 3 to the GND terminal of the arduino. This gives the smoke sensor the 5 volts it needs to be powered.
The output of the sensor goes into analog pin A0 of the arduino. Through this connection, the arduino can read the analog voltage output from the sensor. The arduino board has a built-in analog-to-digital converter, so it is able to read analog values without any external ADC chip.
Depending on the value that the arduino reads determines the action that will occur with the circuit. We will make it in our code that if the sensor outputs a voltage above a certain threshold, the buzzer will go off, alerting a user that smoke has been detected.
These are all the physical connections in order for our circuit to work.
Being that we’ve just gone over the circuit schematic for the smoke sensor circuit, all we need know is the code necessary to upload to the arduino for this smoke alarm cicrcuit to work.
The code that we need to upload is shown below.
/*Code for MQ-2 Smoke Sensor Circuit Built with an Arduino Board*/
const int sensorPin= 0;
const int buzzerPin= 13;
int smoke_level;
void setup() {
Serial.begin(115200); //sets the baud rate for data transfer in bits/second
pinMode(sensorPin, INPUT);//the smoke sensor will be an input to the arduino
pinMode(buzzerPin, OUTPUT);//the buzzer serves an output in the circuit
}
void loop() {
smoke_level= analogRead(sensorPin); //arduino reads the value from the smoke sensor
Serial.println(smoke_level);//prints just for debugging purposes, to see what values the sensor is picking up
if(smoke_level > 200){ //if smoke level is greater than 200, the buzzer will go off
digitalWrite(buzzerPin, HIGH);
}
else{
digitalWrite(buzzerPin, LOW);
}
}
The first block of code declares and initializes 3 variables. The sensorPin represents the smoke sensor. It is initialized to 0, because it will be connected to analog pin A0 of the arduino board. The next variable, buzzerPin, represents the pin that the anode of the buzzer will be connected to; it is initialized to 12 because it will be connected to digital pin D12 of the arduino board. And the variable, smoke_level, represents the amount of smoke that the smoke sensor picks up.
The next block of code defines the baud rate and the input and output of the circuit. The sensorPin, which is the smoke sensor pin, serves as the input of the circuit. This sensor is input into the arduino so that the arduino can read and process the value. The buzzerPin serves as the output. If the smoke level is above a certain threshold, the output of the circuit, the buzzer, will go off.
The next block of code uses the analogRead() function to read the value from the sensorPin (the smoke sensor). This will be a numerical value from 0 to 1023. 0 represents no smoke, while 1023 represents smoke at the absolute maximum highest level. So the variable, smoke_level, represents the smoke level that can range from 0 to 1023. We put a line to print this value just for debugging purposes, so that you can see what values are being returned from this function. In our code, we make it so that if the smoke level rises above 200, we will trigger the buzzer to sound by sending the digital pin D12 high. So 200 is our threshold level. If the smoke level is below this value, then the buzzer does not go off.
This last block of code was the loop() function. This is the part of code that repeats over and over in an infinite loop. This means that our code is always checking to see what the smoke_level is, so that it can know whether to trigger the buzzer or not.
And this is how a smoke sensor works with
We need Switch to control electronics or electrical appliances or some thing, Some time electrical switches will give a shock when we use electrical switches with wet hand and then touch to control electrical or electronic load is much interactive than ordinary switches, may be some projects needs touch switch.
In this lesson, we will show what is Digital Touch Sensor Module and how to use it with the Arduino board.
Arduino IDE (version 1.6.4+)
-Control Interface : A total of three pins (GND, VCC, SIG), GND to ground , VCC is the power supply , SIG digital signal output pin ;
-Power Indicator : Green LED, power on the right that is shiny ;
-Touch area : Similar to a fingerprint icon inside the area , you can touch the trigger finger .
-Positioning holes : 4 M2 screws positioning hole diameter is 2.2mm, the positioning of the module is easy to install , to achieve inter- module combination ;
TTP223 is 1 Key Touch pad detector IC, and it is suitable to detect capacitive element variations. It consumes very low power and the operating voltage is only between 2.0V~5.5V. The response time max about 60mS at fast mode, 220mS at low power mode @VDD=3V. Sensitivity can adjust by the capacitance(0~50pF) outside.
Connect Vcc pin of Sensor breakout board to Arduino’s +5V pin and GND to GND. Connect Signal (SIG) pin to Arduino Digital pin D2.
The sketch below provides an output to your serial monitor indicating whether or not the sensor is pressed.
After the uploader , if use finger or metal object touch the metal surface of the transducer , the red LED lights on the UNO will light. Open the Serial Monitor at baudrate 9600, and you will see something as below:
KOOKYE Arduino学習キット中級版
Arduino学習キットです。 様々なArduino実験や開発ができるキットです。
MCU(マイクロコントローラユニット)を学習の初心者に向け素晴らしいdo-and-learnキットだと思います。
このスターターキットを使って、色々なArduinoラボプロジェクトを学習できます。例えば、交通信号の模倣(LEDとボタンが必要) 液晶ディスプレイ(LCD)で文字を表示 サーボモーターをコントロールするために、ポテンショメーターを使って サーボ モーターの制御など色々あります。
ボタン、抵抗器、センサー、赤外線リモコン、レシーバーの基本概念も、色々なセンサーを使って環境の検出も、74HC595というシフトレジスタ ICを使ってArduinoデジタルポートの扩张も学習できます。
このスターターキット内のすべてのプロジェクトは詳細な回路図、詳細な操作手順、テスト済みのArduinoのサンプル・コードが付属していますので、お客様の時間を節約し、Arduinoの学習も上达になれます。
このキット内のプロジェクトをすべて学習したら、もう初心者ではなく、Arduino達人になりますね!
| Buy It On Amazon US |
Amazon Japanで購入する Arduino学習キット 様々なマイコン実験や開発用電子部品キット Arduino UNO R3互換ボード LCDキャ… |
Buy It On Amazon UK![]() Arduino Starter kit with 19 Projectors |
チュートリアル:
| プロジェクト | チュートリアル~ |
| P1: LED点滅 プロジェクト | チュートリアル~ |
| P2: 光センサーを使って、光を検出する | チュートリアル~ |
| P3: 可変抵抗器を使って、マイクロサーボモーターを制御する | チュートリアル~ |
| P4: 赤外線レシーバー使って、赤外線リモコンの信号を復号化 | チュートリアル~ |
| P5: TMP36 温度センサープロジェクト | チュートリアル~ |
| P6: タクトスイッチを使って、交通信号の制御する | チュートリアル~ |
| P7: 傾斜センサープロジェクト | チュートリアル~ |
| P8: 16×2 I2C LCD プロジェクト | チュートリアル~ |
| P9: 74HC595 シフトレジスターを使って、直列入力並列出力プロジェクト | チュートリアル~ |
| P10:LEDデジタル表示管で4桁の数字を表示する | チュートリアル~ |
| P11:LEDデジタル表示管で0~9の数字を表示する | チュートリアル~ |
| P12:BYJ48ステッピングモーターのテスト | チュートリアル~ |
| P13:可変抵抗器を使って、マイクロサーボモーターを制御する | チュートリアル~ |
| P14:DC5V ブザーのテスト | チュートリアル~ |
| P15:抵抗のカラーコードと読み方 | チュートリアル~ |
| P16:DHT11 デジタル温度/湿度センサー | チュートリアル~ |
| P17:HC-SR04超音波測距センサープロジェクト | チュートリアル~ |
| P18:Arduinoで8×8LEDマトリックスを作動する | チュートリアル~ |
| P19:赤外線障害物検知センサーモジュール | チュートリアル~ |
| P20:実験プラットフォームとR3ボード、16×2 LCDの装着方法 | チュートリアル~ |
内容物:
| 画像 | パーツ | |
![]() |
1* UNO R3 ボードとUSBケーブル(Arduino UNO R3ボードと同じ) | |
![]() |
24* LED(6*白, 6*赤, 6*黄, 6*緑) | |
![]() |
1* 4桁LEDデジタル表示管 | |
![]() |
1* 1桁LEDデジタル表示管 | |
![]() |
3* 光センサー | |
![]() |
1* 10KΩ可変抵抗器 | |
![]() |
1* 74HC595 シフトレジスター | |
![]() |
1* 1602 16×2 LCD キャラクタ ディスプレイ | |
![]() |
1* ステッピングモーター&ドライバ | |
![]() |
1* DC5V ブザー | |
![]() |
1* マイクロサーボ | |
![]() |
1* 傾斜センサー | |
![]() |
1* DHT11 デジタル温度/湿度センサー | |
![]() |
1* TMP36温度センサー | |
![]() |
1* HC-SR04超音波測距センサー | |
![]() |
1* 赤外線障害物検知センサーモジュール | |
![]() |
1* 赤外線レシーバーと赤外線リモコン | |
![]() |
5* プッシュボタン | |
![]() |
1* ベースプレート | |
![]() |
1* ブレッドボード | |
![]() |
抵抗: 15* (220 ohm) 15* (470 ohm) 15* (10K ohm) |
|
![]() |
ジャンパーワイヤー: 40* 12cm オス – オス 15* 15cm オス – オス 5* 20cm & 25cm オス – オス 8* 20cm メス – メス |
|