Skip to content

Commit 02c8d14

Browse files
authored
Merge pull request #180 from kike-canaries/devel
Devel
2 parents 0be8e83 + 658df0e commit 02c8d14

File tree

11 files changed

+355
-46
lines changed

11 files changed

+355
-46
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Panasonic via UART in ESP8266 maybe needs select in detection.
5353
| BME680 | i2c | Auto | STABLE |
5454
| DfRobot SEN0469 NH3 | i2c | Auto | TESTING |
5555
| DFRobot SEN0466 CO | i2c | Auto | TESTING |
56+
| DFRobot SEN0471 NO2 | i2c | Auto | TESTING |
5657
| Geiger CAJOE | GPIO | Select | TESTING |
5758
| DHTxx | TwoWire | Select | DISABLED |
5859

@@ -364,7 +365,7 @@ Also you can make a donation, be a patreon or buy a device:
364365
- [x] SenseAir S8 via UART support
365366
- [x] Multivariable selection (getNextUnit(),getUnitName(),etc)
366367
- [x] Two I2C channel supported for M5Stack Devices (M5StickC tested)
367-
- [x] Added CO and NH3 sensors
368+
- [x] Added CO, NO2 and NH3 sensors
368369
- [x] Added Geiger sensor support
369370
- [ ] New IKEA VINDSTYRKA device support
370371
- [ ] Sea level setting for Pressure sensors and others

doxygen.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "CanAirIO Sensors Library"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 0.7.1
41+
PROJECT_NUMBER = 0.7.3
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

examples/DfRobot_Multigas/dfr_multigas.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
void onSensorDataOk() {
2222
Serial.println("-->[MAIN] NH3: " + String(sensors.getNH3()));
2323
Serial.println("-->[MAIN] CO: " + String(sensors.getCO()));
24+
Serial.println("-->[MAIN] NO2: " + String(sensors.getNO2()));)
2425
}
2526

2627
void onSensorDataError(const char* msg) {
@@ -46,6 +47,7 @@ void setup() {
4647

4748
sensors.init(SENSORS::SDFRCO); // detect CO sensor
4849
sensors.init(SENSORS::SDFRNH3); // detect NH3 sensor
50+
sensors.init(SENSORS::SDFRNO2); // detect NO2 sensor
4951

5052
delay(500);
5153
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*!
2+
* @file readGasConcentration.ino
3+
* @brief Obtain gas concentration corresponding to the current environment, output as concentration value
4+
* @n Experimental mode: connect sensor communication pin to the main controller and burn
5+
* @n Communication mode select, DIP switch SEL: 0: I2C, 1: UART
6+
* @n Group serial number Address in the group
7+
* @n A0 A1 DIP level 00 01 10 11
8+
* @n 1 0x60 0x61 0x62 0x63
9+
* @n 2 0x64 0x65 0x66 0x67
10+
* @n 3 0x68 0x69 0x6A 0x6B
11+
* @n 4 0x6C 0x6D 0x6E 0x6F
12+
* @n 5 0x70 0x71 0x72 0x73
13+
* @n 6 (Default address group) 0x74 0x75 0x76 0x77 (Default address)
14+
* @n 7 0x78 0x79 0x7A 0x7B
15+
* @n 8 0x7C 0x7D 0x7E 0x7F
16+
* @n i2c address select, default to 0x77, A1 and A0 are grouped into 4 I2C addresses.
17+
* @n | A0 | A1 |
18+
* @n | 0 | 0 | 0x74
19+
* @n | 0 | 1 | 0x75
20+
* @n | 1 | 0 | 0x76
21+
* @n | 1 | 1 | 0x77 default i2c address
22+
* @n Experimental phenomenon: view the gas concentration corresponding to the current environment through serial port printing
23+
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
24+
* @license The MIT License (MIT)
25+
* @author PengKaixing(kaixing.peng@dfrobot.com)
26+
* @version V1.0
27+
* @date 2021-03-28
28+
* @url https://github.com/DFRobot/DFRobot_MultiGasSensor
29+
*/
30+
#include "DFRobot_MultiGasSensor.h"
31+
#include <Arduino.h>
32+
33+
//Turn on by default, using I2C communication at the time, switch to serial port communication after turning off
34+
//#define I2C_COMMUNICATION
35+
36+
//#ifdef I2C_COMMUNICATION
37+
//#define I2C_ADDRESS 0x77
38+
DFRobot_GAS_I2C nh3(&Wire,0x7A);
39+
DFRobot_GAS_I2C co(&Wire,0x78);
40+
DFRobot_GAS_I2C no2(&Wire,0x7B);
41+
42+
void setup() {
43+
//Serial port init for viewing printing output
44+
Serial.begin(115200);
45+
46+
//Change i2c address group
47+
while(gas.changeI2cAddrGroup(7)==0)
48+
{
49+
Serial.println("IIC addr change fail!");
50+
delay(1000);
51+
}
52+
Serial.println("IIC addr change success!");
53+
}
54+
55+
//Sensor init, used to init serial port or I2C, depending on the communication mode currently used
56+
while(!nh3.begin())
57+
{
58+
Serial.println("No Devices NH3 !");
59+
delay(1000);
60+
}
61+
//Mode of obtaining data: the main controller needs to request the sensor for data
62+
nh3.changeAcquireMode(nh3.PASSIVITY);
63+
delay(1000);
64+
65+
nh3.setTempCompensation(nh3.ON);
66+
67+
Serial.println("The device nh3 0x7A is connected successfully!");
68+
69+
while(!co.begin())
70+
{
71+
Serial.println("No Devices CO !");
72+
delay(1000);
73+
}
74+
75+
co.changeAcquireMode(co.PASSIVITY);
76+
delay(1000);
77+
78+
co.setTempCompensation(co.ON);
79+
80+
Serial.println("The device CO 0x78 is connected successfully!");
81+
82+
while(!no2.begin())
83+
{
84+
Serial.println("No Devices NO2 !");
85+
delay(1000);
86+
}
87+
88+
no2.changeAcquireMode(no2.PASSIVITY);
89+
delay(1000);
90+
91+
no2.setTempCompensation(no2.ON);
92+
93+
Serial.println("The device CO 0x7B is connected successfully!");
94+
}
95+
96+
void loop() {
97+
String gastypeNH3 = nh3.queryGasType();
98+
/**
99+
*Fill in the parameter readGasConcentration() with the type of gas to be obtained and print
100+
*The current gas concentration
101+
*Print with 1s delay each time
102+
*/
103+
Serial.print("Ambient ");
104+
Serial.print(gastypeNH3);
105+
Serial.print(" concentration is: ");
106+
Serial.print(nh3.readGasConcentrationPPM());
107+
if (gastypeNH3 == "O2")
108+
Serial.println(" %vol");
109+
else
110+
Serial.println(" PPM");
111+
Serial.println();
112+
delay(1000);
113+
114+
String gastypeCO = co.queryGasType();
115+
/**
116+
*Fill in the parameter readGasConcentration() with the type of gas to be obtained and print
117+
*The current gas concentration
118+
*Print with 1s delay each time
119+
*/
120+
Serial.print("Ambient ");
121+
Serial.print(gastypeCO);
122+
Serial.print(" concentration is: ");
123+
Serial.print(co.readGasConcentrationPPM());
124+
if (gastypeCO == "O2")
125+
Serial.println(" %vol");
126+
else
127+
Serial.println(" PPM");
128+
Serial.println();
129+
delay(1000);
130+
131+
String gastypeNO2 = no2.queryGasType();
132+
/**
133+
*Fill in the parameter readGasConcentration() with the type of gas to be obtained and print
134+
*The current gas concentration
135+
*Print with 1s delay each time
136+
*/
137+
Serial.print("Ambient ");
138+
Serial.print(gastypeNO2);
139+
Serial.print(" concentration is: ");
140+
Serial.print(no2.readGasConcentrationPPM());
141+
if (gastypeNO2 == "O2")
142+
Serial.println(" %vol");
143+
else
144+
Serial.println(" PPM");
145+
Serial.println();
146+
delay(1000);
147+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env:esp32doit-devkit-v1]
12+
platform = espressif32
13+
board = esp32doit-devkit-v1
14+
monitor_speed = 115200
15+
monitor_filters = time
16+
framework = arduino
17+
lib_deps =
18+
https://github.com/DFRobot/DFRobot_MultiGasSensor.git

examples/advanced_multivariable/src/main.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file main.cpp
33
* @author Antonio Vanegas @hpsaturn
4-
* @date June 2018 - 2022
4+
* @date June 2018 - 2023
55
* @brief CanAirIO Sensorslib tests
66
* @license GPL3
77
*
@@ -18,6 +18,8 @@
1818
#include <Arduino.h>
1919
#include <Sensors.hpp>
2020

21+
#define MAIN_HW_EN_PIN 27 // Only for setup with booster board with enable pin
22+
2123
void printSensorsDetected() {
2224
uint16_t sensors_count = sensors.getSensorsRegisteredCount();
2325
uint16_t units_count = sensors.getUnitsRegisteredCount();
@@ -56,21 +58,31 @@ void onSensorDataError(const char * msg){
5658
* M A I N
5759
******************************************************************************/
5860

61+
void powerEnableSensors() {
62+
// init all sensors (step-up to 5V with enable pin)
63+
Serial.println("-->[POWR] == enable sensors ==");
64+
pinMode(MAIN_HW_EN_PIN, OUTPUT);
65+
digitalWrite(MAIN_HW_EN_PIN, HIGH); // step-up on
66+
}
67+
5968
void setup() {
6069
Serial.begin(115200);
61-
delay(200);
70+
delay(500); // Only for debugging
71+
// powerEnableSensors(); // Only for special setup hardware with enable
72+
delay(100);
6273
Serial.println("\n== Sensor test setup ==\n");
6374
Serial.println("-->[SETUP] Detecting sensors..");
6475

6576
sensors.setSampleTime(10); // config sensors sample time interval
6677
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
67-
sensors.setDebugMode(true); // [optional] debug mode
68-
sensors.detectI2COnly(true); // force to only i2c sensors
78+
sensors.setDebugMode(false); // [optional] debug mode
79+
sensors.detectI2COnly(false); // not force to only i2c sensors
6980
sensors.setTemperatureUnit(TEMPUNIT::KELVIN); // comment for Celsius or set Fahrenheit
70-
sensors.init(); // Auto detection to UART and i2c sensors
81+
// sensors.init(SENSORS::Auto, 13, 12); // Auto detection (Custom UART sensor pins example)
82+
sensors.init(); // Auto detection (UART and i2c sensors)
7183
delay(1000);
7284
}
7385

7486
void loop() {
7587
sensors.loop(); // read sensor data and showed it
76-
}
88+
}

library.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CanAirIO Air Quality Sensors Library",
3-
"version": "0.7.2",
3+
"version": "0.7.3",
44
"homepage":"https://canair.io",
55
"keywords":
66
[
@@ -82,13 +82,14 @@
8282
{"name":"Adafruit BME680 Library","owner":"adafruit","version":"2.0.2"},
8383
{"name":"Adafruit SHT31 Library", "owner":"adafruit","version":"2.2.2"},
8484
{"name":"Adafruit SCD30", "owner":"adafruit","version":"1.0.9"},
85-
{"name":"Adafruit BusIO", "owner":"adafruit","version":"1.14.4"},
86-
{"name":"AM232X", "owner":"robtillaart", "version":"0.4.5"},
87-
{"name":"sps30", "owner":"paulvha","version":"1.4.16"},
85+
{"name":"Adafruit BusIO", "owner":"adafruit","version":"1.14.5"},
86+
{"name":"AM232X", "owner":"robtillaart", "version":"0.5.0"},
87+
{"name":"sps30", "owner":"paulvha","version":"1.4.17"},
8888
{"name":"MH-Z19", "owner":"wifwaf", "version":"1.5.4"},
8989
{"name":"S8_UART", "owner":"jcomas", "version":"1.0.1"},
9090
{"name":"Sensirion Core","owner":"sensirion","version":"0.6.0"},
9191
{"name":"Sensirion I2C SCD4x","owner":"sensirion","version":"0.4.0"},
92+
{"name":"Sensirion I2C SEN5X","owner":"sensirion","version":"0.3.0"},
9293
{"name":"DFRobot_MultiGasSensor","owner":"phzi","version":"2.0.0"},
9394

9495
{"name":"AHTxx", "version":"https://github.com/enjoyneering/AHTxx.git#eb21571"},

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=CanAirIO Air Quality Sensors Library
2-
version=0.7.2
2+
version=0.7.3
33
author=@hpsaturn, CanAirIO project <info@canair.io>
44
maintainer=Antonio Vanegas <hpsaturn@gmail.com>
55
url=https://github.com/kike-canaries/canairio_sensorlib

0 commit comments

Comments
 (0)