Git Product home page Git Product logo

arduino-i2c-sfm-sf06's People

Contributors

leoniefierz avatar psachs avatar rol-la avatar sensirion-bot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

surejm hibrar khrams

arduino-i2c-sfm-sf06's Issues

SFM-3013-300-CL Wiring Diagram Arduino Mega

Hi,

Our team is attempting to connect SIX SFM-3013-300-CL Mass Flow Rate (MFR) Sensors to an Arduino Mega and get a readable output on a Laptop. This would require a multiplexer to enable multiple sensors to be integrated. The datasheet states the requirement for a 3.3kohm pull-up resistor to be fitted. Do these resistors need to be connected one to each the SDL and SCL port of each MFR sensor and then to the multiplexer? Would any additional components/resistors be required for this wiring diagram, and is this the right way to set up the system?

Thanks

SFM3013-300-CL Code Issue for connecting multiple sensors with Multiplexer(TCA9548A)

Hi, I am trying to connect two SFM-3013-300-CL's to an Arduino via a TCA9548A multiplexer to collect flow and temperature data. I am using the 'exampleusage.ino' file and have set the I2C multiplexer as specified. However I keep receiving the following error: Error trying to execute readMeasurementData(): Not enough data received

image

I am trying the to run the multiplexer with two sensors to test if it works with the following code:

`#include <Arduino.h>
#include <SensirionI2cSfmSf06.h>
#include <Wire.h>

#define TCAADDR 0x70
int active_sensors[8];

SensirionI2cSfmSf06 sensor;
SensirionI2cSfmSf06 sensor_2;

void tcaselect(uint8_t i) { // i stands for bus
if (i > 7) return;
Wire.beginTransmission(TCAADDR);
Wire.write(1 << i); // send byte to select bus
Wire.endTransmission();
}

static char errorMessage[64];
static int16_t error;

void print_byte_array(uint8_t* array, uint16_t len) {
uint16_t i = 0;
Serial.print("0x");
for (; i < len; i++) {
Serial.print(array[i], HEX);
}
}

void setup() {

Serial.begin(115200);
while (!Serial) {
    delay(100);
}
Wire.begin();
tcaselect(1);
sensor.begin(Wire, SFM3013_I2C_ADDR_2F);

tcaselect(1);
sensor.stopContinuousMeasurement();
delay(100);
uint32_t productIdentifier = 0;
uint8_t serialNumber[8] = {0};
error = sensor.readProductIdentifier(productIdentifier, serialNumber, 8);
if (error != NO_ERROR) {
    Serial.print("Error trying to execute readProductIdentifier(): ");
    errorToString(error, errorMessage, sizeof errorMessage);
    Serial.println(errorMessage);
    return;
}
Serial.print("productIdentifier: ");
Serial.print(productIdentifier);
Serial.print("\t");
Serial.print("serialNumber: ");
print_byte_array(serialNumber, 8);
Serial.println();
tcaselect(1);
error = sensor.startO2ContinuousMeasurement();
if (error != NO_ERROR) {
    Serial.print(
        "Error trying to execute startO2ContinuousMeasurement(): ");
    errorToString(error, errorMessage, sizeof errorMessage);
    Serial.println(errorMessage);
    return;
}

tcaselect(2);
sensor.begin(Wire, SFM3013_I2C_ADDR_2F);

tcaselect(2);
sensor.stopContinuousMeasurement();
delay(100);
uint32_t productIdentifier = 0;
uint8_t serialNumber[8] = {0};
error = sensor.readProductIdentifier(productIdentifier, serialNumber, 8);
if (error != NO_ERROR) {
    Serial.print("Error trying to execute readProductIdentifier(): ");
    errorToString(error, errorMessage, sizeof errorMessage);
    Serial.println(errorMessage);
    return;
}
Serial.print("productIdentifier: ");
Serial.print(productIdentifier);
Serial.print("\t");
Serial.print("serialNumber: ");
print_byte_array(serialNumber, 8);
Serial.println();
tcaselect(2);
error = sensor.startO2ContinuousMeasurement();
if (error != NO_ERROR) {
    Serial.print(
        "Error trying to execute startO2ContinuousMeasurement(): ");
    errorToString(error, errorMessage, sizeof errorMessage);
    Serial.println(errorMessage);
    return;
}

}

void loop() {

float aFlow = 0.0;
float aTemperature = 0.0;
uint16_t aStatusWord = 0u;
delay(100);
tcaselect(1);
error = sensor.readMeasurementData(aFlow, aTemperature, aStatusWord);
if (error != NO_ERROR) {
    Serial.print("Error trying to execute readMeasurementData(): ");
    errorToString(error, errorMessage, sizeof errorMessage);
    Serial.println(errorMessage);
    return;
}
Serial.print("aFlow: ");
Serial.print(aFlow);
Serial.print("\t");
Serial.print("aTemperature: ");
Serial.print(aTemperature);
Serial.print("\t");
Serial.print("aStatusWord: ");
Serial.print(aStatusWord);
Serial.println();

tcaselect(2);
error = sensor.readMeasurementData(aFlow, aTemperature, aStatusWord);
if (error != NO_ERROR) {
    Serial.print("Error trying to execute readMeasurementData(): ");
    errorToString(error, errorMessage, sizeof errorMessage);
    Serial.println(errorMessage);
    return;
}
Serial.print("aFlow: ");
Serial.print(aFlow);
Serial.print("\t");
Serial.print("aTemperature: ");
Serial.print(aTemperature);
Serial.print("\t");
Serial.print("aStatusWord: ");
Serial.print(aStatusWord);
Serial.println();

}`

Would appreciate any guidance.

Function readMeasurementData returns integer on Arduino Due

Plaform: Arduino Due (SAM board package 1.6.12)
File: SensirionI2CSfmSf06.cpp
Function: SensirionI2CSfmSf06::readMeasurementData

flow = (intFlow - _flowOffset) / _flowScaleFactor;
should be changed to:
flow = (float)(intFlow - _flowOffset) / (float)(_flowScaleFactor);

otherwise it returns integer values.

Edit: typo in SAM board package version

Reading Air-O2 Flow from SFM3003-300-CL

Hi,

I have been able to read O2 flow successfully using this library using the aforementioned SFM3003-300-CL library on an Arduino Nano 33 BLE. However, when I tried to use the startAirO2ContinuousMeasurement() function to read the both a mixture-flow from human breath (as well as the O2 concentration within this mixture), it started to give me large negative values for flow. Further, the last nine bits of the status word did not change to match a changing level of O2 concentration as they should according to the datasheet. This may be entirely due to my lack of understanding, so it would be much appreciated to get some clarity on this.

The following code is what I am currently using (note for others who use a Nano that I had to change the name of the variable "error" as it is a keyword in the Mbed OS driver commonly used on Arduino Nano systems):

// #include <Arduino.h>
#include <SensirionI2cSfmSf06.h>
#include <stdlib.h>
#include <stdint.h>

#include <Wire.h>

SensirionI2cSfmSf06 sensor;

static char errMessage[64];
static int16_t err;


void print_byte_array(uint8_t* array, uint16_t len) {
  uint16_t i = 0;
  Serial.print("0x");
  for (; i < len; i++) {
    Serial.print(array[i], HEX);
  }
}




void setup() {

  Serial.begin(115200);
  while (!Serial) {
    delay(100);
  }
  Wire.begin();
  sensor.begin(Wire, SFM3003_I2C_ADDR_28);

  sensor.stopContinuousMeasurement();
  delay(100);
  uint32_t productIdentifier = 0;
  uint8_t serialNumber[8] = { 0 };
  err = sensor.readProductIdentifier(productIdentifier, serialNumber, 8);
  if (err != NO_ERROR) {
    Serial.print("Error trying to execute readProductIdentifier(): ");
    errorToString(err, errMessage, sizeof errMessage);
    Serial.println(errMessage);
    return;
  }
  Serial.print("productIdentifier: ");
  Serial.print(productIdentifier);
  Serial.print("\t");
  Serial.print("serialNumber: ");
  print_byte_array(serialNumber, 8);
  Serial.println();

  
  uint16_t o2_vol_frac = 21; // in %, assuming 21% volume O2 in ambient air mixture.
  err = sensor.startAirO2ContinuousMeasurement(o2_vol_frac);
  if (err != NO_ERROR) {
    Serial.print(
      "Error trying to execute startO2ContinuousMeasurement(): ");
    errorToString(err, errMessage, sizeof errMessage);
    Serial.println(errMessage);
    return;
  }
}

void loop() {
 
  float aFlow = 0.0;
  float aTemperature = 0.0;
  uint16_t aStatusWord = 0u;
  delay(100);
  err = sensor.readMeasurementData(aFlow, aTemperature, aStatusWord);
  if (err != NO_ERROR) {
    Serial.print("Error trying to execute readMeasurementData(): ");
    errorToString(err, errMessage, sizeof errMessage);
    Serial.println(errMessage);
    return;
  }
  Serial.print("aFlow: ");
  Serial.println(aFlow);
  Serial.print("aTemperature: ");
  Serial.println(aTemperature);
  Serial.print("aStatusWord: ");
  Serial.println(aStatusWord);
}

The resulting output looks something like :

aFlow: -24583.00
aTemperature: 27.95
aStatusWord: 26645

which seems entirely incorrect. I am assuming that readFlowMeasurement is accurately using the scale factors and such due to its prior performance, which leaves either my use of the O2 volume input parameter or my use of the read function itself at fault.

Thank you for your help!

Negative flow values when using SFM-3013

Hi there,

I seem to be getting negative values for flow moving in the direction of the arrow on the flow sensor and positive values for flow moving in the opposite direction. Would you be able to shine any light on this - am I missing something simple here??

Thanks,
Seán

SFM3013 Arduino Interface Issue

Hi,

I am trying to connect an SFM-3013-CL to an Arduino Mega and I'm using this repo (arduino-i2c-sfm-sf06) as guidance to collect Temperature and Mass Flow Readings. Following is the Circuit Set-Up I've been using:

image

I have followed the guidance and downloaded the 'Sensirion I2C SFM-SF06' Library and also installed all the required dependencies onto the Arduino IDE. I decided to download and use the latest 'exampleUsage' file (1.4.0), SensirionI2cSfmSf06.h and SensirionI2cSfmSf06.cpp.

Following is the code I've used (from the exampleUsage file):

`
#include <Arduino.h>
#include <SensirionI2cSfmSf06.h>
#include <Wire.h>

SensirionI2cSfmSf06 sensor;

static char errorMessage[64];
static int16_t error;

void print_byte_array(uint8_t* array, uint16_t len) {
uint16_t i = 0;
Serial.print("0x");
for (; i < len; i++) {
Serial.print(array[i], HEX);
}
}

void setup() {

Serial.begin(115200);
while (!Serial) {
    delay(100);
}
Wire.begin();
sensor.begin(Wire, SFM3013_I2C_ADDR_2F);

sensor.stopContinuousMeasurement();
delay(100);
uint32_t productIdentifier = 0;
uint8_t serialNumber[8] = {0};
error = sensor.readProductIdentifier(productIdentifier, serialNumber, 8);
if (error != NO_ERROR) {
    Serial.print("Error trying to execute readProductIdentifier(): ");
    errorToString(error, errorMessage, sizeof errorMessage);
    Serial.println(errorMessage);
    return;
}
Serial.print("productIdentifier: ");
Serial.print(productIdentifier);
Serial.print("\t");
Serial.print("serialNumber: ");
print_byte_array(serialNumber, 8);
Serial.println();
error = sensor.startO2ContinuousMeasurement();
if (error != NO_ERROR) {
    Serial.print(
        "Error trying to execute startO2ContinuousMeasurement(): ");
    errorToString(error, errorMessage, sizeof errorMessage);
    Serial.println(errorMessage);
    return;
}

}

void loop() {

float aFlow = 0.0;
float aTemperature = 0.0;
uint16_t aStatusWord = 0u;
delay(100);
error = sensor.readMeasurementData(aFlow, aTemperature, aStatusWord);
if (error != NO_ERROR) {
    Serial.print("Error trying to execute readMeasurementData(): ");
    errorToString(error, errorMessage, sizeof errorMessage);
    Serial.println(errorMessage);
    return;
}
Serial.print("aFlow: ");
Serial.print(aFlow);
Serial.print("\t");
Serial.print("aTemperature: ");
Serial.print(aTemperature);
Serial.print("\t");
Serial.print("aStatusWord: ");
Serial.print(aStatusWord);
Serial.println();

}
`

However, upon running this, the serial monitor shows a maximum of 2-3 readings, and then stops displaying data and prints unreadable symbols:
image

Would appreciate if I could get guidance on what I am doing incorrectly, and how to resolve this.

Thanks.

SFM4300-20-P Negative value

Hi
Thank you for creating library, for very easy use.
I have configured SFM4300-20-P with Arduino mega 2560 in which facing of issue flow rate over 12 or 13 l/m value becomes negative. also after overlapping range it becomes 0 (request for support showing final range limit).

SFM4300-50-P

Hi,
Thanks for creating this library, very easy to use.
I have a problem when using a SFM4300-50-P. When the flow rate is over 32 l/min, the value becomes negative (-32, then, the higher the flow, the lower this negative value, -30, -28, etc.). Could it be a problem of coding a byte operation?

I do not experience this problem when using a SFM4300-20-P, which is limited to 20 l/min.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.