Skip to content

Commit

Permalink
Merge branch 'sf06_lf_1.1.0_20231017_0736' into 'master'
Browse files Browse the repository at this point in the history
Update SF06_LF driver from Eris-liquidflow model version 1.1.0

See merge request MSO-SW/drivers/arduino/arduino-i2c-sf06-lf!4
  • Loading branch information
LeonieFierz committed Oct 19, 2023
2 parents 430d8dc + 89077f2 commit d025993
Show file tree
Hide file tree
Showing 14 changed files with 284 additions and 147 deletions.
73 changes: 66 additions & 7 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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) 2022, Sensirion AG
Copyright (c) 2023, Sensirion AG
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
193 changes: 136 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,191 @@
# 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.

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

Click [here](https://sensirion.com/products/product-categories/liquid-flow/
) to learn more about the Sensirion SF06-LF sensor family.
<img src="images/sensor_SLF3C_1300F.png" width="300px">

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.
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:

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

| *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
<details><summary>Arduino Uno</summary>
<p>

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)
<img src="images/Arduino-Uno-Rev3-i2c-pinout-3.3V.png" width="600px">
</p>
</details>


## 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.
<details><summary>Arduino Nano</summary>
<p>

| *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 |



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



<details><summary>Arduino Micro</summary>
<p>

| *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 |



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



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

| *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 |



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



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

| *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 |



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


## 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

Expand Down
12 changes: 6 additions & 6 deletions examples/exampleUsage/exampleUsage.ino
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Arduino-Micro-i2c-pinout-3.3V.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Arduino-Nano-i2c-pinout-3.3V.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Arduino-Uno-Rev3-i2c-pinout-3.3V.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/esp32-devkitc-i2c-pinout-3.3V.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d025993

Please sign in to comment.