In this post, you will find an example of SFM3000-200 model mass flow meter using STM32F1 microcontroller.
SFM3000 is a digital flow meter especially suitable for high-volume applications. The design of the flow channel results in very low pressure drop through the sensor element, making it highly suitable for medical ventilation and respiration applications.
Detailed SFM3000 series I2C functional description can be found in this link. I2C peripheral must be initialized with the specifications of:
- 100 kHz Clock Speed
- 7-bit address length
- Disabled clock no stretch mode
Then, the library in this link must be added to the project. If CubeMx is used to create the project, then only the selected peripheral must be replaced in header file.
#define SFM3000_I2C_INS &hi2c2 // Address of I2C HAL Instance
If different libraries are used other than the HAL libraries, to write and read functions must be revised with respect to selected library.
uint8_t I2CreadBytes(uint16_t devAddr, uint8_t * buffer, uint8_t size); uint8_t I2CwriteBytes(uint16_t devAddr, uint8_t * buffer, uint8_t size);
After the necessary adjustments, the library is ready to use. This procedure can be preferred for successful operation:
sfm3000init() must be initiated once, then sfm3000GetValue() can be used whenever a new reading is wanted. The warnings and explanations on the header and source files must be considered.