The communication with the SFM3000 Mass Flow Meters is discussed in this article. The digital I2C-interface is used for the communication between the SFM3000 sensor system and a master. This article covers some of the basic descriptions and all of the essential commands of the SFM3000 I2C protocol.
Interface connection
Master and slave devices implement bi-directional bus lines utilizing open-drain output stages and a pull-up resistor (Rp) coupled to the positive supply voltage. The recommended pull-up resistor value is selected based on the system configuration, especially on the capacitance of the circuit or cable and bus clock frequency.
The recommended value for quick prototyping is l0kOhm. The optimal value can be determined using NXP's I2C bus specification. The capacitive loads on SDA and SCL lines must be the same. Asymmetric capacitive loads must be avoided, and SDA and SCL lines must be shielded in case of long wires (>10cm). It is important to avoid the use of wires longer than 30cm.
Figure 1 shows the interface connection.
.jpg)
Figure 1. Interface connection
I2C Address
The I2C address is characterized by a 7-digit binary value and its default value is 64 (1000000b). It is followed by a read bit (1) or a write bit (0). Hence, the default hexadecimal I2C header is 0x81 for read access to the sensor.
I2C communication
The I2C protocol comprises of start and stop conditions at the start and conclusion of the transfers and a number of 8 bit frames in between, of which each frame is acknowledged when a transmission is successful.
Transmission START Condition (S)
The START condition (Figure 2) on the bus generated by the master indicates the beginning of a transmission sequence to the slaves. The bus is assumed busy after a START.
.jpg)
Figure 2. Transmission START Condition (S)
Transmission STOP Condition (P)
The STOP condition (Figure 3) on the bus generated by the master indicates the end of a transmission sequence to the slaves. The bus is assumed free after a STOP.
.jpg)
Figure 3. Transmission STOP Condition (P)
Acknowledge (ACK) / Not Acknowledge (NACK)
An acknowledge condition from the receiver follows each byte transmission over the I2C bus, meaning that once the SCL is pulled low by the master to finish the transmission of the 8th bit, the receiver will pull SDA low during the 9th bit time. If this does not happen, the condition is known as a NACK condition (Figure 4).
.jpg)
Figure 4. ACK and NACK conditions
Data transfer format
Data is transmitted in byte packets in the I2C protocol, wherein an acknowledge bit follows each byte. Data is transmitted with the most significant bit first. A data transfer sequence is triggered by the master creating the Start condition (S) and transmitting a header byte. The I2C header comprises the data direction bit (R/_W) and the 7-bit I2C device address.
The data direction for the remaining data transfer sequence is determined by the value of the R/_W bit in the header. The direction remains master-to-slave when R/_W = 0 (WRITE). There is a change in the direction to slave-to-master subsequent to the header byte when R/_W = 1 (READ).
Command Set and Data Transfer Sequences
Once a data transmission is triggered by a header byte with a Write, the slave receives a command characterized by a 16-bit command code comprising of two 8-bit frames. There may not be any change in the data direction after the command bytes as the direction may have already been determined to be master-to-slave by the R/_W bit of the preceding I2C header. After receiving the command code, the command is stored internally by the sensor. An I2C data transfer sequence with R/_W = 1 is initiated to invoke the Read part of this command.
If a correctly addressed sensor acknowledges a valid command and gains access to this command, it will respond by pulling the SDA line low during the succeeding SCL pulse for the acknowledge signal (ACK). Otherwise, the SDA line is left unasserted (NACK condition). After the acknowledgement of the second byte read back from the sensor, another byte consisting of CRC data will be transmitted by the sensor.
Measurement Triggering
Flow measurements are initiated when the sensor receives the start measurement command (0x1000). The continuous update of the measurement results takes place until the measurement is stopped by the receipt of any command outside the 0x1000 to 0x1FFF range.
If a different command is received in between, then the command 0x1000 needs to be resent prior to reading the out flow measurement results. If this other command was in the range of 0x1000 to 0x1 FFFF, the sensor is still making measurements. Hence, 0x1000 is the only command that can move the internal pointer back to the measurement result register.
If this other command is not within the range of 0x1000 to 0x1FFFF, then the measurement will be restarted by the 0x1000 command. The following table illustrates a sequence with explanations for every command.
Ģ time (ms) |
I2C communication |
Measuring? |
Comment |
0 |
- |
No |
Powering up of the sensor. |
100 |
80a 10a 00a |
→Yes |
After the sensor is out of reset, the start measurement command is sent. |
0.5 |
81n FFa FFa FFa |
Yes |
First measurement result read out after chip reset is always invalid. |
0.5 |
81a F0a 00a CRCa |
Yes |
Valid measurement data is read out + CRC byte. |
0.5 |
81a F0a 14n |
Yes |
Updated flow value is read out. CRC is chosen not to read out. |
0.4 |
81n |
Yes |
No valid measurement data is ready yet. The read request is not acknowledged. |
0.1 |
81a F0a 29a CRCa |
Yes |
New measurement data is available and read out. |
1 |
80a 77a 00a |
→No |
Read ID command is send. |
0.1 |
81a D5a 3Fa CRCa |
No |
The ID command is read (example data). |
0.1 |
80a 10a 00a |
→Yes |
Start measurement command is sent. |
0.5 |
81a F0a 00a CRCa |
Yes |
Valid measurement data is read out + CRC byte. |
Dark areas with white text indicate that the sensor controls the SDA (Data) line.
An a indicates and ACK, an n indicates a NACK.
Read Data Layout
Data provided by the sensor comprises two bytes, with the most significant byte and bit read first and the least significant bit and byte are read last. The following table provides more details on the content of the different results:
Read Flow Measurement Result |
Bit |
#Bits |
Description/Coding |
Boot State default |
15:0 |
16 |
Flow path measurement. Bit <1:0> is always zero. |
0 |
Read Status |
Bit |
#Bits |
Description/Coding |
Boot State default |
15:14 |
2 |
Unused |
0 |
13:0 |
14 |
measurement error occurred
00 0000 0000 0000: no error occurred
else: error occurred |
0 |
Read ID * |
Bit |
#Bits |
Description/Coding |
Boot State default |
15:12 |
4 |
unused |
0 |
11:0 |
12 |
revision ID |
revision ID |
* Please note that the revision ID value will change in case of future chip revisions.
Conversion of Measurement Results into Measured Values
The following formula is used to convert the measurement results into measured values:
.jpg)
The datasheet contains the offset and scale factor values. The first measurement is taken immediately after the chip initialization is not valid.
CRC-8 Redundant Data Transmission
Cyclic redundancy checking (CRC) technique is used to detect errors in data transmission. An n-bit checksum containing redundant information about the data sequence is added to the actual data sequence by the transmitter. The checksum enables the receiver to determine transmission errors. The CRC-8 standard based on the generator polynomial: x8 + x5 + x4 +1. (0x31) is implemented by the SFM3000 sensor.
Soft reset
The soft reset command (Figure 5) initiates a sensor reset devoid of switching off or on the power. Once the command is received, the control/status register contents from the EEPROM are reinitialized by the sensor. The sensor then begins operating as per these settings.
.jpg)
Figure 5. The soft reset command
Limitations
Deviations from the NXP I2C specification can be observed in the I2C interface of the SFM3000, which needs to be locked up and ceased to respond, under the following conditions:
- Glitches on the SCL.
- The first byte read from the sensor is not acknowledged by the master after the receipt of the header byte (I2C address + R bit).
These phenomena can be avoided by ensuring that the first data byte of the transaction is always acknowledged by the master during data reading from the sensor. In addition, a sensor reset must be possible through a hard reset. Furthermore, shorter cable length is recommended between the sensor and the microprocessor.

This information has been sourced, reviewed and adapted from materials provided by Sensirion Inc.
For more information on this source, please visit Sensirion Inc.