Skip to content

Commit

Permalink
Merge pull request #44 from Sensirion/scd4x_2.0_20250129_1204
Browse files Browse the repository at this point in the history
Generate SCD4x driver from SCD4x model version 2.0
  • Loading branch information
LeonieFierz authored Jan 31, 2025
2 parents 229d854 + 2e763f3 commit 414c8ac
Show file tree
Hide file tree
Showing 21 changed files with 2,132 additions and 1,277 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/arduino_quality_check.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Quality check

on:
pull_request:
branches:
- master
push:
pull_request:
branches:
- master

Expand All @@ -13,4 +11,5 @@ jobs:
uses: sensirion/.github/.github/workflows/driver.arduino.check.yml@main
with:
expect-arduino-examples: true
# change to "update" once you published the driver on Arduino library registry
lint-lib-manager-check: update
57 changes: 10 additions & 47 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,23 @@
# Changelog

All notable changes to this project will be documented in this file.
# CHANGELOG

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [Unreleased]

## [0.4.0] - 2023-03-06
## [1.0.0] - 2025-1-30

### Added
- Methods for ASC (Automatic Self Calibration)

### Breaking changes
- Renamed getDataReadyStatus to getDataReadyFlag

### Fixed
- RH/T conversion now uses correct constant: `2^16 - 1`
- Fixed a few comments
- Initializing the output variables to zero

## [0.3.1] - 2021-04-30

### Changed
- All commands according to data sheet

* Increase timing for single shot from 1350ms to 5000ms
* Increase timing for self test from 5500ms to 10000ms


## [0.3.0] - 2021-03-01
## [0.1.0] - 2021-2-1

### Added
- Convenience interfaces taking care of unit conversion to and from ticks.

### Fixed
- wake-up interface handles missing ACK from sensor on wake up.


## [0.2.0] - 2021-02-10

### Changed

* Updated Sensirion Core library version from 0.4.0 to 0.4.2. This includes the
renaming of the library header file from `SensirionCoreArduinoLibrary.h` to
`SensirionCore.h`.
* Define `SCD4X_I2C_ADDRESS` as hex instead of dec (unchanged value).

### Added

* Added warning about limited EEPROM write cycles.

## [0.1.0] - 2021-02-05

Initial release
- Initial version
- Check latest 0.x.x version for changelog prior to version 1.0.0

[0.3.1]: https://github.com/Sensirion/arduino-i2c-scd4x/compare/0.3.0...0.3.1
[0.3.0]: https://github.com/Sensirion/arduino-i2c-scd4x/compare/0.2.0...0.3.0
[0.2.0]: https://github.com/Sensirion/arduino-i2c-scd4x/compare/0.1.0...0.2.0
[0.1.0]: https://github.com/Sensirion/arduino-i2c-scd4x/releases/tag/0.1.0
[Unreleased]: https://github.com/Sensirion/arduino-i2c-scd4x/compare/1.0.0...HEAD
[1.0.0]: https://github.com/Sensirion/arduino-i2c-scd4x/compare/0.1.0...1.0.0
[0.1.0]: https://github.com/Sensirion/arduino-i2c-scd4x/releases/tag/0.1.0
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2021, Sensirion AG
Copyright (c) 2025, Sensirion AG
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
209 changes: 171 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,195 @@
# Sensirion I2C SCD4x Arduino Library
# Sensirion I²C SCD4X Arduino Library

This is the Sensirion SCD4x library for Arduino using the I2C interface.
This is the Sensirion SCD4X library for Arduino allowing you to
communicate with a sensor of the SCD4X family over I²C.

[<center><img src="images/SCD41_Development_Board.png" width="300px"></center>](https://sensirion.com/my-scd-ek)
<img src="images/SCD41.png" width="300px">

Click [here](https://sensirion.com/my-scd-ek) to learn more about the SCD4x
sensor and the SCD41 Evaluation Kit Board.
Click [here](https://sensirion.com/products/catalog/SEK-SCD41) to learn more about the Sensirion SCD4X sensor family.

# Installation

To install, download the latest release as .zip file and add it to your
[Arduino IDE](http://www.arduino.cc/en/main/software) via
Not all sensors of this driver family support all measurements.
In case a measurement is not supported by all sensors, the products that
support it are listed in the API description.

Sketch => Include Library => Add .ZIP Library...

Don't forget to **install the dependencies** listed below the same way via `Add
.ZIP Library`

Note: Installation via the Arduino Library Manager is coming soon.
## Supported sensor types

# Dependencies
| Sensor name | I²C Addresses |
| ------------- | -------------- |
|[SCD40](https://sensirion.com/products/catalog/SCD40)| **0x62**|
|[SCD41](https://sensirion.com/products/catalog/SCD41)| **0x62**|

The following instructions and examples use a *SCD41*.



## Installation of the library

This library can be installed using the Arduino Library manager:
Start the [Arduino IDE](http://www.arduino.cc/en/main/software) and open
the Library Manager via

`Sketch``Include Library``Manage Libraries...`

Search for the `Sensirion I2C SCD4X` library in the `Filter
your search...` field and install it by clicking the `install` button.

If you cannot find it in the library manager, download the latest release as .zip file
and add it to your [Arduino IDE](http://www.arduino.cc/en/main/software) via

`Sketch``Include Library``Add .ZIP Library...`

Don't forget to **install the dependencies** listed below the same way via library
manager or `Add .ZIP Library`

#### Dependencies
* [Sensirion Core](https://github.com/Sensirion/arduino-core)

## Connect the sensor

Use the following pin description to connect your SCD4X to the standard I²C bus of your Arduino board:

<img src="images/SCD41_pinout.png" width="300px">

| *Pin* | *Cable Color* | *Name* | *Description* | *Comments* |
|-------|---------------|:------:|----------------|------------|
| 1 | yellow | SCL | I2C: Serial clock input |
| 2 | black | GND | Ground |
| 3 | red | VDD | Supply Voltage | 2.4V to 5.5V
| 4 | green | SDA | I2C: Serial data input / output |




The recommended voltage is 3.3V.

### Board specific wiring
You will find pinout schematics for recommended board models below:



<details><summary>Arduino Uno</summary>
<p>

| *SCD4X* | *SCD4X Pin* | *Cable Color* | *Board Pin* |
| :---: | --- | --- | --- |
| SCL | 1 | yellow | D19/SCL |
| GND | 2 | black | GND |
| VDD | 3 | red | 3.3V |
| SDA | 4 | green | D18/SDA |



<img src="images/Arduino-Uno-Rev3-i2c-pinout-3.3V.png" width="600px">
</p>
</details>




<details><summary>Arduino Nano</summary>
<p>

| *SCD4X* | *SCD4X Pin* | *Cable Color* | *Board Pin* |
| :---: | --- | --- | --- |
| SCL | 1 | yellow | A5 |
| GND | 2 | black | GND |
| VDD | 3 | red | 3.3V |
| SDA | 4 | green | A4 |


# Quick Start

1. Connect the SCD4x sensor to your Arduino board's standard I2C bus. Check
the pinout of your Arduino board to find the correct pins. The pinout of the
SCD4x sensor board can be found [here](https://sensirion.com/my-scd-ek)
<img src="images/Arduino-Nano-i2c-pinout-3.3V.png" width="600px">
</p>
</details>

* **VDD** of the SEK-SCD41 to the **3.3V** of your Arduino board (5V is also possible)
* **GND** of the SEK-SCD41 to the **GND** of your Arduino board
* **SCL** of the SEK-SCD41 to the **SCL** of your Arduino board
* **SDA** of the SEK-SCD41 to the **SDA** of your Arduino board

2. Open the `exampleUsage` sample project within the Arduino IDE

File => Examples => Sensirion I2C Scd4x => exampleUsage

3. Click the `Upload` button in the Arduino IDE or
<details><summary>Arduino Micro</summary>
<p>

Sketch => Upload
| *SCD4X* | *SCD4X Pin* | *Cable Color* | *Board Pin* |
| :---: | --- | --- | --- |
| SCL | 1 | yellow | ~D3/SCL |
| GND | 2 | black | GND |
| VDD | 3 | red | 3.3V |
| SDA | 4 | green | D2/SDA |



<img src="images/Arduino-Micro-i2c-pinout-3.3V.png" width="600px">
</p>
</details>




<details><summary>Arduino Mega 2560</summary>
<p>

| *SCD4X* | *SCD4X Pin* | *Cable Color* | *Board Pin* |
| :---: | --- | --- | --- |
| SCL | 1 | yellow | D21/SCL |
| GND | 2 | black | GND |
| VDD | 3 | red | 3.3V |
| SDA | 4 | green | D20/SDA |



<img src="images/Arduino-Mega-2560-Rev3-i2c-pinout-3.3V.png" width="600px">
</p>
</details>




<details><summary>ESP32 DevKitC</summary>
<p>

| *SCD4X* | *SCD4X Pin* | *Cable Color* | *Board Pin* |
| :---: | --- | --- | --- |
| SCL | 1 | yellow | GPIO 22 |
| GND | 2 | black | GND |
| VDD | 3 | red | 3V3 |
| SDA | 4 | green | GPIO 21 |



<img src="images/esp32-devkitc-i2c-pinout-3.3V.png" width="600px">
</p>
</details>



## Quick Start

1. Install the libraries and dependencies according to [Installation of the library](#installation-of-the-library)

2. Connect the SCD4X sensor to your Arduino as explained in [Connect the sensor](#connect-the-sensor)

3. Open the `exampleUsage` sample project within the Arduino IDE:

`File``Examples``Sensirion I2C SCD4X``exampleUsage`


The provided example is working with a SCD41, I²C address 0x62.
In order to use the code with another product or I²C address you need to change it in the code of `examples/exampleUsage`.
You find the list with pre-defined addresses in `src/SensirionI2CSCD4X.h`.


5. Click the `Upload` button in the Arduino IDE or `Sketch``Upload`

4. When the upload process has finished, open the `Serial Monitor` or `Serial
Plotter` via the `Tools` menu to observe the measured CO2, Temperature and
Humidity values. Note that the `Baud Rate` in the corresponding window has
to be set to `115200 baud`.
Plotter` via the `Tools` menu to observe the measurement values. Note that
the `Baud Rate` in the used tool has to be set to `115200 baud`.

# Contributing
## Contributing

**Contributions are welcome!**

We develop and test this driver using our company internal tools (version
control, continuous integration, code review etc.) and automatically
synchronize the master branch with GitHub. But this doesn't mean that we don't
respond to issues or don't accept pull requests on GitHub. In fact, you're very
welcome to open issues or create pull requests :)

This Sensirion library uses
[`clang-format`](https://releases.llvm.org/download.html) to standardize the
formatting of all our `.cpp` and `.h` files. Make sure your contributions are
Expand All @@ -66,12 +198,13 @@ formatted accordingly:
The `-i` flag will apply the format changes to the files listed.

```bash
clang-format -i *.cpp *.h
clang-format -i src/*.cpp src/*.h
```

Note that differences from this formatting will result in a failed build until
they are fixed.
:

# License
## License

See [LICENSE](LICENSE).
See [LICENSE](LICENSE).
Loading

0 comments on commit 414c8ac

Please sign in to comment.