รหัสสินค้า | AS00628 |
หมวดหมู่ | Gas Sensors แก๊สเซ็นเซอร์ |
ราคา | 5,450.00 บาท |
สถานะสินค้า | พร้อมส่ง |
จำนวน | ชิ้น |
ดูการใช้งานอย่างละเอียดและตัวอย่าง code ได้ที่ Product WiKi
Introduction
Features
Projects
Project: Accurate soil health assessment using calibrated ammonia gas sensors
Shipping List
Download the program to UNO and open the serial monitor to check the gas concentration.
Note:
Hardware
Software
#define I2C_COMMUNICATION
in the code, and set the dip switch SEL to 1, the sensor is connected to the corresponding port defined by the controller, if use UNO, the blue line is connected to D3 and the green line is connected to D2, if use ESP32, the blue line is connected to IO17 and the green line is connected to IO16. After re-uploading the code, the whole system will be re-powered and will switch to UART communication.gas.setTempCompensation(gas.ON);
, turn on temperature compensation after re-uploading the code/*!
* @file initiativereport.ino
* @brief The sensor actively reports all data
* @n Experimental method: Connect the sensor communication pin to the main control, then burn codes into it.
* @n Communication mode selection, dial switch SEL:0: IIC, 1: UART
@n I2C address selection, the default I2C address is 0x74, A1 and A0 are combined into 4 types of IIC addresses
| A1 | A0 |
| 0 | 0 | 0x74
| 0 | 1 | 0x75
| 1 | 0 | 0x76
| 1 | 1 | 0x77 default i2c address
* @n Experimental phenomenon: Print all data via serial port
*/
#include "DFRobot_MultiGasSensor.h"
//Enabled by default, use IIC communication at this time. Use UART communication when disabled
#define I2C_COMMUNICATION
#ifdef I2C_COMMUNICATION
#define I2C_ADDRESS 0x74
DFRobot_GAS_I2C gas(&Wire ,I2C_ADDRESS);
#else
#if (!defined ARDUINO_ESP32_DEV) && (!defined __SAMD21G18A__)
/**
UNO:pin_2-----RX
pin_3-----TX
*/
SoftwareSerial mySerial(2,3);
DFRobot_GAS_SoftWareUart gas(&mySerial);
#else
/**
ESP32:IO16-----RX
IO17-----TX
*/
DFRobot_GAS_HardWareUart gas(&Serial2); //ESP32HardwareSerial
#endif
#endif
void setup() {
Serial.begin(115200);
while(!gas.begin())
{
Serial.println("NO Deivces !");
delay(1000);
}
Serial.println("The device is connected successfully!");
gas.changeAcquireMode(gas.PASSIVITY);
delay(1000);
gas.setTempCompensation(gas.OFF);
}
void loop() {
Serial.print("Ambient ");
Serial.print(gas.queryGasType());
Serial.print(" concentration is: ");
Serial.print(gas.readGasConcentrationPPM());
Serial.println(" %vol");
//The measurement unit will only be %vol when the sensor is SEN0465
//Otherwise the unit will be PPM
Serial.print("The board temperature is: ");
Serial.print(gas.readTempC());
Serial.println(" ℃");
Serial.println();
delay(1000);
}
Open the serial monitor to get the gas type, concentration and temperature.
Connect the module to the Arduino according to the connection diagram above. Of course, you can also use it with Gravity I/O Expansion Board to build the project prototype more conveniently and quickly.
Set the DIP switch SEL on the sensor to 0, and use I2C communication by default.
The default I2C address is 0x74. If you need to modify the I2C address,You can configure the hardware I2C address through the DIP switch on the module, or run the code to modify the address group to modify the address. The corresponding relationship between the DIP switch and the I2C address parameter is as follows:
Download and install the DFRobot_GasSensor Library (About how to install the library?)
Open Arduino IDE and upload the following code to Arduino UNO.
Open the serial port monitor of Arduino IDE, adjust the baud rate to 115200, and observe the serial port print result.
Default use I2C communication, mask `#define I2C_COMMUNICATION in the code, and set the dip switch SEL to 1, the sensor is connected to the corresponding port defined by the controller, if use UNO, the blue line is connected to D3 and the green line is connected to D2, if use ESP32, the blue line is connected to IO17 and the green line is connected to IO16. After re-uploading the code, the whole system will be re-powered and will switch to UART communication.
Turn off temperature compensation by default, modify the code gas.setTempCompensation(gas.ON);
, turn on temperature compensation after re-uploading the code
/*!
* @file readGasConcentration.ino
* @brief Obtain the corresponding gas concentration in the current environment and output the concentration value
* @n Experiment method: Connect the sensor communication pin to the main control and burn codes into it.
* @n Communication mode selection, dial switch SEL:0: IIC, 1: UART
@n i2c address selection, the default i2c address is 0x74, A1 and A0 are combined into 4 types of IIC addresses
| A1 | A0 |
| 0 | 0 | 0x74
| 0 | 1 | 0x75
| 1 | 0 | 0x76
| 1 | 1 | 0x77 default i2c address
* @n Experimental phenomenon: You can see the corresponding gas concentration value of the environment at this time by printing on the serial port
*/
#include "DFRobot_MultiGasSensor.h"
//Enabled by default, use IIC communication at this time. Use UART communication when disabled
#define I2C_COMMUNICATION
#ifdef I2C_COMMUNICATION
#define I2C_ADDRESS 0x74
DFRobot_GAS_I2C gas(&Wire, I2C_ADDRESS);
#else
#if (!defined ARDUINO_ESP32_DEV) && (!defined __SAMD21G18A__)
/**
UNO:pin_2-----RX
pin_3-----TX
*/
SoftwareSerial mySerial(2, 3);
DFRobot_GAS_SoftWareUart gas(&mySerial);
#else
/**
ESP32:IO16-----RX
IO17-----TX
*/
DFRobot_GAS_HardWareUart gas(&Serial2); //ESP32HardwareSerial
#endif
#endif
void setup() {
Serial.begin(115200);
while(!gas.begin())
{
Serial.println("NO Deivces !");
delay(1000);
}
gas.setTempCompensation(gas.OFF);
gas.changeAcquireMode(gas.INITIATIVE);
delay(1000);
}
void loop() {
if(true==gas.dataIsAvailable())
{
Serial.println("========================");
Serial.print("gastype:");
Serial.println(AllDataAnalysis.gastype);
Serial.println("------------------------");
Serial.print("gasconcentration:");
Serial.print(AllDataAnalysis.gasconcentration);
if (AllDataAnalysis.gastype.equals("O2"))
Serial.println(" %VOL");
else
Serial.println(" PPM");
Serial.println("------------------------");
Serial.print("temp:");
Serial.print(AllDataAnalysis.temp);
Serial.println(" ℃");
Serial.println("========================");
}
delay(1000);
}
Open the serial monitor, then you can get the corresponding gas concentration.
The initial power-on requires more than 5 minutes of preheating. It is recommended to preheat more than 24 hours if it has not been used for a long time.
After switching the communication mode and changing the I2C address, the system needs to be powered off and on again.
Connect the module to the Arduino according to the connection diagram above. Of course, you can also use it with Gravity I/O Expansion Board to build the project prototype more conveniently and quickly.
Set the DIP switch SEL on the sensor to 0, and use I2C communication by default.
The default I2C address is 0x74. If you need to modify the I2C address,You can configure the hardware I2C address through the DIP switch on the module, or run the code to modify the address group to modify the address. The corresponding relationship between the DIP switch and the I2C address parameter is as follows:
Download and install the DFRobot_GasSensor Library (About how to install the library?)
Open Arduino IDE and upload the following code to Arduino UNO.
Open the serial port monitor of Arduino IDE, adjust the baud rate to 115200, and observe the serial port print result.
/*!
* @file setThresholdAlarm.ino
* @brief Set the threshold alarm of the sensor
* @n Experiment method: Connect the sensor communication pin to the main control and burn codes into it.
* @n Communication mode selection, dial switch SEL:0: IIC, 1: UART
*/
#include "DFRobot_MultiGasSensor.h"
//Enabled by default, use IIC communication at this time. Use UART communication when disabled
#define I2C_COMMUNICATION
#ifdef I2C_COMMUNICATION
#define I2C_ADDRESS 0x77
DFRobot_GAS_I2C gas(&Wire ,I2C_ADDRESS);
#else
#if (!defined ARDUINO_ESP32_DEV) && (!defined __SAMD21G18A__)
/**
UNO:pin_2-----RX
pin_3-----TX
*/
SoftwareSerial mySerial(2, 3);
DFRobot_GAS_SoftWareUart gas(&mySerial);
#else
/**
ESP32:IO16-----RX
IO17-----TX
*/
DFRobot_GAS_HardWareUart gas(&Serial2); //ESP32HardwareSerial
#endif
#endif
#define ALA_pin 4
void setup() {
Serial.begin(115200);
while(!gas.begin())
{
Serial.println("NO Deivces !");
delay(1000);
}
while (!gas.changeAcquireMode(gas.PASSIVITY))
{
delay(1000);
}
Serial.println("change acquire mode success!");
while (!gas.setThresholdAlarm(gas.ON, 2, gas.HIGH_THRESHOLD_ALA ,gas.queryGasType()))
{
Serial.println("Failed to open alarm!");
delay(1000);
}
pinMode(ALA_pin,INPUT);
}
void loop() {
Serial.print(gas.queryGasType());
Serial.print(":");
Serial.println(gas.readGasConcentrationPPM());
if (digitalRead(ALA_pin) == 1)
{
Serial.println("warning!!!");
}
else
{
Serial.println("nolmal!!!");
}
delay(200);
}
-*After uploading the code successfully, open the serial monitor and you can observe the alarm message. *
-ALA outputs low level by default when no alarm is triggered. Modify the HIGH_THRESHOLD_ALA
parameter in the gas.setThresholdAlarm
function to LOW_THRESHOLD_ALA
, then ALA outputs high level when no alarm is triggered
DFR0784 Gravity: Electrochemical Smart Gas Sensor Terminal There are two data reading modes: active upload and passive response. The factory default is active upload mode, and users can adjust them in the code according to their needs.
Modify the parameters in brackets of the "changeAcquireMode()" function to adjust the data sending mode.
"INITIATIVE" is the active upload mode. In the active upload mode, the sensor will automatically upload parameters every 1 second;
"PASSIVITY" is the passive response mode. In the passive response mode, the sensor will feedback the parameters only every time the data reading function is called.
gas.changeAcquireMode(gas.INITIATIVE)
/*
gas.INITIATIVE // Active upload mode
gas.PASSIVITY // Passive response mode
*/
Set the probe type by the "setGasType()" function.
gas.setGasType(/*Gas type*/gas.O2);
Through the "queryGasType()" function, You can get the type of current gas probe.
gas.queryGasType();
For probe compatible types and corresponding parameters, please refer to the table below.
Gas type | CO | O2 | NH3 | H2S | NO2 | HCL |
---|---|---|---|---|---|---|
Detection range | (0-1000)ppm | (0-25)%VOL | (0-100)ppm | (0-100)ppm | (0-20)ppm | (0-10)ppm |
Resolution | 1ppm | 0.1%VOL | 1ppm | 1ppm | 0.1ppm | 0.1ppm |
V0 voltage output range | (0.6-3)V | (1.5-0)V | (0.6-3)V | (0.6-3)V | (2-0)V | (2-0)V |
Response time (T90) | ≤30S | ≤15S | ≤150S | ≤30S | ≤30S | ≤60S |
Gas type | H2 | PH3 | SO2 | O3 | CL2 | HF |
---|---|---|---|---|---|---|
Detection range | (0-1000)ppm | (0-1000)ppm | (0-20)ppm | (0-10)ppm | (0-20)ppm | (0-10)ppm |
Resolution | 1ppm | 0.1ppm | 0.1ppm | 0.1ppm | 0.1ppm | 0.1ppm |
V0 voltage output range | (0.6-3)V | (0.6-3)V | (0.6-3)V | (2-0)V | (2-0)V | (2-0)V |
Response time (T90) | ≤120S | ≤30S | ≤30S | ≤120S | ≤60S | ≤60S |
The feedback gas concentration value of the gas sensor can be read through the "readGasConcentrationPPM()" function.
gas.readGasConcentrationPPM();
The onboard temperature sensor data can be read through the "readTempC()" function.
gas.readTempC();
The original voltage output V0 of the gas probe can be read through the "getSensorVoltage()" function.
gas.getSensorVoltage();
You can enable/disable the temperature compensation function through the "setTempCompensation()" function.
gas.setTempCompensation();
/*
gas.ON Turn on
gas.OFF Turn off
*/
You can configure the threshold alarm information through the "setThresholdAlarm()" function
gas.setThresholdAlarm(gas.ON, 200, gas.LOW_THRESHOLD_ALA ,gas.queryGasType());
/*
gas.ON Turn on
gas.OFF Turn off
200 Set threshold
gas.LOW_THRESHOLD_ALA Jump to low level when alarming
gas.HIGH_THRESHOLD_ALA Jump to high level when alarming
gas.queryGasType() Set alarm gas type
*/
You can configure the I2C address group code and switch between different address groups through the "changeI2cAddrGroup()" function.
In order to prevent address conflicts when using multiple sensors, we have prepared 8 groups with a total of 23 addresses. If necessary, You can use "change_sensor_iic_addr.ino" in the library file "example",to switch by modifying the group serial number configuration of "changeI2cAddrGroup()". After the serial port information displays "IIC addr change success!", power on again.
gas.changeI2cAddrGroup(i);
/*
i Group number
//Group serial number and DIP switch configuration table
A0 A1Dial level 00 01 10 11
Group number Group address
1 0x60 0x61 0x62 0x63
2 0x64 0x65 0x66 0x67
3 0x68 0x69 0x6A 0x6B
4 0x6C 0x6D 0x6E 0x6F
5 0x70 0x71 0x72 0x73
6(Default address group) 0x74 0x75 0x76 0x77
7 0x78 0x79 0x7A 0x7B
8 0x7C 0x7D 0x7E
*/
Through the UART serial communication protocol, you can connect DFR0784 Gravity: Electrochemical Smart Gas Sensor Terminal to any controller with UART for data reading and sensor configuration. Note: At this time, the SEL end of the DIP switch on the sensor must be placed in the "1" position
Baud rate | 9600 |
---|---|
Data bit | 8 bit |
Check bit | 1 bit |
The terminal has two communication modes, active uploading and question and answer. The factory default is active uploading mode, and data is sent every 1s.
Send
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | addr | Command | Communication mode | -- | -- | -- | -- | Check value |
0xFF | 0x01 | 0x78 | Active upload mode: 0x03 Question and answer mode: 0x04 |
0x00 | 0x00 | 0x00 | 0x00 | 0x84 0x83 |
EXP.FF 01 78 03 00 00 00 00 84 (switch to initiative mode)
EXP.FF 01 78 04 00 00 00 00 83 (switch to passive mode)
Return
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | Command | Back to calibration | -- | -- | -- | -- | -- | Check value |
0xFF | 0x78 | Success: 0x01 Failure: 0x00 |
0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x87 0x88 |
EXP.FF 78 01 00 00 00 00 00 87
In the active upload mode, the terminal will return data every 1s. The data format is as follows.
Return
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | Command | Gas concentration high bit |
Gas concentration low bit |
Gas type | Decimal places | Temperature value High |
Temperature value lower |
Check value |
0xFF | 0x88 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | -- |
Note:
Gas Type Table
Gas Type | Command | Gas Type | Command |
---|---|---|---|
NH3 | 0x02 | SO2 | 0x2B |
H2S | 0x03 | NO2 | 0x2C |
CO | 0x04 | HCL | 0x2E |
O2 | 0x05 | CL2 | 0X31 |
H2 | 0x06 | HF | 0x33 |
O3 | 0x2A | PH3 | 0x45 |
In the question and answer mode, you need to send commands to read various parameters of the terminal. The method of reading the gas concentration is as follows.
Send
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | addr | Command | -- | -- | -- | -- | -- | Check value |
0xFF | 0x01 | 0x86 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x79 |
EXP.FF 01 86 00 00 00 00 00 79
Return
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | Command | Gas concentration high bit |
Gas concentration low bit |
Gas type | Decimal places | -- | -- | Check value |
0xFF | 0x86 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x7A |
EXP.FF 86 00 00 00 00 00 00 7A
Note:
In the question and answer mode, you need to read various parameters of the terminal by sending commands. The terminal integrates the thermistor, which can obtain the real-time temperature of the terminal. The way to read the terminal temperature is as follows.
Send
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | addr | Command | -- | -- | -- | -- | -- | Check value |
0xFF | 0x01 | 0x87 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x78 |
EXP.FF 01 87 00 00 00 00 00 78
Return
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | Command | Temperature data high bit |
Temperature data low bit |
-- | -- | -- | -- | Check value |
0xFF | 0x87 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x79 |
EXP.FF 87 00 00 00 00 00 00 79
Note:
For the calculation method of temperature value, please refer to the sample code below: "Calculation of temperature value"
In the question and answer mode, you need to read various parameters of the terminal by sending commands, and the way to read the temperature and gas concentration data of the terminal is as follows.
Send
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | addr | Command | -- | -- | -- | -- | -- | Check value |
0xFF | 0x01 | 0x88 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x77 |
EXP.FF 01 88 00 00 00 00 00 77
Return
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | Command | Gas concentration high bit |
Gas concentration low bit |
Gas type | Decimal places | Temperature value High |
Temperature value lower |
Check value |
0xFF | 0x88 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x78 |
EXP. FF 88 00 00 00 00 00 00 78
Note:
The terminal has a threshold alarm function, the alarm threshold and judgment logic can be configured. The configuration method is as follows,After the configuration is successful, the entire system needs to be powered on again to take effect.
Note: When no external controller is connected and only the sensor is used to achieve this function, the sensor must be set to active upload mode after the parameters related to the threshold alarm function are configured.
Send
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | Empty | Command | Function switch setting | Alarm concentration threshold high bit |
Alarm concentration threshold low bit |
-- | -- | Check value |
0xFF | 0x01 | 0x89 | On: 0x01 Off: 0x00 |
0x00 | 0x00 | 0x00 | 0x00 | 0x71 0x70 |
EXP. FF 01 89 00 00 05 00 00 71 (turn off the alarm function)
EXP. FF 01 89 01 00 05 00 00 70 (open the alarm function)
Please refer to ⑤ for how to calculate the concentration.
Return
Byte0 | Byte1 | Byte2 | Byte3 | Byte4 | Byte5 | Byte6 | Byte7 | Byte8 |
---|---|---|---|---|---|---|---|---|
Start bit | Command | Return configuration result | Function switch status | Alarm concentration threshold high bit |
Alarm concentration threshold low bit |
-- | -- | Check value |
0xFF | 0x89 | Success: 0x01 Failure: 0x00 |
On: 0x01 Off: 0x00 |
0x00 | 0x00 | 0x00 | 0x00 | -- |
To configure the threshold alarm by code using a controller such as Raspberry Pi, you can use this python code: GAS_ALA.zip
unsigned char data[] = {0xFF,0x01,0x87,0x00,0x00,0x00};
unsigned char FucCheckSum(unsigned char *i,unsigned char ln)
{
unsigned char j,tempq=0;
i+=1;
for(j=0;j<6;j++)
{
tempq+=*i;
i++;
}
tempq=(~tempq)+1;
return(tempq);
}
void setup() {
Serial.begin(115200);
Serial.println(FucCheckSum(data,6),HEX);
}
void loop() {
}
byte Temp_H = 0x01;//Temperature data high bit
byte Temp_L = 0xD9;//Temperature data low bit
void setup() {
Serial.begin(115200);
uint16_t temp_ADC = (Temp_H << 8) + Temp_L;
float Vpd3 = 3 * (float)temp_ADC / 1024;
float Rth = Vpd3 * 10000 / (3 - Vpd3);
float Temp = 1 / (1 / (273.15 + 25) + 1 / 3380.13 * log(Rth / 10000)) - 273.15;
Serial.println(Temp);
}
void loop() {
}
ชำระเงินค่าสินค้าโดยการโอนเงินเข้าบัญชีธนาคาร KBANK, SCB, BBL,TMB
กรุณาเก็บหลักฐานการโอนเงินของท่านไว้เพื่อแจ้งการชำระเงินด้วยค่ะ
ท่านสามารถแจ้งการชำระเงินผ่านระบบอัตโนมัติได้โดย Click Link ข้างล่างค่ะ
https://www.arduitronics.com/informpayment
หน้าที่เข้าชม | 15,375,197 ครั้ง |
ผู้ชมทั้งหมด | 5,878,275 ครั้ง |
เปิดร้าน | 21 พ.ค. 2556 |
ร้านค้าอัพเดท | 5 ก.ย. 2568 |