SFM 3000 arduino code problem

Hi everyone,

I have a problem with using SFM 3000 flow meter sensor with arduino. the default code uses Wire library. Unfortunately, when i use the code bellow, the code shows no result on the serial. when i searched for the problem , i found that there is a problem with Wire library when dealing with I2C sensors which can be solved if WSWire librabry is used. Unfortuantely, when i use WSWire libraby, the serial show only one constant reading which is 239.53.

Note : i changed in the codes of the sensor library by replacing <Wire.h> with <WSWire.h>

Regards,

the library used to run the code :

the library used for WSWire:

#include <Wire.h>
#include <sfm3000wedo.h>

SFM3000wedo measflow(64);

int offset = 32000; // Offset for the sensor
float scale = 140.0; // Scale factor for Air and N2 is 140.0, O2 is 142.8


void setup() {
  // put your setup code here, to run once:
  Wire.begin();
  Serial.begin(9600);
  delay(500); // let serial console settle


  // initialize the sesnor
  measflow.init();
  Serial.println("Sensor initialized!");
}

void loop() {
  unsigned int result = measflow.getvalue();

  float Flow = ((float)result - offset) / scale;
    
  Serial.print("Flow: ");
  if (result >= 0) {
    Serial.print(" ");
  }
  Serial.print(Flow, 5);
  Serial.print("\n");

  delay(10);
}

Unfortunately, when i use the code bellow, the code shows no result on the serial. when i searched for the problem , i found that there is a problem with Wire library when dealing with I2C sensors which can be solved if WSWire librabry is used.

There is no problem with the Wire library, at least the problem doesn't exist if the hardware conforms to the I2C standard and is correctly wired.

The value you get with the WSWire library means the sensor isn't answering at all (logic 1 is idle state on I2C). This let me assume that there is a wiring problem. Post a complete wiring diagram of your setup! Often the wire length is a problem, so write the wire length into the diagram too.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.