diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 71fc2e7..2c74751 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,6 +2,9 @@ stages:
- validate
- test
+variables:
+ YQ_URL: https://github.com/mikefarah/yq/releases/download/v4.33.3/yq_linux_amd64
+
compile_test:
stage: test
image:
@@ -11,12 +14,23 @@ compile_test:
- rm -rf ../sensirion-core-arduino-library
script:
- git clone --depth 1 --branch 0.5.2 https://github.com/Sensirion/arduino-core.git ../sensirion-core-arduino-library
- - arduino-cli compile --libraries=".." --warnings all --fqbn arduino:samd:mkrzero examples/exampleUsage
- - arduino-cli compile --libraries=".." --warnings all --fqbn arduino:avr:mega examples/exampleUsage
- - arduino-cli compile --libraries=".." --warnings all --fqbn arduino:avr:nano examples/exampleUsage
- - arduino-cli compile --libraries=".." --warnings all --fqbn arduino:avr:uno examples/exampleUsage
- - arduino-cli compile --libraries=".." --warnings all --fqbn esp32:esp32:esp32 examples/exampleUsage
- - arduino-cli compile --libraries=".." --warnings all --fqbn esp8266:esp8266:generic examples/exampleUsage
+ - arduino-cli compile --libraries=".." --warnings all --fqbn arduino:samd:mkrzero ./examples/exampleUsage/exampleUsage.ino
+ - arduino-cli compile --libraries=".." --warnings all --fqbn arduino:avr:mega ./examples/exampleUsage/exampleUsage.ino
+ - arduino-cli compile --libraries=".." --warnings all --fqbn arduino:avr:nano ./examples/exampleUsage/exampleUsage.ino
+ - arduino-cli compile --libraries=".." --warnings all --fqbn arduino:avr:uno ./examples/exampleUsage/exampleUsage.ino
+ - arduino-cli compile --libraries=".." --warnings all --fqbn esp32:esp32:esp32 ./examples/exampleUsage/exampleUsage.ino
+ - arduino-cli compile --libraries=".." --warnings all --fqbn esp8266:esp8266:generic ./examples/exampleUsage/exampleUsage.ino
+
+arduino_lint:
+ stage: validate
+ image:
+ name: registry.gitlab.sensirion.lokal/mso-sw/drivers/docker-driver-generator:0.2.0
+ tags: [linux, docker]
+ script:
+ - mkdir ~/arlint
+ - PATH=~/arlint:$PATH
+ - curl -fsSL https://raw.githubusercontent.com/arduino/arduino-lint/main/etc/install.sh | BINDIR=~/arlint sh
+ - arduino-lint --library-manager false
syntax_check:
stage: validate
@@ -33,7 +47,7 @@ cppcheck:
name: registry.gitlab.sensirion.lokal/mso-sw/drivers/docker-driver-generator:0.2.0
tags: [linux, docker]
script:
- - cppcheck --std=c++11 --language=c++ --error-exitcode=1 --enable=warning,style,performance,portability src/*
+ - cppcheck --std=c++11 --language=c++ --error-exitcode=1 --enable=warning,style,performance,portability --suppress=unreadVariable src/*
TODO_check:
stage: validate
@@ -42,3 +56,48 @@ TODO_check:
tags: [linux, docker]
script:
- '! grep -rnw --exclude=.gitlab-ci.yml --exclude-dir=.git . -e "TODO"'
+
+metadata_check:
+ stage: validate
+ image:
+ name: registry.gitlab.sensirion.lokal/mso-sw/drivers/docker-driver-generator:0.2.0
+ tags: [linux, docker]
+ before_script:
+ - apt-get -qq update && apt-get -qq install -y wget
+ - if ! [ -d downloads/ ]; then mkdir downloads; fi
+ - if ! [ -e downloads/yq ]; then wget --no-verbose $YQ_URL -O downloads/yq; fi
+ - cp downloads/yq /usr/local/bin/yq && chmod +x /usr/local/bin/yq
+ script:
+ # check if metadata.yml exists
+ - >
+ if ! [ -f "metadata.yml" ]; then
+ echo "metadata.yml file not found"
+ exit 1
+ fi
+ # check that dg_status is 'released'
+ - export DG_STATUS=$(yq ".dg_status.[]" ./metadata.yml)
+ - >
+ if [ $DG_STATUS != "released" ]; then
+ echo "dg_status in metadata.yml has to be 'released', not '$DG_STATUS'"
+ exit 1
+ fi
+ # check that last_generated is not older than timestamp of last non-merge commit (+ 3 minutes)
+ - export IS_MANUALLY_MODIFIED=$(yq ".is_manually_modified" ./metadata.yml)
+ - >
+ if [ $IS_MANUALLY_MODIFIED = false ]; then
+ export LAST_GENERATED_TS=$(yq ".last_generated" ./metadata.yml)
+ export LAST_GENERATED_TS_EPOCH=$(date -d "$LAST_GENERATED_TS" +%s)
+ export LAST_NON_MERGE_COMMIT_TS=$(git log --format=%ad --date=iso-strict --no-merges -1)
+ export COMMIT_TS_EPOCH=$(date -d "$LAST_NON_MERGE_COMMIT_TS" +%s)
+ if [ $(($LAST_GENERATED_TS_EPOCH + 180)) -lt $COMMIT_TS_EPOCH ]; then
+ echo "'last_generated' timestamp in metadata.yml is older than commit timestamp ($LAST_GENERATED_TS vs $LAST_NON_MERGE_COMMIT_TS)"
+ exit 1
+ fi
+ fi
+ # check that 'is_manually_modified' is set to true if commit is not from driver generator
+ - export LAST_NON_MERGE_COMMIT_AUTHOR=$(git log --format=%an --no-merges -1)
+ - >
+ if ! [ "$LAST_NON_MERGE_COMMIT_AUTHOR" = "Driver Generator 2" ] && [ "$IS_MANUALLY_MODIFIED" = false ]; then
+ echo "Last commit is not from Driver Generator. Please update 'is_manually_modified' in metadata.yml"
+ exit 1
+ fi
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 92bb03f..028b250 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+Names of defines for I2C addresses in SensirionI2cSf06Lf.h changed
+
## [0.1.0] - 2022-03-30
Initial release
diff --git a/LICENSE b/LICENSE
index e53c5ee..f95f5fe 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
BSD 3-Clause License
-Copyright (c) 2022, Sensirion AG
+Copyright (c) 2023, Sensirion AG
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/README.md b/README.md
index f4c8a96..f2f6735 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,11 @@
-# Sensirion I2C SF06-LF Arduino Library
+# Sensirion I²C SF06-LF Arduino Library
-This document explains how to set up a sensor of the SF06-LF sensor family to run on a Arduino
+This is the Sensirion SF06-LF library for Arduino allowing you to
+communicate with a sensor of the SF06-LF family over I²C.
-
-
-Click [here](https://sensirion.com/products/product-categories/liquid-flow/
-) to learn more about the Sensirion SF06-LF sensor family.
+
+Click [here](https://sensirion.com/products/product-categories/liquid-flow/) to learn more about the Sensirion SF06-LF sensor family.
Not all sensors of this driver family support all measurements.
@@ -14,99 +13,179 @@ In case a measurement is not supported by all sensors, the products that
support it are listed in the API description.
+
## Supported sensor types
- - SLF3C-1300F
+| Sensor name | I²C Addresses |
+| ------------- | -------------- |
+|[SLF3C-1300F](https://sensirion.com/products/catalog/SLF3C-1300F/)| **0x08**|
+|[SLF3S-1300F](https://sensirion.com/products/catalog/SLF3S-1300F/)| **0x08**|
+|[SLF3S-0600F](https://sensirion.com/products/catalog/SLF3S-0600F/)| **0x08**|
+|[SLF3S-4000B](https://sensirion.com/products/catalog/SLF3S-4000B/)| **0x08**|
+|[LD20-0600L](https://sensirion.com/products/catalog/LD20-0600L/)| **0x08**|
+|[LD20-2600B](https://sensirion.com/products/catalog/LD20-2600B/)| **0x08**|
+
+The following instructions and examples use a *SLF3C-1300F*.
+
- - SLF3S-1300F
- - SLF3S-0600F
+## Installation of the library
- - SLF3S-4000B
+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
- - LD20-0600L
+`Sketch` ➔ `Include Library` ➔ `Manage Libraries...`
- - LD20-2600B
+Search for the `Sensirion I2C SF06-LF` library in the `Filter
+your search...` field and install it by clicking the `install` button.
-The following instructions and examples use a *SLF3C-1300F*.Click [here](https://sensirion.com/media/documents/F3931025/621F8CCE/Sensirion_Liquid_Flow_Meters_SLF3C-1300F_Datasheet.pdf
-) to download the datasheet.
+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...`
-## Setup Guide
+Don't forget to **install the dependencies** listed below the same way via library
+manager or `Add .ZIP Library`
-### Connecting the Sensor
+#### Dependencies
+* [Sensirion Core](https://github.com/Sensirion/arduino-core)
-Your sensor has the four different connectors: VDD, GND, SDA, SCL. Use
-the following pins to connect your SF06-LF:
+## Sensor wiring
+
+Use the following pin description to connect your SF06-LF to the standard I²C bus of your Arduino board:
| *Pin* | *Cable Color* | *Name* | *Description* | *Comments* |
|-------|---------------|:------:|----------------|------------|
-| 1 | |NC | Do not connect |
-| 2 | green |SDA | I2C: Serial data input / output |
-| 3 | red |VDD | Supply Voltage | 3.2 to 3.8V
-| 4 | black |GND | Ground |
-| 5 | yellow |SCL | I2C: Serial clock input |
-| 6 | |NC | Do not connect |
+| 1 | | NC | Do not connect |
+| 2 | green | SDA | I2C: Serial data input / output |
+| 3 | red | VDD | Supply Voltage | 3.2V to 3.8V
+| 4 | black | GND | Ground |
+| 5 | yellow | SCL | I2C: Serial clock input |
+| 6 | | NC | Do not connect |
-You can find the pinout for specific boards under following links:
-* [Arduino Uno](pinouts/arduino-uno-rev3.md)
-* [Arduino Nano](pinouts/arduino-nano.md)
-* [Arduino Micro](pinouts/arduino-micro.md)
-* [Arduino Mega 2560](pinouts/arduino-mega-2560-rev3.md)
-* [ESP32 DevKitC](pinouts/esp32-devkitc.md)
-### Installation of Arduino
+The recommended voltage is 3.3V.
-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
+### Board specific wiring
+You will find pinout schematics for recommended board models below:
- Sketch => Include Library => Manage Libraries...
-Search for the `Sensririon I2C SF06-LF` 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
+Arduino Uno
+
- Sketch => Include Library => Add .ZIP Library...
+| *SF06-LF* | *SF06-LF Pin* | *Cable Color* | *Board Pin* |
+| :---: | --- | --- | --- |
+| SDA | 2 | green | D18/SDA |
+| VDD | 3 | red | 3.3V |
+| GND | 4 | black | GND |
+| SCL | 5 | yellow | D19/SCL |
-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)
+
+
+
-## Quick Start
-1. Connect the SF06-LF 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 SF06-LF Sensor is described above.
+Arduino Nano
+
+
+| *SF06-LF* | *SF06-LF Pin* | *Cable Color* | *Board Pin* |
+| :---: | --- | --- | --- |
+| SDA | 2 | green | A4 |
+| VDD | 3 | red | 3.3V |
+| GND | 4 | black | GND |
+| SCL | 5 | yellow | A5 |
+
+
+
+
+
+
+
+
+
+Arduino Micro
+
+
+| *SF06-LF* | *SF06-LF Pin* | *Cable Color* | *Board Pin* |
+| :---: | --- | --- | --- |
+| SDA | 2 | green | D2/SDA |
+| VDD | 3 | red | 3.3V |
+| GND | 4 | black | GND |
+| SCL | 5 | yellow | ~D3/SCL |
+
+
+
+
+
+
+
+
+
+Arduino Mega 2560
+
+
+| *SF06-LF* | *SF06-LF Pin* | *Cable Color* | *Board Pin* |
+| :---: | --- | --- | --- |
+| SDA | 2 | green | D20/SDA |
+| VDD | 3 | red | 3.3V |
+| GND | 4 | black | GND |
+| SCL | 5 | yellow | D21/SCL |
+
+
+
+
+
+
+
+
+
+ESP32 DevKitC
+
+
+| *SF06-LF* | *SF06-LF Pin* | *Cable Color* | *Board Pin* |
+| :---: | --- | --- | --- |
+| SDA | 2 | green | GPIO 21 |
+| VDD | 3 | red | 3V3 |
+| GND | 4 | black | GND |
+| SCL | 5 | yellow | GPIO 22 |
+
+
+
+
+
+
+
+
+## Quick Start
- The recommended voltage is 3.3V.
+1. Install the libraries and dependencies according to [Installation of the library](#installation-of-the-library)
-2. Open the `exampleUsage` sample project within the Arduino IDE via the application menu
+2. Connect the SF06-LF sensor to your Arduino as explained in [Sensor wiring](#sensor-wiring)
- File => Examples => Sensirion I2C SF06-LF => exampleUsage
+3. Open the `exampleUsage` sample project within the Arduino IDE:
- The example is configured to run with a SLF3C-1300F, I2C address 0x08.
- In case you need a different address change it in the code of `examples/exampleUsage.ino`. You find the list with pre-defined
- addresses for the supported sensors in the `src/SensirionI2CSf06Lf.h`.
+ `File` ➔ `Examples` ➔ `Sensirion I2C SF06-LF` ➔ `exampleUsage`
+
+ The provided example is working with a SLF3C-1300F, I²C address 0x08.
+ In order to use the code with another product or I²C address you need to change it in the code of `exampleUsage`.
+ You find the list with pre-defined addresses in `src/SensirionI2CSf06Lf.h`.
-3. Click the `Upload` button in the Arduino IDE or
- Sketch => Upload
+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 measurement values. Note that
- the `Baud Rate` in the corresponding window has to be set to `115200 baud`.
+ the `Baud Rate` in the used tool has to be set to `115200 baud`.
## Contributing
diff --git a/examples/exampleUsage/exampleUsage.ino b/examples/exampleUsage/exampleUsage.ino
index ab789c8..d74dcbf 100644
--- a/examples/exampleUsage/exampleUsage.ino
+++ b/examples/exampleUsage/exampleUsage.ino
@@ -1,12 +1,12 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
- * Generator: sensirion-driver-generator 0.9.0
- * Product: sf06_lf
- * Version: 1.0
+ * Generator: sensirion-driver-generator 0.32.0
+ * Product: sf06_lf
+ * Model-Version: 1.1.0
*/
/*
- * Copyright (c) 2022, Sensirion AG
+ * Copyright (c) 2023, Sensirion AG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,7 @@
SensirionI2cSf06Lf sensor;
-static char errorMessage[128];
+static char errorMessage[64];
static int16_t error;
void print_byte_array(uint8_t* array, uint16_t len) {
@@ -59,7 +59,7 @@ void setup() {
delay(100);
}
Wire.begin();
- sensor.begin(Wire, SF06_LF_I2C_ADDRESS);
+ sensor.begin(Wire, SLF3C_1300F_I2C_ADDR_08);
sensor.stopContinuousMeasurement();
delay(100);
diff --git a/images/Arduino-Mega-2560-Rev3-i2c-pinout-3.3V.png b/images/Arduino-Mega-2560-Rev3-i2c-pinout-3.3V.png
new file mode 100644
index 0000000..942173d
Binary files /dev/null and b/images/Arduino-Mega-2560-Rev3-i2c-pinout-3.3V.png differ
diff --git a/images/Arduino-Micro-i2c-pinout-3.3V.png b/images/Arduino-Micro-i2c-pinout-3.3V.png
new file mode 100644
index 0000000..ca9ba6c
Binary files /dev/null and b/images/Arduino-Micro-i2c-pinout-3.3V.png differ
diff --git a/images/Arduino-Nano-i2c-pinout-3.3V.png b/images/Arduino-Nano-i2c-pinout-3.3V.png
new file mode 100644
index 0000000..55fd2ff
Binary files /dev/null and b/images/Arduino-Nano-i2c-pinout-3.3V.png differ
diff --git a/images/Arduino-Uno-Rev3-i2c-pinout-3.3V.png b/images/Arduino-Uno-Rev3-i2c-pinout-3.3V.png
new file mode 100644
index 0000000..a6daad7
Binary files /dev/null and b/images/Arduino-Uno-Rev3-i2c-pinout-3.3V.png differ
diff --git a/images/esp32-devkitc-i2c-pinout-3.3V.png b/images/esp32-devkitc-i2c-pinout-3.3V.png
new file mode 100644
index 0000000..319b021
Binary files /dev/null and b/images/esp32-devkitc-i2c-pinout-3.3V.png differ
diff --git a/library.properties b/library.properties
index d6750db..e97ba47 100644
--- a/library.properties
+++ b/library.properties
@@ -1,10 +1,11 @@
name=Sensirion I2C SF06-LF
-version=0.1.0
+version=1.0.0
author=Sensirion
maintainer=Sensirion
-sentence=Library for the SF06-LF sensor by Sensirion
-paragraph=Enables you to use the SF06-LF via I2C.
+sentence=Library for the SF06-LF sensor family by Sensirion
+paragraph=Enables you to use the SF06-LF sensor family via I2C.
url=https://github.com/Sensirion/arduino-i2c-sf06-lf
category=Sensors
+architectures=*
depends=Sensirion Core
includes=SensirionI2cSf06Lf.h
diff --git a/metadata.yml b/metadata.yml
new file mode 100644
index 0000000..ac3b15d
--- /dev/null
+++ b/metadata.yml
@@ -0,0 +1,7 @@
+generator_version: 0.32.0
+model_version: 1.1.0
+dg_status:
+- released
+is_manually_modified: true
+first_generated: '2022-03-30 10:56'
+last_generated: '2023-10-17 07:36'
diff --git a/src/SensirionI2cSf06Lf.cpp b/src/SensirionI2cSf06Lf.cpp
index 7547428..b926f35 100644
--- a/src/SensirionI2cSf06Lf.cpp
+++ b/src/SensirionI2cSf06Lf.cpp
@@ -1,12 +1,12 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
- * Generator: sensirion-driver-generator 0.9.0
- * Product: sf06_lf
- * Version: 1.0
+ * Generator: sensirion-driver-generator 0.32.0
+ * Product: sf06_lf
+ * Model-Version: 1.1.0
*/
/*
- * Copyright (c) 2022, Sensirion AG
+ * Copyright (c) 2023, Sensirion AG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -39,6 +39,8 @@
#include "SensirionI2cSf06Lf.h"
#include
+static uint8_t communication_buffer[18] = {0};
+
SensirionI2cSf06Lf::SensirionI2cSf06Lf() {
}
@@ -120,9 +122,9 @@ int16_t SensirionI2cSf06Lf::readProductIdentifier(uint32_t& productIdentifier,
int16_t SensirionI2cSf06Lf::startH2oContinuousMeasurement() {
int16_t localError = NO_ERROR;
- uint8_t local_buffer[2] = {0};
- SensirionI2CTxFrame txFrame = SensirionI2CTxFrame::createWithUInt16Command(
- 0x3608, local_buffer, sizeof local_buffer);
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CTxFrame txFrame =
+ SensirionI2CTxFrame::createWithUInt16Command(0x3608, buffer_ptr, 2);
localError =
SensirionI2CCommunication::sendFrame(_i2cAddress, txFrame, *_i2cBus);
if (localError != NO_ERROR) {
@@ -134,9 +136,9 @@ int16_t SensirionI2cSf06Lf::startH2oContinuousMeasurement() {
int16_t SensirionI2cSf06Lf::startIpaContinuousMeasurement() {
int16_t localError = NO_ERROR;
- uint8_t local_buffer[2] = {0};
- SensirionI2CTxFrame txFrame = SensirionI2CTxFrame::createWithUInt16Command(
- 0x3615, local_buffer, sizeof local_buffer);
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CTxFrame txFrame =
+ SensirionI2CTxFrame::createWithUInt16Command(0x3615, buffer_ptr, 2);
localError =
SensirionI2CCommunication::sendFrame(_i2cAddress, txFrame, *_i2cBus);
if (localError != NO_ERROR) {
@@ -150,8 +152,8 @@ int16_t SensirionI2cSf06Lf::readMeasurementDataRaw(int16_t& rawFlow,
int16_t& rawTemperature,
uint16_t& signalingFlags) {
int16_t localError = NO_ERROR;
- uint8_t local_buffer[9] = {0};
- SensirionI2CRxFrame rxFrame(local_buffer, sizeof local_buffer);
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CRxFrame rxFrame(buffer_ptr, 9);
localError = SensirionI2CCommunication::receiveFrame(_i2cAddress, 9,
rxFrame, *_i2cBus);
if (localError != NO_ERROR) {
@@ -165,9 +167,9 @@ int16_t SensirionI2cSf06Lf::readMeasurementDataRaw(int16_t& rawFlow,
int16_t SensirionI2cSf06Lf::stopContinuousMeasurement() {
int16_t localError = NO_ERROR;
- uint8_t local_buffer[2] = {0};
- SensirionI2CTxFrame txFrame = SensirionI2CTxFrame::createWithUInt16Command(
- 0x3ff9, local_buffer, sizeof local_buffer);
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CTxFrame txFrame =
+ SensirionI2CTxFrame::createWithUInt16Command(0x3ff9, buffer_ptr, 2);
localError =
SensirionI2CCommunication::sendFrame(_i2cAddress, txFrame, *_i2cBus);
if (localError != NO_ERROR) {
@@ -179,9 +181,9 @@ int16_t SensirionI2cSf06Lf::stopContinuousMeasurement() {
int16_t SensirionI2cSf06Lf::startSingleThermalConductivityMeasurementSync() {
int16_t localError = NO_ERROR;
- uint8_t local_buffer[2] = {0};
- SensirionI2CTxFrame txFrame = SensirionI2CTxFrame::createWithUInt16Command(
- 0x3646, local_buffer, sizeof local_buffer);
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CTxFrame txFrame =
+ SensirionI2CTxFrame::createWithUInt16Command(0x3646, buffer_ptr, 2);
localError =
SensirionI2CCommunication::sendFrame(_i2cAddress, txFrame, *_i2cBus);
if (localError != NO_ERROR) {
@@ -193,9 +195,9 @@ int16_t SensirionI2cSf06Lf::startSingleThermalConductivityMeasurementSync() {
int16_t SensirionI2cSf06Lf::startSingleThermalConductivityMeasurementAsync() {
int16_t localError = NO_ERROR;
- uint8_t local_buffer[2] = {0};
- SensirionI2CTxFrame txFrame = SensirionI2CTxFrame::createWithUInt16Command(
- 0x3646, local_buffer, sizeof local_buffer);
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CTxFrame txFrame =
+ SensirionI2CTxFrame::createWithUInt16Command(0x3646, buffer_ptr, 2);
localError =
SensirionI2CCommunication::sendFrame(_i2cAddress, txFrame, *_i2cBus);
if (localError != NO_ERROR) {
@@ -208,8 +210,8 @@ int16_t SensirionI2cSf06Lf::llreadThermalConductivityMeasurementData(
int16_t& thermalConductivity, int16_t& rawTemperature,
int16_t& rawDeltaTemperature) {
int16_t localError = NO_ERROR;
- uint8_t local_buffer[9] = {0};
- SensirionI2CRxFrame rxFrame(local_buffer, sizeof local_buffer);
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CRxFrame rxFrame(buffer_ptr, 9);
localError = SensirionI2CCommunication::receiveFrame(_i2cAddress, 9,
rxFrame, *_i2cBus);
if (localError != NO_ERROR) {
@@ -223,9 +225,9 @@ int16_t SensirionI2cSf06Lf::llreadThermalConductivityMeasurementData(
int16_t SensirionI2cSf06Lf::enterSleep() {
int16_t localError = NO_ERROR;
- uint8_t local_buffer[2] = {0};
- SensirionI2CTxFrame txFrame = SensirionI2CTxFrame::createWithUInt16Command(
- 0x3677, local_buffer, sizeof local_buffer);
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CTxFrame txFrame =
+ SensirionI2CTxFrame::createWithUInt16Command(0x3677, buffer_ptr, 2);
localError =
SensirionI2CCommunication::sendFrame(_i2cAddress, txFrame, *_i2cBus);
if (localError != NO_ERROR) {
@@ -235,19 +237,20 @@ int16_t SensirionI2cSf06Lf::enterSleep() {
}
int16_t SensirionI2cSf06Lf::exitSleep() {
- uint8_t local_buffer[2] = {0};
- SensirionI2CTxFrame txFrame = SensirionI2CTxFrame::createWithUInt16Command(
- 0x0, local_buffer, sizeof local_buffer);
+ int16_t localError = NO_ERROR;
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CTxFrame txFrame =
+ SensirionI2CTxFrame::createWithUInt8Command(0x0, buffer_ptr, 2);
SensirionI2CCommunication::sendFrame(_i2cAddress, txFrame, *_i2cBus);
delay(25);
- return NO_ERROR;
+ return localError;
}
int16_t SensirionI2cSf06Lf::readProductIdentifierPrepare() {
int16_t localError = NO_ERROR;
- uint8_t local_buffer[2] = {0};
- SensirionI2CTxFrame txFrame = SensirionI2CTxFrame::createWithUInt16Command(
- 0x367c, local_buffer, sizeof local_buffer);
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CTxFrame txFrame =
+ SensirionI2CTxFrame::createWithUInt16Command(0x367c, buffer_ptr, 2);
localError =
SensirionI2CCommunication::sendFrame(_i2cAddress, txFrame, *_i2cBus);
if (localError != NO_ERROR) {
@@ -260,22 +263,22 @@ int16_t SensirionI2cSf06Lf::llreadProductIdentifier(uint32_t& productIdentifier,
uint8_t serialNumber[],
uint16_t serialNumberSize) {
int16_t localError = NO_ERROR;
- uint8_t local_buffer[18] = {0};
- SensirionI2CTxFrame txFrame = SensirionI2CTxFrame::createWithUInt16Command(
- 0xe102, local_buffer, sizeof local_buffer);
+ uint8_t* buffer_ptr = communication_buffer;
+ SensirionI2CTxFrame txFrame =
+ SensirionI2CTxFrame::createWithUInt16Command(0xe102, buffer_ptr, 18);
localError =
SensirionI2CCommunication::sendFrame(_i2cAddress, txFrame, *_i2cBus);
if (localError != NO_ERROR) {
return localError;
}
- SensirionI2CRxFrame rxFrame(local_buffer, sizeof local_buffer);
+ SensirionI2CRxFrame rxFrame(buffer_ptr, 18);
localError = SensirionI2CCommunication::receiveFrame(_i2cAddress, 18,
rxFrame, *_i2cBus);
if (localError != NO_ERROR) {
return localError;
}
localError |= rxFrame.getUInt32(productIdentifier);
- localError |= rxFrame.getBytes(serialNumber, serialNumberSize);
+ localError |= rxFrame.getBytes((uint8_t*)serialNumber, serialNumberSize);
return localError;
}
diff --git a/src/SensirionI2cSf06Lf.h b/src/SensirionI2cSf06Lf.h
index 63bb82b..f56d8f0 100644
--- a/src/SensirionI2cSf06Lf.h
+++ b/src/SensirionI2cSf06Lf.h
@@ -1,12 +1,12 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
- * Generator: sensirion-driver-generator 0.9.0
- * Product: sf06_lf
- * Version: 1.0
+ * Generator: sensirion-driver-generator 0.32.0
+ * Product: sf06_lf
+ * Model-Version: 1.1.0
*/
/*
- * Copyright (c) 2022, Sensirion AG
+ * Copyright (c) 2023, Sensirion AG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,25 +43,12 @@
#include
#define NO_ERROR 0
-
-// supported i2c addresses of SLF3C-1300F
-#define SLF3C_1300F_ADDR_A 0x08
-
-// supported i2c addresses of SLF3S-1300F
-#define SLF3S_1300F_ADDR_A 0x08
-
-// supported i2c addresses of SLF3S-0600F
-#define SLF3S_0600F_ADDR_A 0x08
-
-// supported i2c addresses of SLF3S-4000B
-#define SLF3S_4000B_ADDR_A 0x08
-
-// supported i2c addresses of LD20-0600L
-#define LD20_0600L_ADDR_A 0x08
-
-// supported i2c addresses of LD20-2600B
-#define LD20_2600B_ADDR_A 0x08
-#define SF06_LF_I2C_ADDRESS 0x08
+#define SLF3C_1300F_I2C_ADDR_08 0x08
+#define SLF3S_1300F_I2C_ADDR_08 0x08
+#define SLF3S_0600F_I2C_ADDR_08 0x08
+#define SLF3S_4000B_I2C_ADDR_08 0x08
+#define LD20_0600L_I2C_ADDR_08 0x08
+#define LD20_2600B_I2C_ADDR_08 0x08
typedef enum {
START_H2O_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3608,
@@ -147,7 +134,7 @@ class SensirionI2cSf06Lf {
* @param[out] productIdentifier Note that the last 8 bits are the sensor’s
* revision number and are subject to change in case of an update of the
* specifications.
- * @param[out] serialNumber 64-bit unique serial number
+ * @param[out] serialNumber serial number
*
* @return error_code 0 on success, an error code otherwise.
*/
@@ -212,10 +199,9 @@ class SensirionI2cSf06Lf {
* information. Following flags are defined: Air-in-Line flag (Bit 0), High
* Flow flag (Bit 1), Exponential smoothing active (Bit 5)
*
- * @note The first measurement result will be available after 12ms after
- * starting the measurement. Small accuracy deviations (% m.v.) can occur
- * during the first 60ms for SLF3x, 120ms for LD2x (including the 12ms
- * initialization)
+ * @note The first measurement result will be available 12ms after starting
+ * the measurement. Small accuracy deviations (% m.v.) can occur during the
+ * first 60ms for SLF3x, 120ms for LD2x (including the 12ms initialization)
*
* @return error_code 0 on success, an error code otherwise.
*/
@@ -276,12 +262,12 @@ class SensirionI2cSf06Lf {
* *start_single_thermal_conductivity_measurement_async*. Supported by
* products: SLF3C-1300F, SLF3S-4000B
*
- * @param[out] thermalConductivity Thermal conductivity signal read from the
- * sensor in arbitary units.
- * @param[out] rawTemperature Calibrated raw temperature signal read from
- * the sensor.
- * @param[out] rawDeltaTemperature Calibrated raw delta temperature signal
- * read from the sensor.
+ * @param[out] thermalConductivity thermal conductivity
+ * @param[out] rawTemperature Convert to degrees celsius by temperature =
+ * raw_temperature / 200
+ * @param[out] rawDeltaTemperature The delta-temperature is a measure for
+ * the temperature difference between the liquid and the sensor. Convert to
+ * degrees celsius by delta_temperature = raw_delta_temperature / 1000
*
* @return error_code 0 on success, an error code otherwise.
*/
@@ -340,7 +326,7 @@ class SensirionI2cSf06Lf {
* @param[out] productIdentifier Note that the last 8 bits are the sensor’s
* revision number and are subject to change in case of an update of the
* specifications.
- * @param[out] serialNumber 64-bit unique serial number
+ * @param[out] serialNumber serial number
*
* @return error_code 0 on success, an error code otherwise.
*/