Tutorial: Arduino Interface for SF06 Liquid Flow Sensors with Level Shifter
This quick start guide is aimed at customers who have worked with our Liquid Flow Meter Kits and are evaluating Sensirion liquid flow sensors in a prototyping scenario. This guide describes how to set up and connect a SF06 liquid flow sensor with level shifters to an Arduino UNO and how to run a first simple measurement using sample code.
What you need
- SF06 based liquid flow sensor, for example, the SLF3S-1300F or the LD20-2600B
- 6 pin Molex Micro Blade cable
- Arduino UNO (Tested to work)
- 4-channel I2C-safe Bi-directional Logic Level Converter - BSS138
- Jumper wires
- Screw headers (277-1275-ND, from www.digikey.com) to connect the sensor to your
- Arduino board
- Sensirion Arduino Code examples
What you have to do
Setting up your Arduino (UNO)
Please note that these steps are simply a suggestion. Sensirion AG is not responsible for any technical issues arising from the Arduino board, setting it up and all electrical connections.
- Download the Arduino Software here: https://www.arduino.cc/en/Main/Software
- Follow Arduino’s Getting Started Guide (https://www.arduino.cc/en/Guide/HomePage)
- For Arduino UNO: We have successfully tested our sample code with the Arduino UNO board and therefore recommend using it (Arduino UNO Getting Started Guide (https://www.arduino.cc/en/Guide/ArduinoUno)).
If you have successfully connected and tested your Arduino board, you are ready to continue to the next part.
Connecting your sensor
Wiring diagram with two SLF3x sensors
Connect your liquid flow sensor to the Arduino board as described in figure above. Using screw headers may help make reliable and easy to use connections (for example: 277-1275-ND from www.digikey.com) In case you want to design and use your own cable, please follow the pin descriptions shown below precisely. Using the wrong voltage or applying voltages to the wrong pins can damage the sensor. Sensirion AG is not responsible for any damages incurred this way.
|Pin Label||6 pin Molex Pin-no. |
|SCL||5||A5 or SCL|
|SDA||2||A4 or SDA|
Running your first measurement
Once you have successfully tested your Arduino and have connected your sensor correctly, you can start your first measurement. Double-click ‘example_15_simple_measurement_SLF3x.ino’ of Sensirion AG’s sample Arduino code. This will launch the Arduino software suite and open the sample code. Simply upload the code to your Arduino board and wait for the process to finish. The measurement will begin automatically. In order to see the results, start the serial monitor from within the Arduino software suite (see arrow in the figure below).
After opening the serial monitor, a window will open that displays the unsigned integer sensor reading, as well as the flow rate in physical units with the two’s complement and scaling factor applied. The same is displayed for the temperature reading.
All code examples are commented for ease of understanding. Feel free to use and edit the code as you please. Remember to save a new copy before you start editing, to avoid overwriting the original sample code.