Skip to content

Commit 1dfdd6a

Browse files
committed
Add source code
1 parent eb40af7 commit 1dfdd6a

34 files changed

+3804
-0
lines changed

.github/workflows/arduino-lint.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Arduino Lint
2+
3+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
pull_request:
7+
schedule:
8+
# Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint.
9+
- cron: "0 8 * * TUE"
10+
workflow_dispatch:
11+
repository_dispatch:
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Arduino Lint
22+
uses: arduino/arduino-lint-action@v1
23+
with:
24+
compliance: specification
25+
# library-manager: update
26+
# Always use this setting for official repositories. Remove for 3rd party projects.
27+
official: true
28+
project-type: library
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Source: https://github.com/per1234/.github/blob/main/workflow-templates/compile-examples-private.md
2+
name: Compile Examples
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
paths:
8+
- ".github/workflows/compile-examples.ya?ml"
9+
- "library.properties"
10+
- "examples/**"
11+
- "src/**"
12+
pull_request:
13+
paths:
14+
- ".github/workflows/compile-examples.ya?ml"
15+
- "library.properties"
16+
- "examples/**"
17+
- "src/**"
18+
schedule:
19+
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms).
20+
- cron: "0 8 * * TUE"
21+
workflow_dispatch:
22+
repository_dispatch:
23+
24+
env:
25+
SKETCHES_REPORTS_PATH: sketches-reports
26+
SKETCHES_REPORTS_ARTIFACT_NAME: sketches-reports
27+
28+
jobs:
29+
build:
30+
name: ${{ matrix.board.fqbn }}
31+
runs-on: ubuntu-latest
32+
permissions:
33+
contents: read
34+
pull-requests: read
35+
36+
strategy:
37+
fail-fast: false
38+
39+
matrix:
40+
board:
41+
- fqbn: arduino:mbed_portenta:envie_m7
42+
- fqbn: arduino:mbed_nano:nanorp2040connect
43+
- fqbn: arduino:mbed_nicla:nicla_vision
44+
- fqbn: arduino:mbed_nicla:nicla_sense
45+
- fqbn: arduino:mbed_nano:nano33ble
46+
- fqbn: arduino:renesas_portenta:portenta_c33
47+
- fqbn: arduino:renesas_uno:unor4wifi
48+
- fqbn: arduino:samd:mkrwifi1010
49+
- fqbn: arduino:esp32:nano_nora
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
55+
- name: Compile examples
56+
uses: arduino/compile-sketches@v1
57+
with:
58+
github-token: ${{ secrets.GITHUB_TOKEN }}
59+
fqbn: ${{ matrix.board.fqbn }}
60+
platforms: ${{ matrix.board.platforms }}
61+
enable-deltas-report: true
62+
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
63+
64+
- name: Save sketches report as workflow artifact
65+
uses: actions/upload-artifact@v3
66+
with:
67+
if-no-files-found: error
68+
path: ${{ env.SKETCHES_REPORTS_PATH }}
69+
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
70+
71+
report-size-deltas:
72+
needs: build
73+
# Run even if some compilations failed.
74+
if: always() && github.event_name == 'pull_request'
75+
runs-on: ubuntu-latest
76+
permissions:
77+
pull-requests: write
78+
79+
steps:
80+
- name: Download sketches reports artifact
81+
id: download-artifact
82+
continue-on-error: true # If compilation failed for all boards then there are no artifacts
83+
uses: actions/download-artifact@v3
84+
with:
85+
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
86+
path: ${{ env.SKETCHES_REPORTS_PATH }}
87+
88+
- name: Comment size deltas report to PR
89+
uses: arduino/report-size-deltas@v1
90+
# If actions/download-artifact failed, there are no artifacts to report from.
91+
if: steps.download-artifact.outcome == 'success'
92+
with:
93+
sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Render Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- ".github/workflows/render-documentation.ya?ml"
9+
- "examples/**"
10+
- "src/**"
11+
pull_request:
12+
branches:
13+
- main
14+
paths:
15+
- ".github/workflows/render-documentation.ya?ml"
16+
- "examples/**"
17+
- "src/**"
18+
workflow_dispatch:
19+
20+
jobs:
21+
render-docs:
22+
permissions:
23+
contents: write
24+
uses: sebromero/render-docs-github-action/.github/workflows/render-docs.yml@main
25+
with:
26+
source-path: './src'
27+
target-path: './docs/api.md'
28+
fail-on-warnings: true
29+
commit: ${{ github.event_name != 'pull_request' }} # Only commit changes if not a PR

.github/workflows/spell-check.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Source: https://github.com/per1234/.github/blob/main/workflow-templates/spell-check.md
2+
name: Spell Check
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
pull_request:
8+
schedule:
9+
# Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates.
10+
- cron: "0 8 * * TUE"
11+
workflow_dispatch:
12+
repository_dispatch:
13+
14+
jobs:
15+
spellcheck:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Spell check
25+
uses: codespell-project/actions-codespell@v2

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vscode
2+
.DS_Store

README.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# 🤖 Nicla Sense Env Arduino Library
2+
3+
[![Check Arduino](https://github.com/arduino-libraries/Arduino_UnifiedStorage/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_UnifiedStorage/actions/workflows/check-arduino.yml) [![Compile Examples](https://github.com/arduino-libraries/Arduino_UnifiedStorage/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_UnifiedStorage/actions/workflows/compile-examples.yml) [![Spell Check](https://github.com/arduino-libraries/Arduino_UnifiedStorage/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_UnifiedStorage/actions/workflows/spell-check.yml)
4+
5+
This library contains an API to read data from the Nicla Sense Env board and control its behaviour. The board host three different sensors which can be read simultaneously: **ZMOD4410** (Indoor Air Quality), **ZMOD4510** (Outdoor Air Quality), **HS4001** (Temperature & Humidity).
6+
7+
## ✨ Features
8+
9+
This library supports the complete API exposed by the Nicla Sense Env sensor board over I2C.
10+
11+
- 🌈 RGB LED control
12+
- ⚪️ White LED control
13+
- 💤 Board control (sleep, reset, factory reset)
14+
- 🔧 Board configuration (e.g. changing the I2C address)
15+
- 🏠 Indoor Air Quality Sensor control
16+
- Change mode (Power down, cleaning, Indoor Air quality, sulfur detection)
17+
- Detect sulfur
18+
- Measure odor intensity
19+
- Measure ethanol level
20+
- Measure TVOC
21+
- Measure CO2
22+
- Measure air quality
23+
- 🌳 Outdoor Air Quality Sensor control
24+
- Change mode (Power down, cleaning, Outdoor Air quality)
25+
- Measure NO2
26+
- Measure O3
27+
- Measure air quality
28+
- 🌡 Temperature/Humidity Sensor Control
29+
- Change mode (Power down, temperature/humidity)
30+
- Read temperature
31+
- Read humidity
32+
- 📄 UART CSV output
33+
34+
## 📖 Documentation
35+
For more information on the features of this library and how to use them please read the documentation [here](./docs/).
36+
37+
## ✅ Supported Boards
38+
39+
The library was tested on the Arduino Portenta, Nano and MKR board families but it likely works on other boards that come with a modern Arduino core.
40+
On Arduino boards, the default I2C interface is set to `Wire`. On other boards you may need to specify a different interface depending on the pinout. e.g.
41+
42+
```cpp
43+
NiclaSenseEnv device = NiclaSenseEnv(Wire1);
44+
```
45+
46+
## ⚙️ Installation
47+
48+
The easiest way is to use the Arduino IDE or the Arduino CLI. As for the latter option you can install it with `arduino-cli lib install Arduino_NiclaSenseEnv`. You may need to update the index beforehand `arduino-cli lib update-index`
49+
50+
## 🧑‍💻 Developer Installation
51+
52+
Clone the repository and then run any example using the Arduino CLI. e.g. `arduino-cli compile examples/IndoorAirQuality/IndoorAirQuality.ino -b arduino:samd:mkrwifi1010 --library ./ -u -p /dev/cu.usbmodem14201`
53+
54+
## 🐛 Reporting Issues
55+
56+
If you encounter any issue, please open a bug report [here](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/issues).
57+
58+
## 📕 Further Reading
59+
- Indoor Air Quality:
60+
- [A Sense of Clean Air](https://www.renesas.com/us/en/blogs/sense-clean-air)
61+
- [Overview of TVOC and Indoor Air Quality](https://www.renesas.com/us/en/document/whp/overview-tvoc-and-indoor-air-quality)
62+
- Outdoor Air Quality: [Outdoor Air Quality: It’s Not Just About Urban Areas](https://www.renesas.com/us/en/blogs/outdoor-air-quality-its-not-just-about-urban-areas)
63+
64+
- Datasheets
65+
- [ZMOD4410 datasheet](https://www.renesas.com/us/en/document/dst/zmod4410-datasheet)
66+
- [ZMOD4510 datasheet](https://www.renesas.com/eu/en/document/dst/zmod4510-datasheet)
67+
- [HS4001 datasheet](https://www.renesas.com/us/en/document/dst/hs40xx-datasheet?r=1575071)
68+
69+
## 💪 Contributing
70+
71+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
72+
73+
## 🤙 Contact
74+
75+
For questions, comments, or feedback on this library, please create an issue on this repository.
76+
77+
## ⚖️ License
78+
79+
This library is released under the [MPL-2.0 license](http://mozilla.org/MPL/2.0/).

docs/README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# 📖 Documentation
2+
3+
## 💻 Usage
4+
5+
To use this library you can include the umbrella header `Arduino_NiclaSenseEnv.h` which includes other header files from the library. Then you need to initialize the device object which gives you access to the different sensor and actuator objects:
6+
7+
```cpp
8+
#include "Arduino_NiclaSenseEnv.h"
9+
10+
void setup(){
11+
NiclaSenseEnv device;
12+
13+
if (device.begin()) {
14+
Serial.println("🔌 Device is connected");
15+
16+
auto indoorAirQualitySensor = device.indoorAirQualitySensor();
17+
// ...
18+
auto outdoorAirQualitySensor = device.outdoorAirQualitySensor();
19+
// ...
20+
auto temperatureSensor = device.temperatureHumiditySensor();
21+
// ...
22+
auto rgbLED = device.rgbLED();
23+
// ...
24+
auto whiteLED = device.whiteLED();
25+
// ...
26+
}
27+
}
28+
```
29+
Once the desired object is obtained you can call functions on these objects such as `temperatureSensor.getTemperature()`. A complete list of these functions can be found in the [API documentation](./api.md).
30+
31+
## 🧑‍💻 API
32+
The API documentation can be found [here](./api.md).
33+
34+
## 👀 Examples
35+
36+
The following scripts are examples of how to use the Nicla Sense Env board with Python:
37+
38+
- [BoardControl.ino](../examples/BoardControl/BoardControl.ino): Shows how to print the device information of the Nicla Sense Env, how to disable sensors and how to reset the device or put it to sleep.
39+
- [ChangeI2CAddress.ino](../examples/ChangeI2CAddress/ChangeI2CAddress.ino): Demonstrates how to change the board's I2C address.
40+
- [FactoryReset.ino](../examples/FactoryReset/FactoryReset.ino): Demonstrates how to perform a factory reset on the board.
41+
- [IndoorAirQuality.ino](../examples/IndoorAirQuality/IndoorAirQuality.ino): Demonstrates how to read the indoor air quality data from the board's sensors.
42+
- [OutdoorAirQuality.ino](../examples/OutdoorAirQuality/OutdoorAirQuality.ino): Demonstrates how to read the outdoor air quality data from the board's sensors.
43+
- [RGBLED.ino](../examples/RGBLED/RGBLED.ino): Demonstrates how to control the board's RGB LED.
44+
- [TemperatureHumidity.ino](../examples/TemperatureHumidity/TemperatureHumidity.ino): Demonstrates how to read the temperature and humidity data from the board's sensors.
45+
- [UARTRead.ino](../examples/UARTRead/UARTRead.ino): Shows how to read data from the UART port on the board when not connecting to it over I2C.
46+
- [WhiteLED.ino](../examples/WhiteLED/WhiteLED.ino): Demonstrates how to control the board's white LED.

0 commit comments

Comments
 (0)