Skip to content

Commit

Permalink
Merge pull request #207 from kike-canaries/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
hpsaturn authored Jan 18, 2025
2 parents fb7c28b + 40d11ad commit 09c8d8d
Show file tree
Hide file tree
Showing 20 changed files with 963 additions and 88 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
matrix:
python-version: [3.7]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
python-version: ${{ matrix.python-version }}
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -34,12 +40,7 @@ jobs:
- name: Basic Arduino IDE example test
run: |
cd examples/advanced_sensirion
pio run
- name: PlatformIO registry backward (M5CoreInk project)
run: |
git clone https://github.com/hpsaturn/co2_m5coreink.git
cd co2_m5coreink
pio run
pio run
- name: PlatformIO registry lastest (M5Atom project)
run: |
cd examples/m5atom
Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
name: Schedule


on:
schedule:
- cron: '30 10 * * 3'

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
matrix:
python-version: [3.7]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
python-version: ${{ matrix.python-version }}
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

[![PlatformIO](https://github.com/kike-canaries/canairio_sensorlib/workflows/PlatformIO/badge.svg)](https://github.com/kike-canaries/canairio_sensorlib/actions/) [![Build Status](https://travis-ci.com/kike-canaries/canairio_sensorlib.svg?branch=master)](https://travis-ci.com/kike-canaries/canairio_sensorlib.svg?branch=master) ![ViewCount](https://views.whatilearened.today/views/github/kike-canaries/canairio_sensorlib.svg)
[![PlatformIO](https://github.com/kike-canaries/canairio_sensorlib/workflows/PlatformIO/badge.svg)](https://github.com/kike-canaries/canairio_sensorlib/actions/) ![ViewCount](https://views.whatilearened.today/views/github/kike-canaries/canairio_sensorlib.svg) [![Telegram Group](https://img.shields.io/endpoint?color=neon&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fcanairio)](https://t.me/canairio)

# Air Quality Sensors Library

Expand Down
32 changes: 32 additions & 0 deletions examples/m5airq/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; 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

[platformio]
src_dir = .
lib_dir = ../..
extra_configs = ../../unified-lib-deps.ini

[env]
framework = arduino
upload_speed = 1500000
monitor_speed = 115200
build_flags =
-D CORE_DEBUG_LEVEL=0
-D ARDUINO_USB_CDC_ON_BOOT=1
-D ARDUINO_ESP32_DEV=1
-D M5AIRQ=1 ; in your implementation you NEED it (it will improved in the future)
lib_deps =
${commonlibs.lib_deps}

[env:m5airq]
extends = env
platform = espressif32
board = esp32-s3-devkitc-1
board_build.filesystem = littlefs ; compatibility with original demo firmware
96 changes: 96 additions & 0 deletions examples/m5airq/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* @file main.cpp
* @author Antonio Vanegas @hpsaturn
* @date June 2018 - 2024
* @brief CanAirIO M5AirQ test
* @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 documentation:
* https://canair.io/docs
*/

#include <Arduino.h>

#include <Sensors.hpp>

#define POWER_HOLD 46 // M5AirQ main board
#define SEN55_POWER_EN 10

#define GROVE_SDA 13
#define GROVE_SCL 15

#define I2C1_SDA_PIN 11
#define I2C1_SCL_PIN 12

void printSensorsDetected() {
uint16_t sensors_count = sensors.getSensorsRegisteredCount();
uint16_t units_count = sensors.getUnitsRegisteredCount();
Serial.println("-->[MAIN] Sensors detected \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.printf("-->[MAIN] %6s:\t%02.1f\t%s\n", uName.c_str(), uValue, uSymb.c_str());
unit = sensors.getNextUnit();
}
}

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

void onSensorDataError(const char* msg) {}
/******************************************************************************
* M A I N
******************************************************************************/

void powerEnableSensors() {
Serial.println("-->[POWR] == enable sensors ==");
pinMode(POWER_HOLD, OUTPUT);
digitalWrite(POWER_HOLD, HIGH);
pinMode(SEN55_POWER_EN, OUTPUT);
digitalWrite(SEN55_POWER_EN, LOW);
}

void setup() {
Serial.begin(115200);
delay(2000); // Only for debugging
powerEnableSensors(); // M5AirQ enable sensors

delay(100);
Serial.println("\n== Sensor test setup ==\n");
Serial.println("-->[SETUP] Detecting sensors..");

sensors.setSampleTime(10); // config sensors sample time interval
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
sensors.setDebugMode(false); // [optional] debug mode
sensors.detectI2COnly(true); // not force to only i2c sensors
sensors.setTemperatureUnit(TEMPUNIT::CELSIUS); // comment for Celsius or set Fahrenheit
sensors.init(); // Auto detection (UART and i2c sensors)
delay(1000);
}

void loop() {
sensors.loop(); // read sensor data and showed it
}
2 changes: 1 addition & 1 deletion examples/m5atom/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ build_flags =
lib_deps =
hpsaturn/CanAirIO Air Quality Sensors Library @ 0.7.4
fastled/FastLED@^3.5.0
m5stack/M5Atom@^0.0.7
m5stack/M5Atom@^0.1.2
5 changes: 3 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CanAirIO Air Quality Sensors Library",
"version": "0.7.4",
"version": "0.7.5",
"homepage":"https://canair.io",
"keywords":
[
Expand Down Expand Up @@ -86,10 +86,11 @@
{"name":"AM232X", "owner":"robtillaart", "version":"0.5.0"},
{"name":"sps30", "owner":"paulvha","version":"1.4.17"},
{"name":"MH-Z19", "owner":"wifwaf", "version":"1.5.4"},
{"name":"S8_UART", "owner":"jcomas", "version":"1.0.1"},
{"name":"S8_UART", "owner":"jcomas", "version":"1.0.2"},
{"name":"Sensirion Core","owner":"sensirion","version":"0.6.0"},
{"name":"Sensirion I2C SCD4x","owner":"sensirion","version":"0.4.0"},
{"name":"Sensirion I2C SEN5X","owner":"sensirion","version":"0.3.0"},
{"name":"Sensirion I2C SGP41","owner":"sensirion","version":"1.0.0"},
{"name":"DFRobot_MultiGasSensor","owner":"phzi","version":"2.0.0"},

{"name":"AHTxx", "version":"https://github.com/enjoyneering/AHTxx.git#eb21571"},
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.7.4
version=0.7.5
author=@hpsaturn, CanAirIO project <[email protected]>
maintainer=Antonio Vanegas <[email protected]>
url=https://github.com/kike-canaries/canairio_sensorlib
Expand Down
Loading

0 comments on commit 09c8d8d

Please sign in to comment.