Skip to content

Commit d33d70a

Browse files
authored
Merge pull request #170 from kike-canaries/devel
Devel
2 parents 51a2c31 + 621aff8 commit d33d70a

File tree

8 files changed

+180
-53
lines changed

8 files changed

+180
-53
lines changed

README.md

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Air Quality Sensors Library
55

6-
Generic sensor manager, abstractions and bindings of multiple sensors [libraries](https://github.com/kike-canaries/canairio_sensorlib/blob/master/platformio.ini#L18-L34): Honeywell, Plantower, Panasonic, Sensirion, etc. and CO2 sensors. Also it's handling others environment sensors. This library is for general purpose, but also is the sensors library base of [CanAirIO project](https://canair.io/docs).
6+
Generic sensor manager, abstractions and bindings of multiple sensors [libraries](https://github.com/kike-canaries/canairio_sensorlib/blob/master/unified-lib-deps.ini): Honeywell, Plantower, Panasonic, Sensirion, etc. and CO2 sensors. Also it's handling others environment sensors. This library is for general purpose, but also is the sensors library base of [CanAirIO project](https://canair.io/docs).
77

88
For developers also you can check the complete library documentation [here](http://hpsaturn.com/canairio_sensorlib_doc/html/index.html)
99

@@ -25,7 +25,7 @@ For developers also you can check the complete library documentation [here](http
2525
| Panasonic SN-GCJA5L | Yes | Yes | Auto | STABLE |
2626
| Plantower models | Yes | --- | Auto | STABLE |
2727
| Nova SDS011 | Yes | --- | Auto | STABLE |
28-
| IKEA Vindriktning | Yes | --- | Select | TESTING|
28+
| IKEA Vindriktning | Yes | --- | Select | STABLE |
2929
| Sensirion SPS30 | Yes | Yes | Select / Auto | STABLE |
3030

3131
NOTE: Panasonic via UART in ESP8266 maybe needs select in detection
@@ -49,8 +49,10 @@ NOTE: Panasonic via UART in ESP8266 maybe needs select in detection
4949
| SHT31 | i2c | Auto | STABLE |
5050
| AHT10 | i2c | Auto | STABLE |
5151
| BME280 | i2c | Auto | STABLE |
52-
| BMP280 | i2c | Auto | TESTING |
52+
| BMP280 | i2c | Auto | STABLE |
5353
| BME680 | i2c | Auto | STABLE |
54+
| DfRobot SEN0469 NH3 | i2c | Auto | TESTING |
55+
| DFRobot SEN0466 CO | i2c | Auto | TESTING |
5456
| DHTxx | TwoWire | Auto | DISABLED |
5557

5658
NOTE: DHT22 is supported but is not recommended. Please see the documentation.
@@ -60,8 +62,8 @@ NOTE: DHT22 is supported but is not recommended. Please see the documentation.
6062
| Platform | Variants | Notes | Status |
6163
|:----------------------- |:-----:|:-------:|:----------:|
6264
| ESP32 | WROVER* | ESP32Devkit and similar (recommended) | STABLE |
63-
| ESP32S3 | LilyGo TDisplay | In testing | UNSTABLE |
64-
| ESP32C3 | Devkit v3 | In testing | UNSTABLE |
65+
| ESP32S3 | LilyGo TDisplay | In testing | STABLE |
66+
| ESP32C3 | Devkit v3 | In testing | STABLE |
6567
| ESP8266 | 12 | D1MINI tested and similar (old) | STABLE |
6668
| Atmelsam | seeed_wio_terminal | Only works via i2c on left port | STABLE |
6769
| Arduino | Atmel | Some third party libraries fails | IN PROGRESS |
@@ -72,9 +74,9 @@ NOTE: DHT22 is supported but is not recommended. Please see the documentation.
7274

7375
- Unified variables and getters for all sensors
7476
- Auto UART port selection (Hw, Sw, UART1, UART2, etc)
75-
- Multiple i2c reads and one UART sensor read support
77+
- Multiple i2c sensors and one UART sensor supported at the same time
7678
- Two I2C channel supported (Wire and Wire1)
77-
- Real time registry of sensors unit registered (see multivariable)
79+
- Real time registry of sensor units (see multivariable)
7880
- Get vendor names of all devices detected
7981
- Preselected main stream UART pins from popular boards
8082
- Auto config UART port for Plantower, Honeywell and Panasonic sensors
@@ -85,9 +87,8 @@ NOTE: DHT22 is supported but is not recommended. Please see the documentation.
8587
- Get unit symbol and name and each sub-sensor
8688
- Get the main group type: NONE, PM, CO2 and ENV.
8789
- Basic debug mode support toggle in execution
88-
- Basic power saving management with sample time > 30s on SPS30
8990

90-
Full list of all sub libraries supported [here](https://github.com/kike-canaries/canairio_sensorlib/blob/master/library.json#L72-L89)
91+
Full list of all sub libraries supported [here](https://github.com/kike-canaries/canairio_sensorlib/blob/master/unified-lib-deps.ini)
9192

9293
# Quick implementation
9394

@@ -170,7 +171,6 @@ In this [demo](https://www.youtube.com/watch?v=uxlmP905-FE) on a simple sketch y
170171

171172
[![CanAirIO Sensors Lib DEMO with M5CoreInk](https://img.youtube.com/vi/i15iEF47CbY/0.jpg)](https://youtu.be/i15iEF47CbY)
172173

173-
174174
## Multivariable alternative implementation
175175

176176
The last version added new getters to have the current status of each unit of each sensor connected to the device in real time. Also you can retrieve the list of device names and other stuff:
@@ -231,16 +231,14 @@ void setup() {
231231
void loop() {
232232
sensors.loop(); // read sensor data and showed it
233233
}
234-
```
235-
234+
```
236235

237-
## UART detection demo
236+
## UART detection demo
238237

239238
[![CanAirIO auto configuration demo](https://img.youtube.com/vi/hmukAmG5Eec/0.jpg)](https://www.youtube.com/watch?v=hmukAmG5Eec)
240239

241240
CanAirIO sensorlib auto configuration demo on [Youtube](https://www.youtube.com/watch?v=hmukAmG5Eec)
242241

243-
244242
# Wiring
245243

246244
The current version of library supports 3 kinds of wiring connection, UART, i2c and TwoWire, in the main boards the library using the defaults pins of each board, but in some special cases the pins are:
@@ -251,20 +249,20 @@ The current version of library supports 3 kinds of wiring connection, UART, i2c
251249

252250
The library has [pre-defined some UART pin configs](https://github.com/kike-canaries/canairio_sensorlib/blob/master/src/Sensors.hpp#L19-L52), these are selected on compiling time. Maybe you don't need change anything with your board, and maybe the nexts alternatives works for you:
253251

254-
| Board model | TX | RX | Notes
252+
| Board model | TX | RX | Notes |
255253
|:---------------|:---:|:---:|:------------------:|
256254
| ESP32GENERIC | 1 | 3 | ESP32 Pio defaults
257255
| TTGOT7 / ESP32DEVKIT / D1MINI / NODEFINED | 16 | 17 | CanAirIO devices **
258256
| TTGO_TDISPLAY | 12 | 13 | |
259257
| M5COREINK | 14 | 13 | |
260258
| TTGO TQ | 18 | 13 | |
261-
| HELTEC | 18 | 17 | |
259+
| HELTEC | 18 | 17 | |
262260
| WEMOSOLED | 15 | 13 | |
263261
| ESP32PICOD4 | 3 | 1 | |
264262

265263
** This pines are when you compile your project without specific any build variable or you board isn't in the list.
266264

267-
### Custom UART:
265+
### Custom UART
268266

269267
Also you could define a custom UART pins in the init() method and select specific sensors model, like this:
270268

@@ -280,27 +278,22 @@ We are using the default pins for each board, some times it's pins are 21,22, pl
280278

281279
For now we are using it only for DHT sensors in PIN 23. For more info please review the next lines [here](https://github.com/kike-canaries/canairio_sensorlib/blob/master/src/Sensors.hpp#L19-L52).
282280

283-
284281
# Examples
285282

286283
### PlatformIO (recommended)
287284

288-
#### Compiling and Installing
289-
290285
We recommended PlatformIO because is more easy than Arduino IDE. For this, please install first [PlatformIO](http://platformio.org/) and its command line tools (Windows, MacOs and Linux), **pio** command, then connect your compatible board to the USB and run the next command:
291286

292287
```python
293-
pio run --target upload
288+
pio run -e esp32 --target upload
294289
```
295290

296291
### Arduino IDE
297292

298-
Only import the `ino` file of the sample and install the libraries listed on `library.json` and this library.
293+
Only import the `ino` file of the sample and install the libraries listed on `library.json` and this library. Complete list of libraries used [here](https://github.com/kike-canaries/canairio_sensorlib/blob/master/unified-lib-deps.ini)
299294

300295
### Arduino CLI
301296

302-
#### Prerequisites
303-
304297
For run the examples, you first need to install **arduino-cli** or the **Arduino IDE** with the libraries referenced in **lib_deps** on the file [platformio.ini](https://github.com/kike-canaries/canairio_sensorlib/blob/master/platformio.ini), becuase **Arduino don't install it automatically** like PlatformIO. Then put CanAirIO sensor library in your library directory, you can download it from [releases](https://github.com/kike-canaries/canairio_sensorlib/releases) section.
305298

306299
Also you need to add the **alternative links** for supporting the ESP32 boards:
@@ -316,9 +309,7 @@ board_manager:
316309
additional_urls:
317310
- https://arduino.esp8266.com/stable/package_esp8266com_index.json
318311
- https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
319-
```
320-
321-
#### Compiling and Installing
312+
```
322313
323314
From `arduino-cli` you can run the basic example in a ESP32 board following these steps:
324315

@@ -352,7 +343,6 @@ Also you can make a donation, be a patreon or buy a device:
352343
- **Buy a device**: [CanAirIO Bike in Tindie](https://www.tindie.com/products/hpsaturn/canairio-bike/)
353344
- [Inviting us **a coffee**](https://www.buymeacoffee.com/hpsaturn)
354345

355-
356346
# TODO
357347

358348
- [x] Auto detection for UART sensors (Honeywell, Panasonic and Plantower)
@@ -370,6 +360,7 @@ Also you can make a donation, be a patreon or buy a device:
370360
- [x] SenseAir S8 via UART support
371361
- [x] Multivariable selection (getNextUnit(),getUnitName(),etc)
372362
- [x] Two I2C channel supported for M5Stack Devices (M5StickC tested)
363+
- [x] Added CO and NH3 sensors
373364
- [ ] Sea level setting for Pressure sensors and others
374365
- [ ] Support to second UART port
375366

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @file main.cpp
3+
* @date June 2018 - 2021
4+
* @brief Particle meter sensor tests
5+
* @license GPL3
6+
*
7+
* Full documentation:
8+
* https://github.com/kike-canaries/canairio_sensorlib#canairio-air-quality-sensors-library
9+
*
10+
* Full implementation for WiFi and Bluetooth Air Quality fixed and mobile station:
11+
* https://github.com/kike-canaries/canairio_firmware#canairio-firmware
12+
*
13+
* CanAirIO project:
14+
* https://canair.io
15+
*/
16+
17+
#include <Arduino.h>
18+
19+
#include <Sensors.hpp>
20+
21+
void onSensorDataOk() {
22+
Serial.println("-->[MAIN] NH3: " + String(sensors.getNH3()));
23+
Serial.println("-->[MAIN] CO: " + String(sensors.getCO()));
24+
}
25+
26+
void onSensorDataError(const char* msg) {
27+
Serial.println(msg);
28+
}
29+
30+
/******************************************************************************
31+
* M A I N
32+
******************************************************************************/
33+
34+
void setup() {
35+
Serial.begin(115200);
36+
delay(200);
37+
Serial.println("\n== Sensor test setup ==\n");
38+
39+
Serial.println("-->[SETUP] Detecting sensors..");
40+
41+
sensors.setSampleTime(5); // config sensors sample time interval
42+
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
43+
sensors.setOnErrorCallBack(&onSensorDataError); // [optional] error callback
44+
sensors.setDebugMode(false); // [optional] debug mode
45+
sensors.detectI2COnly(true); // force to only i2c sensors
46+
47+
sensors.init(SENSORS::SDFRCO); // detect CO sensor
48+
sensors.init(SENSORS::SDFRNH3); // detect NH3 sensor
49+
50+
delay(500);
51+
}
52+
53+
void loop() {
54+
sensors.loop(); // read sensor data and showed it
55+
}

library.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CanAirIO Air Quality Sensors Library",
3-
"version": "0.6.7",
3+
"version": "0.6.8",
44
"homepage":"https://canair.io",
55
"keywords":
66
[
@@ -88,6 +88,7 @@
8888
{"name":"S8_UART", "owner":"jcomas", "version":"1.0.1"},
8989
{"name":"Sensirion Core","owner":"sensirion","version":"0.6.0"},
9090
{"name":"Sensirion I2C SCD4x","owner":"sensirion","version":"0.4.0"},
91+
{"name":"DFRobot_MultiGasSensor","owner":"phzi","version":"2.0.0"},
9192

9293
{"name":"DHT_nonblocking", "version":"https://github.com/hpsaturn/DHT_nonblocking.git#ec6e5b9"},
9394
{"name":"AHTxx", "version":"https://github.com/enjoyneering/AHTxx.git#eb21571"},

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name=CanAirIO Air Quality Sensors Library
2-
version=0.6.7
2+
version=0.6.8
33
author=@hpsaturn, CanAirIO project <info@canair.io>
44
maintainer=Antonio Vanegas <hpsaturn@gmail.com>
55
url=https://github.com/kike-canaries/canairio_sensorlib
66
sentence=Air quality particle meter and CO2 sensors manager for multiple models.
77
paragraph=Generic sensor manager, abstratctions and bindings of multiple air sensors libraries: Honeywell, Plantower, Panasonic, Sensirion, Nova, etc. and CO2 sensors. Also it handling others environment sensors. This library is for general purpose but also is the sensors library base of CanAirIO project.
88
category=sensors
9-
depends=AM232X,Adafruit Unified Sensor,sps30,Adafruit BME280 Library,AHT10,Adafruit BusIO,Adafruit SHT31 Library,DHT_nonblocking,MH-Z19,SparkFun SCD30 Arduino Library,CM1106_UART,SN-GCJA5,Adafruit BME680 Library,S8_UART,Sensirion I2C SCD4x
9+
depends=AM232X,Adafruit Unified Sensor,sps30,Adafruit BME280 Library,AHT10,Adafruit BusIO,Adafruit SHT31 Library,DHT_nonblocking,MH-Z19,SparkFun SCD30 Arduino Library,CM1106_UART,SN-GCJA5,Adafruit BME680 Library,S8_UART,Sensirion I2C SCD4x,DFRobot_MultiGasSensor
1010
license=GPL-3.0-only

platformio.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ monitor_speed = 115200
1515
monitor_filters = time
1616
build_flags =
1717
-D CORE_DEBUG_LEVEL=0
18+
-D ARDUINO_ESP32_DEV=1
1819
; -D DHT11_ENABLED=1 // Deprecated, please change this old sensor
1920
; -D DHT_SENSOR_TYPE=2
2021
; -D DHT_SENSOR_PIN=19
@@ -55,7 +56,6 @@ extends = esp32_common
5556
build_src_filter = -<*> +<advanced_multivariable/>
5657
build_flags =
5758
${env.build_flags}
58-
-D ESP32C3=1
5959

6060
[env:esp32c3]
6161
extends = esp32_common
@@ -69,7 +69,6 @@ board = esp32-s3-devkitc-1
6969
board_build.mcu = esp32s3
7070
board_build.f_cpu = 240000000L
7171
build_src_filter = -<*> +<advanced_multivariable/>
72-
;platform_packages = framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.3
7372
build_flags =
7473
${env.build_flags}
7574
-DBOARD_HAS_PSRAM

0 commit comments

Comments
 (0)