-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NH3 + CO DFRobot Multigas #165
Changes from 1 commit
04c5867
cd17b6d
3aec688
8a975c9
fcb4937
f5d6a70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/*! | ||
* @file readGasConcentration.ino | ||
* @brief Obtain gas concentration corresponding to the current environment, output as concentration value | ||
* @n Experimental mode: connect sensor communication pin to the main controller and burn | ||
* @n Communication mode select, DIP switch SEL: 0: I2C, 1: UART | ||
* @n Group serial number Address in the group | ||
* @n A0 A1 DIP level 00 01 10 11 | ||
* @n 1 0x60 0x61 0x62 0x63 | ||
* @n 2 0x64 0x65 0x66 0x67 | ||
* @n 3 0x68 0x69 0x6A 0x6B | ||
* @n 4 0x6C 0x6D 0x6E 0x6F | ||
* @n 5 0x70 0x71 0x72 0x73 | ||
* @n 6 (Default address group) 0x74 0x75 0x76 0x77 (Default address) | ||
* @n 7 0x78 0x79 0x7A 0x7B | ||
* @n 8 0x7C 0x7D 0x7E 0x7F | ||
* @n i2c address select, default to 0x77, A1 and A0 are grouped into 4 I2C addresses. | ||
* @n | A0 | A1 | | ||
* @n | 0 | 0 | 0x74 | ||
* @n | 0 | 1 | 0x75 | ||
* @n | 1 | 0 | 0x76 | ||
* @n | 1 | 1 | 0x77 default i2c address | ||
* @n Experimental phenomenon: view the gas concentration corresponding to the current environment through serial port printing | ||
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com) | ||
* @license The MIT License (MIT) | ||
* @author PengKaixing([email protected]) | ||
* @version V1.0 | ||
* @date 2021-03-28 | ||
* @url https://github.com/DFRobot/DFRobot_MultiGasSensor | ||
*/ | ||
#include "DFRobot_MultiGasSensor.h" | ||
|
||
//Turn on by default, using I2C communication at the time, switch to serial port communication after turning off | ||
#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 | ||
|
||
void setup() { | ||
//Serial port init for viewing printing output | ||
Serial.begin(115200); | ||
|
||
//Sensor init, used to init serial port or I2C, depending on the communication mode currently used | ||
while(!gas.begin()) | ||
{ | ||
Serial.println("NO Deivces !"); | ||
delay(1000); | ||
} | ||
Serial.println("The device is connected successfully!"); | ||
|
||
//Mode of obtaining data: the main controller needs to request the sensor for data | ||
gas.changeAcquireMode(gas.PASSIVITY); | ||
delay(1000); | ||
|
||
/** | ||
*Turn on temperature compensation: gas.ON : turn on | ||
* gas.OFF:turn off | ||
*/ | ||
gas.setTempCompensation(gas.ON); | ||
} | ||
|
||
void loop() { | ||
String gastype = gas.queryGasType(); | ||
/** | ||
*Fill in the parameter readGasConcentration() with the type of gas to be obtained and print | ||
*The current gas concentration | ||
*Print with 1s delay each time | ||
*/ | ||
Serial.print("Ambient "); | ||
Serial.print(gastype); | ||
Serial.print(" concentration is: "); | ||
Serial.print(gas.readGasConcentrationPPM()); | ||
if (gastype == "O2") | ||
Serial.println(" %vol"); | ||
else | ||
Serial.println(" PPM"); | ||
Serial.println(); | ||
delay(1000); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,10 @@ | |
#include <s8_uart.h> | ||
#include <sps30.h> | ||
#include <drivers/pm1006.h> | ||
#include <drivers/DFRobot_MultiGasSensor.h> | ||
|
||
#define CSL_VERSION "0.5.9" | ||
#define CSL_REVISION 366 | ||
#define CSL_VERSION "0.5.9.1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is invalid, only add one more to the final number of revision and version. More info here: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Entendido There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bueno, aqui deberia quedar 0.5.10 si fue un cambio pequeño compatible. O 0.6.0 si no es compatible hacia atras. Q creo es el caso por el tema del gas, porque ese getter depronto lo vamos a cambiar |
||
#define CSL_REVISION 366.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aqui simplemente sube el numero. |
||
|
||
/*************************************************************** | ||
* S E T U P E S P 3 2 B O A R D S A N D F I E L D S | ||
|
@@ -98,9 +99,12 @@ | |
X(CO2HUM, "%", "CO2H") \ | ||
X(PRESS, "hPa", "P") \ | ||
X(ALT, "m", "Alt") \ | ||
X(GAS, "Ohm", "Gas") \ | ||
X(NH3, "ppm", "NH3") \ | ||
X(CO, "ppm", "CO") \ | ||
X(UCOUNT, "COUNT", "UCOUNT") | ||
|
||
// X(GAS, "Ohm", "Gas") \ // COlisiona con DFRobot Multigas | ||
|
||
#define X(unit, symbol, name) unit, | ||
typedef enum UNIT : size_t { SENSOR_UNITS } UNIT; | ||
#undef X | ||
|
@@ -123,6 +127,7 @@ typedef enum UNIT : size_t { SENSOR_UNITS } UNIT; | |
X(SAHT10, "AHT10", 3) \ | ||
X(SAM232X, "AM232X", 3) \ | ||
X(SDHTX, "DHTX", 3) \ | ||
X(SMULTIGAS, "MULTIGAS", 2) \ | ||
X(SCOUNT, "SCOUNT", 3) | ||
|
||
#define X(utype, uname, umaintype) utype, | ||
|
@@ -204,9 +209,12 @@ class Sensors { | |
// SCD4x sensor | ||
SensirionI2CScd4x scd4x; | ||
|
||
// IKA Vindriktn sensor | ||
// IKEA Vindriktn sensor | ||
PM1006 *pm1006; | ||
|
||
// DFRobot gravity Gas sensor | ||
DFRobot_GAS_I2C gas; | ||
|
||
void init(int pms_type = 0, int pms_rx = PMS_RX, int pms_tx = PMS_TX); | ||
|
||
void loop(); | ||
|
@@ -251,21 +259,22 @@ class Sensors { | |
|
||
float getAltitude(); | ||
|
||
float getGas(); | ||
// float getGas(); // Posible colision con DFRobot Multigas | ||
roberbike marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
void setTempOffset(float offset); | ||
|
||
void setCO2AltitudeOffset(float altitude); | ||
|
||
void setSeaLevelPressure(float hpa); | ||
|
||
|
||
String getFormatTemp(); | ||
|
||
String getFormatPress(); | ||
|
||
String getFormatHum(); | ||
|
||
String getFormatGas(); | ||
// String getFormatGas(); // Posible colision con DFRobot Multigas | ||
|
||
String getFormatAlt(); | ||
|
||
|
@@ -354,12 +363,15 @@ class Sensors { | |
float temp = 0.0; // Temperature (°C) | ||
float pres = 0.0; // Pressure | ||
float alt = 0.0; | ||
float gas = 0.0; | ||
// float gas = 0.0; // Colisiona con DFRobot Multigas | ||
|
||
uint16_t CO2Val; // CO2 in ppm | ||
float CO2humi = 0.0; // humidity of CO2 sensor | ||
float CO2temp = 0.0; // temperature of CO2 sensor | ||
|
||
uint16_t NH3; // Amonium in ppm | ||
uint16_t CO; // Carbon monoxide | ||
|
||
void am2320Init(); | ||
void am2320Read(); | ||
|
||
|
@@ -397,6 +409,9 @@ class Sensors { | |
void dhtRead(); | ||
bool dhtIsReady(float *temperature, float *humidity); | ||
|
||
void DFRobotgravityInit(); | ||
void DFRobotGravityRead(); | ||
|
||
// UART sensors methods: | ||
|
||
bool sensorSerialInit(int pms_type, int rx, int tx); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/*! | ||
roberbike marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @file readGasConcentration.ino | ||
* @brief Obtain gas concentration corresponding to the current environment, output as concentration value | ||
* @n Experimental mode: connect sensor communication pin to the main controller and burn | ||
* @n Communication mode select, DIP switch SEL: 0: I2C, 1: UART | ||
* @n Group serial number Address in the group | ||
* @n A0 A1 DIP level 00 01 10 11 | ||
* @n 1 0x60 0x61 0x62 0x63 | ||
* @n 2 0x64 0x65 0x66 0x67 | ||
* @n 3 0x68 0x69 0x6A 0x6B | ||
* @n 4 0x6C 0x6D 0x6E 0x6F | ||
* @n 5 0x70 0x71 0x72 0x73 | ||
* @n 6 (Default address group) 0x74 0x75 0x76 0x77 (Default address) | ||
* @n 7 0x78 0x79 0x7A 0x7B | ||
* @n 8 0x7C 0x7D 0x7E 0x7F | ||
* @n i2c address select, default to 0x77, A1 and A0 are grouped into 4 I2C addresses. | ||
* @n | A0 | A1 | | ||
* @n | 0 | 0 | 0x74 | ||
* @n | 0 | 1 | 0x75 | ||
* @n | 1 | 0 | 0x76 | ||
* @n | 1 | 1 | 0x77 default i2c address | ||
* @n Experimental phenomenon: view the gas concentration corresponding to the current environment through serial port printing | ||
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com) | ||
* @license The MIT License (MIT) | ||
* @author PengKaixing([email protected]) | ||
* @version V1.0 | ||
* @date 2021-03-28 | ||
* @url https://github.com/DFRobot/DFRobot_MultiGasSensor | ||
*/ | ||
#include "DFRobot_MultiGasSensor.h" | ||
|
||
//Turn on by default, using I2C communication at the time, switch to serial port communication after turning off | ||
#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 | ||
|
||
void setup() { | ||
//Serial port init for viewing printing output | ||
Serial.begin(115200); | ||
|
||
//Sensor init, used to init serial port or I2C, depending on the communication mode currently used | ||
while(!gas.begin()) | ||
{ | ||
Serial.println("NO Deivces !"); | ||
delay(1000); | ||
} | ||
Serial.println("The device is connected successfully!"); | ||
|
||
//Mode of obtaining data: the main controller needs to request the sensor for data | ||
gas.changeAcquireMode(gas.PASSIVITY); | ||
delay(1000); | ||
|
||
/** | ||
*Turn on temperature compensation: gas.ON : turn on | ||
* gas.OFF:turn off | ||
*/ | ||
gas.setTempCompensation(gas.ON); | ||
} | ||
|
||
void loop() { | ||
String gastype = gas.queryGasType(); | ||
/** | ||
*Fill in the parameter readGasConcentration() with the type of gas to be obtained and print | ||
*The current gas concentration | ||
*Print with 1s delay each time | ||
*/ | ||
Serial.print("Ambient "); | ||
Serial.print(gastype); | ||
Serial.print(" concentration is: "); | ||
Serial.print(gas.readGasConcentrationPPM()); | ||
if (gastype == "O2") | ||
Serial.println(" %vol"); | ||
else | ||
Serial.println(" PPM"); | ||
Serial.println(); | ||
delay(1000); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, for the moment remove this example because it don't use the CanAirIO Sensorlib example structures. This will be to understand but maybe will be useful for write a CanAirIO example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eliminado