Skip to content

HardFOC driver

SFM Flow Meter Driver

A header-only C++17 driver for Sensirion SF06-family gas mass flow meters such as the SFM4300. It identifies the part, starts a measurement for the right gas or O2 mixture and reads flow, temperature and status with every word CRC-checked, on any MCU with I2C.

Quickstart API guide Source on GitHub

The driver has no platform code. You give it a small class that writes and reads raw bytes on I2C and waits; it does the rest: command framing, CRC-8 checks, gas-table selection per part family, scaling to standard litres per minute and status decoding.

Thermal mass flow meter for gas mixing SFM4300 Sensirion (SF06 family)
Measures
Gas mass flow, 0 to 20 slm (SFM4300-20) or 0 to 50 slm (SFM4300-50), and sensor temperature
Gases
O2, air, N2O, CO2 and three O2 mixtures (-20); O2, air and air/O2 (-50)
Interface
I2C, 400 kHz typical, up to 1 MHz; address 0x2A to 0x2D (ADDR resistor); IRQn data-ready, active low
Supply
3.0 V to 5.5 V, calibrated at 3.3 V; 4.2 mA measuring, 0.4 µA asleep (typical)
Speed
New flow value about every 0.5 ms (2 kHz); step response τ63 under 5 ms
Driver covers
SFM4300, SFM3003, SFM3013, SFM3019, SFM3119 (SF06 command set) and SFM6000D (SFx6000)

Datasheet · Sensirion reference driver

What you get

  • One object per sensor. sfm::Driver<YourI2c> covers every command of the SF06 set: start and stop, read, averaging, concentration update, scaling, sleep, product identifier and soft reset. See the API guide.
  • The right gas table, or an error. The driver reads the product identifier, knows which gases the variant is calibrated for and refuses the others with UnsupportedGas. See Gases and part families.
  • Readings in slm. Scale factor, offset and unit come from the sensor for the selected gas, so the conversion is right for every variant. See I2C protocol.
  • Every word checked. Each received 16-bit word carries a CRC-8 that the driver verifies; a NACK for "no new sample yet" is reported as NoData, not as a fault. See Measurement and averaging.
  • Zero-overhead portability. The port is a CRTP class with four methods: no virtual calls, no heap, no RTOS dependency. See Porting.
  • Tested without hardware. Host unit tests replay datasheet frames through a fake I2C bus. See Testing and CI.

Where to go next

  • Quickstart


    Wire the sensor, write the port, read a flow in about 15 lines.

  • Hardware


    Connector, addresses, bus settings, timing, power and fluidics.

  • Architecture


    The three layers and what each one owns.

  • API guide


    Identify, start, read, average and handle errors, task by task.

  • Porting


    Implement the I2C interface for your MCU.

  • API reference


    Every class and member, generated from the headers.