Skip to content

Commit

Permalink
Merge pull request #138 from kike-canaries/wio_terminal
Browse files Browse the repository at this point in the history
Wio terminal initial support
  • Loading branch information
hpsaturn authored Jul 29, 2022
2 parents 79493b9 + 330625d commit 14af90e
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 8 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
}

0 comments on commit 14af90e

Please sign in to comment.