Unofficial Arduino driver support for Sensirion flow sensor products. At this point, only sensors using an I2C interface are supported.
Download arduino-sflow either via git or from the releases page and place it in the Arduino/libraries directory. After restarting the Arduino IDE, you will get menu items under libraries and examples.
Assuming you installed the library as described above, the following steps are necessary:
- Import the Wire library like this: From the menu bar, select Sketch > Import Library > Wire
- Import the arduino-sflow library like this: From the menu bar, select Sketch > Import Library > arduino-sflow
- Create an instance of the
SensirionFlow
class, with the I2C address of the sensor as parameter (check datasheet) - In
setup()
, make sure to init the Wire library withWire.init()
- If you want to use the serial console, remember to initialize the Serial library with
Serial.begin(9600)
- Finally, call
flow.readSample()
in theloop()
function, which returns a float value of the current flow
#include <Wire.h>
#include <sensirionflow.h>
SensirionFlow flow(64);
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(9600);
flow.init();
}
void loop() {
float result = flow.readSample();
Serial.print("Flow: ");
Serial.print(result, 2);
Serial.print("\n");
delay(1000);
}