Sensirion Mass Flow Sensor Arduino library, modified from MyElectrons and Nabilphysics Arduino repositories for SFM3300 Digital Mass Flow Sensor

Sensirion Flow Meter (SFM3300)

Description

The SFM3300 Sensirion flow meter is a sensor for proximal flow measurement in respiratory applications such as ventilation or anesthesia. There are two versions available: the SFM3300-AW is Autoclavable and Washable and the SFM3300-D is Disposal.

space-1.jpg
Fig. 1 Sensirion Proximal Flow Sensors SFM3300-AW & SFM3300-D

The SFM3300 features outstanding measuring accuracy and robustness as well as a short signal processing time. The digital flow sensor measures bidirectional flow volumes of up to 250 slm and is fully calibrated for air, N2 and O2 gases. The special design of the flow channel results in a low dead space volume and the slightly greater pressure drop ensures more stability compared to variable inlet conditions. The sensor also features medical cones for pneumatic connection to the respiratory cycle and has a mechanical interface for a user-friendly electrical connection. Thanks to its performance characteristics, the SFM3300 mass flow meter is ideally suited for single-use proximal flow measurements in medical ventilation, hospital applications, residential care applications and emergency situations.

Features

  • Autoclavable / washable (SFM3300-AW) or single-use (SFM3300-D)
  • Flow rates: ±250 slm (bidirectional)
  • Fully calibrated
  • Very fast update time (0.5 ms)
  • Small dead space: < 10 ml
  • Best-in-class accuracy
  • Robust
  • Low dependency on different inlet conditions
  • Medical cones for pneumatic connection to standard breathing circuits
  • Mechanical interface for electrical reconnection

Applications

  • Proximal flow measurement
  • Expiratory measurement
  • Ventilation
  • Anesthesia
  • Respiratory measurements
  • Metabolic measurements

Arduino Interfacing

This secton describes the I2C communication with the SFM3X00 sensor series. Communication between the master and the SFM3X00 series sensor runs via the digital I2C-interface.

space-1.jpg
Fig. 2 Sensirion Flow Sensor Arduino Interfacing

I2C Connection

Bi-directional bus lines are implemented by the devices (master and slave) using open-drain output stages and a pull-up resistor (R) connected to the positive supply voltage (5V +- 5%). The recommended pull-up resistor value is 10kOhm. In case of long wires (>10cm) it is necessary to shield SDA and SCL. Wires longer than 30cm should not be used.

I2C Address

By default, the I2C address is set to 64 (0x40).

Command Set and Data Transfer Sequences

After a data transfer is initiated by a header byte with a Write, a command is send to the slave. A command is represented by a 16-bit command code, consisting of two 8-bit frames. The commands are described below, and the data transfer sequences are specified.

Command Description
0x1000 Start continuous measurement
0x2000 Soft reset command

Flow measurements are started by writing the start measurement command (0x1000) to the sensor. Measurement results are continuously updated until measurement is stopped by sending any other command. After a start measurement command, the measurement results can be read out continuously. This means that an I2C header with R/W bit = 1 can be sent continuously to read out those results, without preceding it with command 0x1000.

The soft reset command (0x2000) forces a sensor reset without switching the power off and on again. On receipt of this command, the sensor reinitializes the control/status register contents from the non-volatile memory and starts operating according to these settings.

Note that if the supply drops below 4.75V and back, the sensor will perform a Power on Reset and will stop measuring. If the master keeps on sending read headers without resending the start measurement command, those read requests will not be acknowledged. If the sensor does not acknowledge the start measurement command, a hard reset (reset the sensor through powering off and on the sensor, in case the sensor freezes) is required.

CRC-8 Redundant Data Transmission

Cyclic redundancy checking (CRC) is a popular technique used for error detection in data transmission. The transmitter appends an n-bit checksum to the actual data sequence. The checksum holds redundant information about the data sequence and allows the receiver to detect transmission errors. The computed checksum can be regarded as the remainder of a polynomial division, where the dividend is the binary polynomial defined by the data sequence and the divisor is a “generator polynomial”.

The SFM3000 sensor implements the CRC-8 standard based on the generator polynomial: x8 + x5 + x4 +1. (0x31)

For easy implementation to a microcontroller, the following simple C++ routine can be used. Note that this code is not optimized for speed.

// CRC
#define POLYNOMIAL 0x131 //P(x)=x^8+x^5+x^4+1 = 100110001
//============================================================
u8t SMF3000_CheckCrc (u8t data[], u8t nbrOfBytes, u8t checksum)
//============================================================
// calculates checksum for n bytes of data
// and compares it with expected checksum
// input: data[] checksum is built based on this data
// nbrOfBytes checksum is built for n bytes of data
// checksum expected checksum
// return: error: CHECKSUM_ERROR = checksum does not match
// 0 = checksum matches
//============================================================
{
u8t crc = 0;
u8t byteCtr;
// calculates 8-Bit checksum with given polynomial
for (byteCtr = 0; byteCtr < nbrOfBytes; ++byteCtr)
{ 
crc ^= (data[byteCtr]);
  for (u8t bit = 8; bit > 0; --bit)
  { 
  if (crc & 0x80) crc = (crc << 1) ^ POLYNOMIAL;
  else crc = (crc << 1);
    }
  }
if (crc != checksum) return CHECKSUM_ERROR;
else return 0;
}

With the type definitions:

typedef enum{
CHECKSUM_ERROR = 0x04
} etError;
typedef unsigned char u8t;

Converting measurement result to measured values

In order to obtain the measured flow in the predefined unit, the flow measurement result needs to be converted according to the following formula:

space-1.jpg
Eqn. 1 Flow measurement express in SLM

Offset and scale factor can be found in the product datasheet. Please note that the first measurement performed directly after chip initialization might not be valid.

Sample Result

space-1.jpg
Fig. 3 Waveform graph using serial plotter
Similar Resources

The core engine forked from NVidia's Q2RTX. Heavily modified and extended to allow for a nicer experience all-round.

Polyhedron - A Q2RTX Fork A fork of the famous Q2RTX project by NVIDIA™ that strives to improve all of its other factors of what was once upon a time

Dec 22, 2022

Bungie's Oni modified so it compiles with Microsoft Visual Studio 2019.

OniFoxed What's this? This is a modified variant of the recently leaked Oni source code so that it compiles under Microsoft Visual Studio 2019 with so

Dec 2, 2022

I modified the colmap,when it reconstructs from known pose ,only let it optimize rotation ,fixing position!

Mapping-base-lidar-pose-or-vslam-pose I simply modified the colmap,when it reconstructs from known pose ,only let it optimize rotation ,fixing positio

Dec 16, 2022

T-HYDRA is a modified version of original thc-hydra for better use inside Termux .

 T-HYDRA is a modified version of original thc-hydra for better use inside Termux .

T-HYDRA is a modified version of original thc-hydra for better use inside Termux . Earlier , hydra pakage had been with Termux repositories. Then afte

Jan 7, 2023

Modified version of srlua for MSVC using version 5.4 of Lua

Modified version of srlua for MSVC using version 5.4 of Lua. Quote from the original README: This is a self-running Lua interpreter. It is meant to be

Jan 4, 2023

CAFLOOD 2D surface flow (flood) simulator with two-way coupling to other simulators

CAFLOOD FLUIDIT This is an improved version of the latest published open source version of University of Exeter's CAFLOOD cellular automata based 2D f

Dec 23, 2021

Incompressible Schrödinger FLow in real-time in TouchDesigner

Open a .toe file from the ISF/TouchDesignerProjects folder on a windows machine with CUDA enabled GPU.

Nov 12, 2022

Digital control and signal processing library for DSPs developed in C

digital-control Overview Thisis a simple C library containing very useful digital control and signal processing functionalities destinated for DSP's a

Oct 25, 2022

Digital Signal Processing Library and Audio Toolbox for the Modern Synthesist.

Digital Signal Processing Library and Audio Toolbox for the Modern Synthesist.

Digital Signal Processing Library and Audio Toolbox for the Modern Synthesist. Attention This library is still under development! Read the docs and ch

Nov 25, 2022
Comments
  • Necessity of resetting the MCU?

    Necessity of resetting the MCU?

    Firstly, thanks for writing this library!

    One thing I noticed, due to what may be a flaw in my circuit, is that the library resets the microcontroller unit when the sensor reading fails:

    https://github.com/TronixLab/SFM3300/blob/main/SFM3300.cpp#L90-L96

    Maybe consider removing this? It threw me for a loop (figuratively and literally!) until I read through the code. I'm not sure if it's a typical use case, but I think the reset makes it impossible to hot-swap flow sensors without resetting runtime state.

Node.js module for Sensirion SHT7X with IOW158A-S

iow_sht7x - Node.js module for Sensirion SHT7X with IOW158A-S This Node module is intended for use with a Sensiron SHT7x sensor IC that is coupled wit

Jan 27, 2022
This is an Arduino library for Aosong ASAIR AHT1x, AHT2x Digital Humidity & Temperature Sensor

Aosong ASAIR AHT1x/AHT2x This is an Arduino library for Aosong ASAIR AHT10/AHT15/AHT20/AHT21/AHT25/AM2301B/AM2311B Digital Humidity & Temperature Sens

Dec 21, 2022
WIP: ESP32 powered robot dog, quadruped robot. This is just code, hardware in the other repositories
WIP: ESP32 powered robot dog, quadruped robot. This is just code, hardware in the other repositories

Small Robot dog (quadruped) Hardware ESP32 IMU (not implemented) 12 servos TowerPro mg90d (hope it will work) Two 18650 Software Arduino IDE compatibl

Dec 22, 2022
DIY Zigbee CC2530 Motion sensor (AM312/ AM412/ BS312/ BS412), Temperature /Humidity /Pressure sensor (BME280), Ambient Light sensor (BH1750), 2.9inch e-Paper Module
DIY Zigbee CC2530 Motion sensor (AM312/ AM412/ BS312/ BS412), Temperature /Humidity /Pressure sensor (BME280), Ambient Light sensor (BH1750), 2.9inch e-Paper Module

How to join: If device in FN(factory new) state: Press and hold button (1) for 2-3 seconds, until device start flashing led Wait, in case of successfu

Feb 13, 2022
DIY Zigbee CC2530 Motion sensor (AM312/ AM412/ BS312/ BS412), Temperature /Humidity /Pressure sensor (BME280), Ambient Light sensor (BH1750), 2.9/2.13/1.54 inch e-Paper Module
DIY Zigbee CC2530 Motion sensor (AM312/ AM412/ BS312/ BS412), Temperature /Humidity /Pressure sensor (BME280), Ambient Light sensor (BH1750), 2.9/2.13/1.54 inch e-Paper Module

How to join: If device in FN(factory new) state: Press and hold button (1) for 2-3 seconds, until device start flashing led Wait, in case of successfu

Dec 9, 2022
Voltage Controlled Digital Core Multimode Oscillator using Mozzi library on Arduino

Arduino-VDCO Voltage Controlled Digital Core Multimode Oscillator using Mozzi library on Arduino Its a digital Oscillator/Voice for the Eurorack Stand

Dec 12, 2022
This is a library that can fix the crash on android 5.0 and 5.1 caused by modified utf8 converting.

FixModifiedUtf8ConvertError This is a library that can fix the crash on android 5.0 and 5.1 caused by modified utf8 converting. What's this On Android

Nov 23, 2021
Creating sepia, reflection, grayscale, and blur filters from scratch and returns a modified image

image-filter Created sepia, reflection, grayscale, and blur filters from scratch and returning a modified image Directories: images: contains sample i

Oct 14, 2021
My old heavily modified version of bigbase v1, it has an impulse-like scrollbar, ytd header loader, Vector3 fix + gamestate fix and some other misc changes!
My old heavily modified version of bigbase v1, it has an impulse-like scrollbar, ytd header loader, Vector3 fix + gamestate fix and some other misc changes!

Old Bigbase V1 UI This is my old ui for bigbase v1 but i dont need it anymore because the dev of solar mod menu stole it, and the new paragon menu (Fr

Sep 13, 2022
Open Source Cheat for Apex Legends, designed for ease of use. Made to understand reversing of Apex Legends and respawn's modified source engine as well as their Easy Anti Cheat Implementation.
Open Source Cheat for Apex Legends, designed for ease of use. Made to understand reversing of Apex Legends and respawn's modified source engine as well as their Easy Anti Cheat Implementation.

Apex-Legends-SDK Open Source Cheat for Apex Legends, designed for ease of use. Made to understand reversing of Apex Legends and respawn's modified sou

Jan 8, 2023