Skip to content

Add UnitCO2L support and Add some API #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .github/workflows/Arduino-Lint-Check.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
name: Arduino Lint Check
on:
push:
branches: [ master ]
branches: [ master, main ]
pull_request:
branches: [ master ]
branches: [ master, main ]
workflow_dispatch:

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: arduino/arduino-lint-action@v1
- uses: actions/checkout@v4
- uses: arduino/arduino-lint-action@v2
with:
library-manager: update
compliance: strict
project-type: all
project-type: all
18 changes: 10 additions & 8 deletions .github/workflows/arduino-esp-v2-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ on:
- 'src/unit/**.hpp'
- 'src/unit/**.h'
- 'src/unit/**.c'
- 'test/**.cpp'
- 'test/**.hpp'
- 'test/**.h'
- 'test/**.c'
- 'examples/UnitUnified/**.ino'
- 'examples/UnitUnified/**.cpp'
- 'examples/UnitUnified/**.hpp'
Expand All @@ -32,10 +28,6 @@ on:
- 'src/unit/**.hpp'
- 'src/unit/**.h'
- 'src/unit/**.c'
- 'test/**.cpp'
- 'test/**.hpp'
- 'test/**.h'
- 'test/**.c'
- 'examples/UnitUnified/**.ino'
- 'examples/UnitUnified/**.cpp'
- 'examples/UnitUnified/**.hpp'
Expand All @@ -44,10 +36,19 @@ on:
- '**arduino-esp-v2-build-check.yml'
workflow_dispatch:

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: ${{ matrix.unit }}:${{ matrix.sketch }}:${{matrix.board}}@${{matrix.platform-version}}
runs-on: ubuntu-latest
timeout-minutes: 5

strategy:
fail-fast: false
Expand All @@ -61,6 +62,7 @@ jobs:

unit:
- UnitCO2
- UnitCO2L
- UnitENVIII
- UnitENVIV
- UnitTVOC
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/arduino-esp-v3-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ on:
- 'src/unit/**.hpp'
- 'src/unit/**.h'
- 'src/unit/**.c'
- 'test/**.cpp'
- 'test/**.hpp'
- 'test/**.h'
- 'test/**.c'
- 'examples/UnitUnified/**.ino'
- 'examples/UnitUnified/**.cpp'
- 'examples/UnitUnified/**.hpp'
Expand All @@ -32,10 +28,6 @@ on:
- 'src/unit/**.hpp'
- 'src/unit/**.h'
- 'src/unit/**.c'
- 'test/**.cpp'
- 'test/**.hpp'
- 'test/**.h'
- 'test/**.c'
- 'examples/UnitUnified/**.ino'
- 'examples/UnitUnified/**.cpp'
- 'examples/UnitUnified/**.hpp'
Expand All @@ -44,10 +36,19 @@ on:
- '**arduino-esp-v3-build-check.yml'
workflow_dispatch:

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: ${{ matrix.unit }}:${{ matrix.sketch }}:${{matrix.board}}@${{matrix.platform-version}}
runs-on: ubuntu-latest
timeout-minutes: 5

strategy:
fail-fast: false
Expand All @@ -61,6 +62,7 @@ jobs:

unit:
- UnitCO2
- UnitCO2L
- UnitENVIII
- UnitENVIV
- UnitTVOC
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/arduino-m5-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ on:
- 'src/unit/**.hpp'
- 'src/unit/**.h'
- 'src/unit/**.c'
- 'test/**.cpp'
- 'test/**.hpp'
- 'test/**.h'
- 'test/**.c'
- 'examples/UnitUnified/**.ino'
- 'examples/UnitUnified/**.cpp'
- 'examples/UnitUnified/**.hpp'
Expand All @@ -32,10 +28,6 @@ on:
- 'src/unit/**.hpp'
- 'src/unit/**.h'
- 'src/unit/**.c'
- 'test/**.cpp'
- 'test/**.hpp'
- 'test/**.h'
- 'test/**.c'
- 'examples/UnitUnified/**.ino'
- 'examples/UnitUnified/**.cpp'
- 'examples/UnitUnified/**.hpp'
Expand All @@ -44,10 +36,19 @@ on:
- '**arduino-m5-build-check.yml'
workflow_dispatch:

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: ${{ matrix.unit }}:${{ matrix.sketch }}:${{matrix.board}}@${{matrix.platform-version}}
runs-on: ubuntu-latest
timeout-minutes: 5

strategy:
fail-fast: false
Expand All @@ -61,6 +62,7 @@ jobs:

unit:
- UnitCO2
- UnitCO2L
- UnitENVIII
- UnitENVIV
- UnitTVOC
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ on:
- '**.clang-format'
workflow_dispatch:

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
formatting-check:
name: Formatting Check
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/doxygen-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ on: [release, workflow_dispatch]
# branches:
# - main
# - master
defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/platformio-build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ on:
- 'src/unit/**.hpp'
- 'src/unit/**.h'
- 'src/unit/**.c'
- 'test/**.cpp'
- 'test/**.hpp'
- 'test/**.h'
- 'test/**.c'
- 'examples/UnitUnified/**.ino'
- 'examples/UnitUnified/**.cpp'
- 'examples/UnitUnified/**.hpp'
Expand All @@ -29,10 +25,6 @@ on:
- 'src/unit/**.hpp'
- 'src/unit/**.h'
- 'src/unit/**.c'
- 'test/**.cpp'
- 'test/**.hpp'
- 'test/**.h'
- 'test/**.c'
- 'examples/UnitUnified/**.ino'
- 'examples/UnitUnified/**.cpp'
- 'examples/UnitUnified/**.hpp'
Expand All @@ -42,10 +34,19 @@ on:
- '**platformio.ini'
workflow_dispatch:

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: ${{ matrix.unit }}:${{ matrix.example }}@${{ matrix.board }}:${{ matrix.framework }}:${{ matrix.espressif32 }}
runs-on: ubuntu-latest
timeout-minutes: 5

strategy:
fail-fast: false
Expand All @@ -57,6 +58,7 @@ jobs:

unit:
- UnitCO2
- UnitCO2L
- UnitENVIII
- UnitENVIV
- UnitTVOC
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ CO2 is a photoacoustic Carbon Dioxide (CO2) Unit that will tell you the CO2 PPM
Library for Unit ENV using [M5UnitUnified](https://github.com/m5stack/M5UnitUnified).
M5UnitUnified is a library for unified handling of various M5 units products.

M5UnitUnified currently supports the following units SKU:U001-C, SKU:U103, SKU:U169, and SKU:U088.
### Supported units
- Unit CO2 (SKU:U103)
- Unit CO2L (SKU:U104)
- Unit ENVIII (SKU:U001-C)
- Unit ENVIV (SKU:U001-D)
- Unit ENVPro (SKU:U169)
- Unit TVOC (SKU:U088)

### SKU:U088

Expand All @@ -67,12 +73,6 @@ See also examples using conventional methods here.
#include <M5UnitUnifiedENV.h> // For UnitUnified
//#include <M5UnitENV.h> // When using M5UnitUnified, do not use it at the same time as conventional libraries
```
### Supported units
- Unit CO2
- Unit ENVIII
- Unit ENVPro
- Unit TVOC

Supported units will be added in the future.

### Required Libraries:
Expand Down
33 changes: 32 additions & 1 deletion examples/UnitUnified/UnitCO2/PlotToSerial/main/PlotToSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void setup()
#else
#pragma message "Using Wire"
// Using TwoWire
Wire.end();
Wire.begin(pin_num_sda, pin_num_scl, 400000U);
if (!Units.add(unit, Wire) || !Units.begin()) {
M5_LOGE("Failed to begin");
Expand All @@ -54,6 +55,35 @@ void setup()
M5_LOGI("M5UnitUnified has been begun");
M5_LOGI("%s", Units.debugInfo().c_str());

{
auto ret = unit.stopPeriodicMeasurement();
float offset{};
ret &= unit.readTemperatureOffset(offset);
uint16_t altitude{};
ret &= unit.readSensorAltitude(altitude);
uint16_t pressure{};
ret &= unit.readAmbientPressure(pressure);
bool asc{};
ret &= unit.readAutomaticSelfCalibrationEnabled(asc);
uint16_t ppm{};
ret &= unit.readAutomaticSelfCalibrationTarget(ppm);
ret &= unit.startPeriodicMeasurement();

M5.Log.printf(
" temp offset:%f\n"
" sensor altitude:%u\n"
"ambient pressure:%u\n"
" ASC enabled:%u\n"
" ASC target:%u\n",
offset, altitude, pressure, asc, ppm);

if (!ret) {
lcd.clear(TFT_RED);
while (true) {
m5::utility::delay(1000);
}
}
}
lcd.clear(TFT_DARKGREEN);
}

Expand All @@ -63,6 +93,7 @@ void loop()
Units.update();
if (unit.updated()) {
// Can be checked e.g. by serial plotters
M5_LOGI("\n>CO2:%u\n>Temperature:%2.2f\n>Humidity:%2.2f", unit.co2(), unit.temperature(), unit.humidity());
M5.Log.printf(">CO2:%u\n>Temperature:%2.2f\n>Humidity:%2.2f\n", unit.co2(), unit.temperature(),
unit.humidity());
}
}
11 changes: 11 additions & 0 deletions examples/UnitUnified/UnitCO2L/PlotToSerial/PlotToSerial.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
*
* SPDX-License-Identifier: MIT
*/
/*
Example using M5UnitUnified for UnitCO2L
Required
- M5Unified: https://github.com/m5stack/M5Unified
*/
#include "main/PlotToSerial.cpp"
Loading