Skip to content

Commit

Permalink
Merge pull request #146 from kike-canaries/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
hpsaturn authored Aug 3, 2022
2 parents 830cdb9 + b80df02 commit bbf59eb
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 57 deletions.
20 changes: 12 additions & 8 deletions examples/platformio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,28 @@
[platformio]
src_dir = .

[common_env_data]
[env]
framework = arduino
upload_speed = 1500000
monitor_speed = 115200
build_flags =
-D CORE_DEBUG_LEVEL=0
lib_deps =
hpsaturn/CanAirIO Air Quality Sensors Library

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = ${common_env_data.framework}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
lib_deps = ${common_env_data.lib_deps}
build_flags = ${env.build_flags}
framework = ${env.framework}
upload_speed = ${env.upload_speed}
monitor_speed = ${env.monitor_speed}
lib_deps = ${env.lib_deps}

[env:esp8266]
platform = espressif8266
board = esp12e
framework = ${common_env_data.framework}
monitor_speed = ${common_env_data.monitor_speed}
lib_deps = ${common_env_data.lib_deps}
build_flags = ${env.build_flags}
framework = ${env.framework}
monitor_speed = ${env.monitor_speed}
lib_deps = ${env.lib_deps}
5 changes: 5 additions & 0 deletions examples/wio_terminal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
28 changes: 28 additions & 0 deletions examples/wio_terminal/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env]
framework = arduino
upload_speed = 1500000
monitor_speed = 115200
build_flags =
-D CORE_DEBUG_LEVEL=0
lib_deps =
hpsaturn/CanAirIO Air Quality Sensors Library @ 0.5.5

[env:wioterminal]
platform = atmelsam
board = seeed_wio_terminal
framework = ${env.framework}
build_flags = ${env.build_flags}
upload_speed = ${env.upload_speed}
monitor_speed = ${env.monitor_speed}
lib_deps = ${env.lib_deps}

91 changes: 91 additions & 0 deletions examples/wio_terminal/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* @file main.cpp
* @author Antonio Vanegas @hpsaturn
* @date June 2018 - 2020
* @brief Particle meter sensor tests
* @license GPL3
*
* Full documentation:
* https://github.com/kike-canaries/canairio_sensorlib#canairio-air-quality-sensors-library
*
* Full implementation for WiFi and Bluetooth Air Quality fixed and mobile station:
* https://github.com/kike-canaries/canairio_firmware#canairio-firmware
*
* CanAirIO project docs:
* https://canair.io/docs
*/

#include <Arduino.h>
#include <Sensors.hpp>

void printSensorsDetected() {
uint16_t sensors_count = sensors.getSensorsRegisteredCount();
uint16_t units_count = sensors.getUnitsRegisteredCount();
Serial.println("-->[MAIN] Sensors detected count\t: " + String(sensors_count));
Serial.println("-->[MAIN] Sensors units count \t: " + String(units_count));
Serial.print( "-->[MAIN] Sensors devices names\t: ");
int i = 0;
while (sensors.getSensorsRegistered()[i++] != 0) {
Serial.print(sensors.getSensorName((SENSORS)sensors.getSensorsRegistered()[i - 1]));
Serial.print(",");
}
Serial.println();
}

void printSensorsValues() {
Serial.println("-->[MAIN] Preview sensor values:");
UNIT unit = sensors.getNextUnit();
while(unit != UNIT::NUNIT) {
String uName = sensors.getUnitName(unit);
float uValue = sensors.getUnitValue(unit);
String uSymb = sensors.getUnitSymbol(unit);
Serial.println("-->[MAIN] " + uName + " \t: " + String(uValue) + " " + uSymb);
unit = sensors.getNextUnit();
}
}

void onSensorDataOk() {
Serial.println("======= E X A M P L E T E S T =========");
printSensorsDetected();
printSensorsValues();
Serial.println("=========================================");
}

void onSensorDataError(const char * msg){
}

/******************************************************************************
* M A I N
******************************************************************************/

void setup() {
Serial.begin(115200);
delay(200);
Serial.println("\n== Sensor test setup ==\n");

Serial.println("-->[SETUP] Detecting sensors..");

sensors.setSampleTime(5); // config sensors sample time interval
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
sensors.setOnErrorCallBack(&onSensorDataError); // [optional] error callback
sensors.setDebugMode(true); // [optional] debug mode
sensors.detectI2COnly(true); // disable force to only i2c sensors
sensors.init(); // Auto detection to UART and i2c sensors

// Alternatives only for UART sensors (TX/RX):

// sensors.init(sensors.Auto); // Auto detection to UART sensors (Honeywell, Plantower, Panasonic)
// sensors.init(sensors.Panasonic); // Force UART detection to Panasonic sensor
// sensors.init(sensors.Sensirion); // Force UART detection to Sensirion sensor
// sensors.init(sensors.Mhz19); // Force UART detection to Mhz14 or Mhz19 CO2 sensor
// sensors.init(sensors.SDS011); // Force UART detection to SDS011 sensor
// sensors.init(sensors.CM1106); // Force UART detection to CM1106 CO2 sensor
// sensors.init(sensors.SENSEAIRS8); // Force UART detection to SenseAirS8 CO2 sensor
// sensors.init(sensors.Auto,PMS_RX,PMS_TX); // Auto detection on custom RX,TX


}

void loop() {
sensors.loop(); // read sensor data and showed it
}
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CanAirIO Air Quality Sensors Library",
"version": "0.5.6",
"version": "0.5.7",
"homepage":"https://canair.io",
"keywords":
[
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=CanAirIO Air Quality Sensors Library
version=0.5.6
version=0.5.7
author=@hpsaturn, CanAirIO project <[email protected]>
maintainer=Antonio Vanegas <[email protected]>
url=https://github.com/kike-canaries/canairio_sensorlib
Expand Down
67 changes: 23 additions & 44 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,63 +33,42 @@ lib_deps =
https://github.com/jcomas/S8_UART.git
https://github.com/jcomas/CM1106_UART.git

[esp32_common]
platform = espressif32
board = esp32dev
[common]
framework = ${env.framework}
upload_speed = ${env.upload_speed}
monitor_speed = ${env.monitor_speed}
build_flags = ${env.build_flags}
lib_deps = ${env.lib_deps}
build_flags =
${env.build_flags}

[esp32_common]
extends = common
platform = espressif32
board = esp32dev

[esp8266_common]
extends = common
platform = espressif8266
framework = ${env.framework}
board = esp12e
monitor_speed = ${env.monitor_speed}
build_flags =
${env.build_flags}
lib_deps =
${env.lib_deps}

[arduino_avr]
platform = atmelavr
board = pro16MHzatmega328
framework = arduino
monitor_speed = ${env.monitor_speed}
build_flags =
${env.build_flags}
lib_deps =
${env.lib_deps}

[env:esp8266full]
extends = esp8266_common
src_filter = -<*> +<platformio/>
[atmelsam_common]
extends = common
platform = atmelsam
board = seeed_wio_terminal

[env:esp32sps30i2c]
extends = esp32_common
src_filter = -<*> +<sps30i2c/>
;;;;;;;;;;;;;;;;;
;; T E S T S :
;;;;;;;;;;;;;;;;;

[env:esp32full]
extends = esp32_common
src_filter = -<*> +<platformio/>
[env:esp8266]
extends = esp8266_common
build_src_filter = -<*> +<advanced_multivariable/>

[env:esp32]
extends = esp32_common
src_filter = -<*> +<advanced_multivariable/>
build_src_filter = -<*> +<advanced_multivariable/>

[env:atmelsam]
extends = atmelsam_common
build_src_filter = -<*> +<wio_terminal/>

; [env:teensy36]
; platform = teensy
; framework = arduino
; board = teensy36
; upload_speed = ${env.upload_speed}
; monitor_speed = ${env.monitor_speed}
; lib_deps = ${env.lib_deps}
; build_flags =
; ${env.build_flags}
; -D TEENSY_OPT_SMALLEST_CODE

;[env:arduino]
;extends = arduino_avr
;src_filter = -<*> +<platformio/>
2 changes: 1 addition & 1 deletion src/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ void Sensors::enableWire1() {
#endif
#ifdef M5ATOM
Wire1.flush();
Wire1.begin(26,32,100000); // M5CoreInk Ext port (default for all sensors)
Wire1.begin(26,32); // M5CoreInk Ext port (default for all sensors)
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions src/Sensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <s8_uart.h>
#include <sps30.h>

#define CSL_VERSION "0.5.6"
#define CSL_REVISION 362
#define CSL_VERSION "0.5.7"
#define CSL_REVISION 363

/***************************************************************
* 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
Expand Down

0 comments on commit bbf59eb

Please sign in to comment.