Skip to content

Commit 09c8d8d

Browse files
authored
Merge pull request #207 from kike-canaries/devel
Devel
2 parents fb7c28b + 40d11ad commit 09c8d8d

File tree

20 files changed

+963
-88
lines changed

20 files changed

+963
-88
lines changed

.github/workflows/platformio.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,23 @@ on:
1515

1616
jobs:
1717
build:
18-
runs-on: ubuntu-latest
18+
runs-on: ${{ matrix.os }}
1919
strategy:
2020
max-parallel: 1
2121
matrix:
22-
python-version: [3.7]
22+
os: [ubuntu-latest]
2323
steps:
24-
- uses: actions/checkout@v1
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v1
24+
- uses: actions/checkout@v4
25+
- uses: actions/cache@v3
2726
with:
28-
python-version: ${{ matrix.python-version }}
27+
path: |
28+
~/.cache/pip
29+
~/.platformio/.cache
30+
key: ${{ runner.os }}-pio
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: '3.10'
2935
- name: Install dependencies
3036
run: |
3137
python -m pip install --upgrade pip
@@ -34,12 +40,7 @@ jobs:
3440
- name: Basic Arduino IDE example test
3541
run: |
3642
cd examples/advanced_sensirion
37-
pio run
38-
- name: PlatformIO registry backward (M5CoreInk project)
39-
run: |
40-
git clone https://github.com/hpsaturn/co2_m5coreink.git
41-
cd co2_m5coreink
42-
pio run
43+
pio run
4344
- name: PlatformIO registry lastest (M5Atom project)
4445
run: |
4546
cd examples/m5atom

.github/workflows/schedule.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
name: Schedule
2-
32

43
on:
54
schedule:
65
- cron: '30 10 * * 3'
76

87
jobs:
98
build:
10-
runs-on: ubuntu-latest
9+
runs-on: ${{ matrix.os }}
1110
strategy:
1211
max-parallel: 1
1312
matrix:
14-
python-version: [3.7]
13+
os: [ubuntu-latest]
1514
steps:
16-
- uses: actions/checkout@v1
17-
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v1
15+
- uses: actions/checkout@v4
16+
- uses: actions/cache@v3
1917
with:
20-
python-version: ${{ matrix.python-version }}
18+
path: |
19+
~/.cache/pip
20+
~/.platformio/.cache
21+
key: ${{ runner.os }}-pio
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.10'
2126
- name: Install dependencies
2227
run: |
2328
python -m pip install --upgrade pip

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
[![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)
2+
[![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)
33

44
# Air Quality Sensors Library
55

examples/m5airq/platformio.ini

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
[platformio]
12+
src_dir = .
13+
lib_dir = ../..
14+
extra_configs = ../../unified-lib-deps.ini
15+
16+
[env]
17+
framework = arduino
18+
upload_speed = 1500000
19+
monitor_speed = 115200
20+
build_flags =
21+
-D CORE_DEBUG_LEVEL=0
22+
-D ARDUINO_USB_CDC_ON_BOOT=1
23+
-D ARDUINO_ESP32_DEV=1
24+
-D M5AIRQ=1 ; in your implementation you NEED it (it will improved in the future)
25+
lib_deps =
26+
${commonlibs.lib_deps}
27+
28+
[env:m5airq]
29+
extends = env
30+
platform = espressif32
31+
board = esp32-s3-devkitc-1
32+
board_build.filesystem = littlefs ; compatibility with original demo firmware

examples/m5airq/src/main.cpp

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* @file main.cpp
3+
* @author Antonio Vanegas @hpsaturn
4+
* @date June 2018 - 2024
5+
* @brief CanAirIO M5AirQ test
6+
* @license GPL3
7+
*
8+
* Full documentation:
9+
* https://github.com/kike-canaries/canairio_sensorlib#canairio-air-quality-sensors-library
10+
*
11+
* Full implementation for WiFi and Bluetooth Air Quality fixed and mobile station:
12+
* https://github.com/kike-canaries/canairio_firmware#canairio-firmware
13+
*
14+
* CanAirIO project documentation:
15+
* https://canair.io/docs
16+
*/
17+
18+
#include <Arduino.h>
19+
20+
#include <Sensors.hpp>
21+
22+
#define POWER_HOLD 46 // M5AirQ main board
23+
#define SEN55_POWER_EN 10
24+
25+
#define GROVE_SDA 13
26+
#define GROVE_SCL 15
27+
28+
#define I2C1_SDA_PIN 11
29+
#define I2C1_SCL_PIN 12
30+
31+
void printSensorsDetected() {
32+
uint16_t sensors_count = sensors.getSensorsRegisteredCount();
33+
uint16_t units_count = sensors.getUnitsRegisteredCount();
34+
Serial.println("-->[MAIN] Sensors detected \t: " + String(sensors_count));
35+
Serial.println("-->[MAIN] Sensors units count\t: " + String(units_count));
36+
Serial.print("-->[MAIN] Sensors devices names\t: ");
37+
int i = 0;
38+
while (sensors.getSensorsRegistered()[i++] != 0) {
39+
Serial.print(sensors.getSensorName((SENSORS)sensors.getSensorsRegistered()[i - 1]));
40+
Serial.print(",");
41+
}
42+
Serial.println();
43+
}
44+
45+
void printSensorsValues() {
46+
Serial.println("-->[MAIN] Preview sensor values :");
47+
UNIT unit = sensors.getNextUnit();
48+
while (unit != UNIT::NUNIT) {
49+
String uName = sensors.getUnitName(unit);
50+
float uValue = sensors.getUnitValue(unit);
51+
String uSymb = sensors.getUnitSymbol(unit);
52+
Serial.printf("-->[MAIN] %6s:\t%02.1f\t%s\n", uName.c_str(), uValue, uSymb.c_str());
53+
unit = sensors.getNextUnit();
54+
}
55+
}
56+
57+
void onSensorDataOk() {
58+
Serial.println("======= E X A M P L E T E S T =========");
59+
printSensorsDetected();
60+
printSensorsValues();
61+
}
62+
63+
void onSensorDataError(const char* msg) {}
64+
/******************************************************************************
65+
* M A I N
66+
******************************************************************************/
67+
68+
void powerEnableSensors() {
69+
Serial.println("-->[POWR] == enable sensors ==");
70+
pinMode(POWER_HOLD, OUTPUT);
71+
digitalWrite(POWER_HOLD, HIGH);
72+
pinMode(SEN55_POWER_EN, OUTPUT);
73+
digitalWrite(SEN55_POWER_EN, LOW);
74+
}
75+
76+
void setup() {
77+
Serial.begin(115200);
78+
delay(2000); // Only for debugging
79+
powerEnableSensors(); // M5AirQ enable sensors
80+
81+
delay(100);
82+
Serial.println("\n== Sensor test setup ==\n");
83+
Serial.println("-->[SETUP] Detecting sensors..");
84+
85+
sensors.setSampleTime(10); // config sensors sample time interval
86+
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
87+
sensors.setDebugMode(false); // [optional] debug mode
88+
sensors.detectI2COnly(true); // not force to only i2c sensors
89+
sensors.setTemperatureUnit(TEMPUNIT::CELSIUS); // comment for Celsius or set Fahrenheit
90+
sensors.init(); // Auto detection (UART and i2c sensors)
91+
delay(1000);
92+
}
93+
94+
void loop() {
95+
sensors.loop(); // read sensor data and showed it
96+
}

examples/m5atom/platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ build_flags =
2323
lib_deps =
2424
hpsaturn/CanAirIO Air Quality Sensors Library @ 0.7.4
2525
fastled/FastLED@^3.5.0
26-
m5stack/M5Atom@^0.0.7
26+
m5stack/M5Atom@^0.1.2

library.json

Lines changed: 3 additions & 2 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.4",
3+
"version": "0.7.5",
44
"homepage":"https://canair.io",
55
"keywords":
66
[
@@ -86,10 +86,11 @@
8686
{"name":"AM232X", "owner":"robtillaart", "version":"0.5.0"},
8787
{"name":"sps30", "owner":"paulvha","version":"1.4.17"},
8888
{"name":"MH-Z19", "owner":"wifwaf", "version":"1.5.4"},
89-
{"name":"S8_UART", "owner":"jcomas", "version":"1.0.1"},
89+
{"name":"S8_UART", "owner":"jcomas", "version":"1.0.2"},
9090
{"name":"Sensirion Core","owner":"sensirion","version":"0.6.0"},
9191
{"name":"Sensirion I2C SCD4x","owner":"sensirion","version":"0.4.0"},
9292
{"name":"Sensirion I2C SEN5X","owner":"sensirion","version":"0.3.0"},
93+
{"name":"Sensirion I2C SGP41","owner":"sensirion","version":"1.0.0"},
9394
{"name":"DFRobot_MultiGasSensor","owner":"phzi","version":"2.0.0"},
9495

9596
{"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.4
2+
version=0.7.5
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)