0% found this document useful (0 votes)
191 views10 pages

Sensirion I2c Functional Description sfm3xxx

This document describes the I2C communication protocol for interacting with Sensirion SFM3xxx sensor series. It provides details on the I2C interface, addressing, start/stop conditions, acknowledgement, data formatting and the command set for reading measurements and device information.

Uploaded by

Cesar Gordillo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
191 views10 pages

Sensirion I2c Functional Description sfm3xxx

This document describes the I2C communication protocol for interacting with Sensirion SFM3xxx sensor series. It provides details on the I2C interface, addressing, start/stop conditions, acknowledgement, data formatting and the command set for reading measurements and device information.

Uploaded by

Cesar Gordillo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

I2C Functional Description

Applicable to following sensors


SFM3000, SFM3200, SFM3300, SFM3400
I2C details for other SFM sensors are directly included in the sensor’s datasheet

Key content
▪ I2C communication details
▪ Command set and data transfer sequences
▪ Reset, limitations and extended command sets

Summary
This document describes the I2C communication with the SFM3xxx sensor series. Communication between the
master and the SFM3xxx series sensor runs via the digital I2C-interface. This document contains all essential as
well as several extended commands and some basic descriptions of the SFM3xxx series I2C protocol. For the
detailed specifications please check the NXP document "The I2C-Bus Specification".

1 Interface connection
Bi-directional bus lines are implemented by the devices (master and slave) using open-drain output stages and a
pull-up resistor (Rp) connected to the positive supply voltage.

The recommended pull-up resistor value depends on the system setup, particularly on the capacitance of the
circuit or cable and bus clock frequency. For quick prototyping a value of 10kOhm is a reasonable choice. Please
refer to NXP’s I2C bus specification in order to determine the optimal value.

The capacitive loads on SDA and SCL line have to be the same. It is important to avoid asymmetric capacitive
loads. In case of long wires (>10cm) it is necessary to shield SDA and SCL. Wires longer than 30cm should not
be used.

I2C Connection Diagram

VDD

m a ste r Rp Rp sla ve (S F M 3 0 0 0)
SDA

SCL

Both bus lines, SDA and SCL, are bi-directional and require an external pull-up resistor.

2 I2C Address
The I2C address is represented by a 7-digit binary value. By default, the I2C address is set to 64 (1000000b). The
address is always followed by a write bit (0) or read bit (1). The default hexadecimal I2C header for read access
to the sensor is therefore 0x81.

© Copyright Sensirion AG, Switzerland 1/10

Downloaded from Arrow.com.


3 I2C communication
The I2C protocol consists of start and stop conditions at the beginning and ending of the transfers and a number
of 8 bit frames in between, of which each frame is acknowledged in case of a successful transmission.

3.1 Transmission START Condition (S)

The START condition is a unique situation on the bus created by the master, indicating to the slaves the
beginning of a transmission sequence (the bus is considered busy after a START).

I2C Transmission Start Condition

SDA

SCL
S
START condition

A HIGH to LOW transition on the SDA line while SCL is HIGH

3.2 Transmission STOP Condition (P)

The STOP condition is a unique situation on the bus created by the master, indicating to the slaves the end of a
transmission sequence (the bus is considered free after a STOP).

I2C Transmission Stop Condition

SDA

SCL
P
STOP condition

A LOW to HIGH transition on the SDA line while SCL is HIGH.

3.3 Acknowledge (ACK) / Not Acknowledge (NACK)

Each byte transmitted over the I2C bus is followed by an acknowledge condition from the receiver. This means
that after the master pulls SCL low to complete the transmission of the 8th bit, SDA will be pulled low by the
receiver during the 9th bit time. If after transmission of the 8th bit the receiver does not pull the SDA line low, this
is considered to be a NACK condition.

© Copyright Sensirion AG, Switzerland 2/10

Downloaded from Arrow.com.


I2C Acknowledge / Not Acknowledge

n o t a ckn o w le d g e

SDA

a ckn o w le d g e

SCL R /_ W ACK D7 D0 ACK

Each byte is followed by an acknowledge or a not acknowledge, generated by the receiver


(The bold lines indicate that the sensor controls the SDA line)

3.4 Data transfer format

Data is transferred in byte packets in the I2C protocol. Each byte is followed by an acknowledge bit. Data is
transferred with the most significant bit first.

A data transfer sequence is initiated by the master generating the Start condition (S) and sending a header byte.
The I2C header consists of the 7-bit I2C device address and the data direction bit (R/_W).

The value of the R/_W bit in the header determines the data direction for the rest of the data transfer sequence. If
R/_W = 0 (WRITE) the direction remains master-to-slave, while if R/_W = 1 (READ) the direction changes to
slave-to-master after the header byte.

© Copyright Sensirion AG, Switzerland 3/10

Downloaded from Arrow.com.


4 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 data direction may not change after
the command bytes, since the R/_W bit of the preceding I2C header has already determined the direction to be
master-to-slave. In order to execute Read commands, the following principle is used. On successful
(acknowledged) receipt of the command code, the sensor stores the command internally. A successive Read is
invoked by initiating an I2C data transfer sequence with R/_W = 1 and the sensor replying with the requested
information.

If a correctly addressed sensor recognizes a valid command and access to this command is granted, it responds
by pulling down the SDA line during the subsequent SCL pulse for the acknowledge signal (ACK). Otherwise it
leaves the SDA line unasserted (NACK).

The commands are described below, and the data transfer sequences are specified.

Command Number of bytes


Command Description Comment
[16 bit] to read back
Start continuous measurement and/or move internal
0x1000 2 See chapter 4.1
pointer (back) to flow measurement result register
0x31AE 4 Read Serial Number (bit 31:0) See chapter 4.2
0x2000 NA Soft reset command See chapter 6

I2C master writes command to SFM3000 with address I2CAdr

I2CAdr[6:0] Cmd[15:8] Cmd[7:0]


ACK

ACK

ACK

S W

I2C master reads command results from SFM3000 with address I2CAdr
NACK

I2CAdr[6:0] flow data[15:8] flow data[7:0] CRC[7:0]


ACK

ACK

ACK

S R P

or

I2CAdr[6:0] serial nr[31:24] serial nr[23:16] CRC[7:0]


ACK

ACK

ACK

ACK

S R
NACK

serial nr[15:8] serial nr[7:0] CRC[7:0]


ACK

ACK

Dark areas with white text indicate that the sensor controls the SDA (Data) line.

4.1 Measurement Triggering

Flow measurements are started by writing the start measurement command (0x1000) to the sensor.
Measurement results are continuously updated until the measurement mode is stopped by sending any other
command or by a sensor reset. After a start measurement command, the measurement results can be read out

© Copyright Sensirion AG, Switzerland 4/10

Downloaded from Arrow.com.


continuously1. In the case that the sensor chip performs an unexpected reset, e.g. due to an intermediate drop in
the supply voltage below 4.75V, the sensor chip will stop measuring and a sensor read command will provide an
invalid result from a user register. To avoid such an invalid result it is recommended to repeat the “start
measurement” command in a repeated interval or for each “read” command as shown in the tables below. The
measurement result register is set to invalid after being read and only set to valid again when a new
measurement result is available. If no valid result is available, the chip does not acknowledge a read command.

The tables below give an example sequence with explanations for every command.

Timing for SFM3000 (see below table for other SFM3xxx)


∆ time (ms) I2C communication Measuring? Comment
Powering up of the sensor (heater powered up with
0 - No
start up of the sensor SFM3000)
After the sensor is out of reset, the start
100 80a 10a 00a → Yes
measurement command is sent
First measurement result read out after chip reset is
0.5 81n FFa FFa FFn Yes
invalid
80a 10a 00a Yes Start measurement command is sent
81a F0a 00a CRCn Valid measurement data is read out + CRC byte.
0.5 Yes
80a 10a 00a Start measurement command is sent
81a F0a 14n Updated flow value is read out. CRC is not read out.
0.5 Yes
80a 10a 00a Start measurement command is sent
No valid measurement data is ready yet. The read
0.4 81n Yes
request is not acknowledged
0.1 81a F0a 28a CRCn Yes New measurement data is available and read out.
1 80a 31a AEa → No Send read serial number command
81a 5Aa D8a CRCa
0.2 No Read example serial number
47a 40a CRCn

0.3 80a 10a 00a → Yes Start measurement command is sent


81a F0a 00a CRCn Measurement data is read out + CRC byte.
0.5 Yes
80a 10a 00a Start measurement command is sent
81a F0a 00a CRCn Measurement data is read out + CRC byte.
0.5 Yes
80a 10a 00a Start measurement command is sent
Dark areas with white text indicate that the sensor controls the SDA (Data) line.
An a indicates and ACK, an n indicates a NACK

1This means that an I2C header with R/_W bit = 1 could be sent continuously to read out those results, without preceding it
with command 0x1000

© Copyright Sensirion AG, Switzerland 5/10

Downloaded from Arrow.com.


Timing for SFM3200, SFM3300 and SFM3400
∆ time (ms) I2C communication Measuring? Comment
0 - No Powering up of the sensor
After the sensor is out of reset, the start
measurement command is sent (unlike for SFM3000,
40 80a 10a 00a No
the heater is only started with the start measurement
command )
First measurement result read out after chip reset is
81n FFa FFa FFn Yes
100 invalid
80a 10a 00a Yes Start measurement command is sent
81a F0a 00a CRCn Yes Valid measurement data is read out + CRC byte.
0.5
80a 10a 00a Yes Start measurement command is sent
81a F0a 14n Yes Updated flow value is read out. CRC is not read out.
0.5
80a 10a 00a Yes Start measurement command is sent
No valid measurement data is ready yet. The read
0.4 81n Yes
request is not acknowledged
0.1 81a F0a 28a CRCn Yes New measurement data is available and read out.
1 80a 31a AEa → No Send read serial number command
81a 5Aa D8a CRCa
0.2 No Read example serial number
47a 40a CRCn

0.3 80a 10a 00a → Yes Start measurement command is sent


81a F0a 00a CRCn Yes Measurement data is read out + CRC byte.
0.5
80a 10a 00a Yes Start measurement command is sent
81a F0a 00a CRCn Yes Valid measurement data is read out + CRC byte.
0.5
80a 10a 00a Yes Start measurement command is sent
Dark areas with white text indicate that the sensor controls the SDA (Data) line.
An a indicates and ACK, an n indicates a NACK

© Copyright Sensirion AG, Switzerland 6/10

Downloaded from Arrow.com.


4.2 Read Data Layout

Data that is read back from the Sensor consists of two or four bytes, with the most significant byte and bit read
first. The least significant bit and byte are read last. The following maps give more details on the content of the
different results:

Read flow measurement result

Bit #Bits Description/Coding


15:0 16 Flow measurement result. Bit <1:0> is always zero.

Read serial number

Command #Bits Description/Coding


0x31AE 32 Bit 31:0 of the unique serial number

4.3 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:

𝑚𝑒𝑎𝑠𝑢𝑟𝑒𝑑 𝑣𝑎𝑙𝑢𝑒 − 𝑜𝑓𝑓𝑠𝑒𝑡 𝑓𝑙𝑜𝑤


𝑓𝑙𝑜𝑤 [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.

5 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)

Note that CRC is only used for data transmitted from the slave to the master.

For details regarding cyclic redundancy checking, please refer to the AppNote SFM-04 “CRC Checksum” on our
website and the relevant literature.

6 Soft reset
The soft reset command 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.

© Copyright Sensirion AG, Switzerland 7/10

Downloaded from Arrow.com.


I2C Soft Reset
16 bit command code: 0x2000
Command: Soft Reset

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

ACK

ACK

ACK
S 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 system reboot
W Command[7:0]
I2CAdr Command[15:8]

7 Limitations
The I2C interface of the SFM3xxxx show deviations from the NXP I2C specification and might lock up and cease
to react (including to the soft reset command), under the following conditions:
▪ Glitches on the SCL, for example caused by electromagnetic irradiation or coupling.
▪ The master does not acknowledge the first byte read from the sensor after having sent the header byte (I2C
address + R bit). The critical acknowledge bit is highlighted below.

I2C read sequence. ACK after first read byte highlighted.

NACK
I2CAdr[6:0] Data[15:8] Data[7:0] CRC[7:0]
ACK

ACK

ACK

S R P

Dark areas with white text indicate that the sensor controls the SDA (Data) line.

The following design precautions are recommended to reduce the probability of sensor freeze/lockup and to
restore the sensor operation with a power (hard) reset in the event of a freeze:
▪ The cable length from the sensor to the microprocessor is recommended to be as short as possible and not
longer than 30 cm as well as shielded. For wires longer than 10 cm the SDA and SCL must be shielded.
Sources that emit electromagnetic radiation must be kept away from the I2C connection.
▪ When data is read from the sensor, one must ensure that the first data byte of the transaction is always
acknowledged by the master.
▪ It must be possible to reset the sensor through a hard reset in case the sensor freezes by powering the
supply voltage of the sensor off and on again.

Suggested measures and error handling logic to establish a reliable communication and read-out of the
measurement values:
▪ Send the “Start measurement” command before every read command to avoid an unnoticed sensor reset.
▪ Ensure the sensor acknowledges all commands, and the CRC checksum of the measurement data is valid.
▪ In case of an unexpected behavior from the sensor (NACK or a wrong CRC checksum), use the last valid
flow value and perform a sensor power (hard) reset if the error persists for 5 (or any other application
specific error threshold) consecutive cycles.

© Copyright Sensirion AG, Switzerland 8/10

Downloaded from Arrow.com.


8 Extended Command Set

Command # of bytes to
Task Detailled Command Description
[16 bit] read back
Start flow
0x1000 2 Start continuous flow measurement
measurement
Start temperature Start continuous temperature measurement. Bit <1:0>
0x1001 2
measurement* are always zero.
Read scale factor 0x30DE 2 Combining both bytes yields the flow scale factor
Read offset 0x30DF 2 Combining both bytes yields the flow offset
In order to read out the product type/article number,
0x31E3 2 two commands have to be sent to the sensor resulting
Read article in 4 bytes of data (bits <31:0>). The command 0x31E3
number results in the first two bytes (bits <31:16>) followed by
0x31E4 2 command 0x31E4 with another two bytes (bits
<15:0>).
In order to read out the serial number, two commands
0x31AE 2 have to be sent to the sensor resulting in 4 bytes of
Read serial number data (bits <31:0>). The command 0x31AE results in
the first two bytes (bits <31:16>) followed by command
0x31AF 2
0x31AF with another two bytes (bits <15:0>).
Soft reset 0x2000 NA Soft reset command

SFM3xxx-AW versions only! There is an additional EEPROM on the SFM3300-AW and SFM3400-AW to allow
storage of customer-specific data (e.g. usage hours). Please see all details in the datasheet of the EEPROM. The
EEPROM is of type 24LC01BT-I/MC. No additional validation or modification of EEPROM settings has been
performed by Sensirion.

*Allows read out of the chip temperature. Please note that the sensor temperature does not necessarily reflect the
temperature of the gas flowing through the sensor. See additional AppNote SFM-08 “Temperature Effects”.

© Copyright Sensirion AG, Switzerland 9/10

Downloaded from Arrow.com.


9 Revision history

Date Author Version Changes


July 2013 ANB 1 First release
July 2015 ANB 1.1 Added Read Serial Number Command. Minor changes.
Added Extended I2C Command Set and applicability to further
Jan 2021 PSIM 1.2
SFM3x00 sensors
Detailed measurement mode (section 4.1) and measures to
May 2022 LOEH 1.3 establish reliable communication despite the I2C limitations
(section 7)

10 Headquarters and Subsidiaries


SENSIRION AG Sensirion Korea Co. Ltd.
Laubisruetistr. 50 phone: +82 31 337 7700 3
CH-8712 Staefa ZH [email protected]
Switzerland www.sensirion.co.kr
phone: +41 44 306 40 00
fax: +41 44 306 40 30 Sensirion China Co. Ltd.
[email protected] phone: +86 755 8252 1501
www.sensirion.com [email protected]
www.sensirion.com.cn
Sensirion Inc., USA
phone: +1 805 409 4900 Sensirion AG (Germany)
[email protected] phone: +41 44 927 11 66
www.sensirion.com [email protected]
www.sensirion.com
Sensirion Japan Co. Ltd.
phone: +81 3 3444 4940 To find your local representative, please
[email protected] visit www.sensirion.com/contact
www.sensirion.co.jp

© Copyright Sensirion AG, Switzerland 10/10

Downloaded from Arrow.com.

You might also like