Go Down

Topic: I2C Flow Sensor not communicating (Read 1 time) previous topic - next topic

Hassler

Hello Arduino users,

I've got a Honeywell I2C flow sensor I'm trying to hook up.  It's a HAFBLF0200C4AX3 that I've connected via a level shifter (3.3/5V) to an Arduino Uno.  I'm pretty sure everything is hooked up correctly (tested w/ multimeter).  I also got a software I2C library set up on the digital pins and was able to read from the standard I2C pins (A4 & A5) using the Wire library as a slave;  so I think I'm using the Wire library correctly.  When communicating with the sensor the software library just returns 255. The Wire library hangs on Wire.requestFrom(0x49) until I disconnect the sensor then it returns 0.  I'm hoping there's some protocol issue that I've overlooked (since it seems that Wire is expecting something from the sensor), but it looks like pretty standard.

The data sheet from the flow sensor:  http://sensing.honeywell.com/index.cfm/ci_id/157399/la_id/1/document/1/re_id/0

The I2C guide for it:  http://sensing.honeywell.com/index.cfm/ci_id/157404/la_id/1/document/1/re_id/0

Level shifter (1 on SCL, 1 on SDA) :  http://www.hagtech.com/pdf/translator.pdf

Any help is appreciated.  Thanks.

Here's my code:

Code: [Select]

#include <Wire.h>




void setup() {
  // put your setup code here, to run once:

Wire.begin();
Serial.begin(9600);

Serial.println("Initializing");

}

void loop() {
  // put your main code here, to run repeatedly:



Wire.requestFrom(0x49, 2);

Serial.print(Wire.receive(), DEC);
Serial.print("   ");
Serial.println(Wire.receive(), DEC);

delay(2000);

 
}


CrossRoads

What does this note say about I2C operation?

9. Refer to Honeywell Technical Note for I2C protocol information.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Hassler

That's the second link, the i2c guide.

CrossRoads

You have pullup resistors on the lines?
This part runs from 5V - why complicate things with the translator?
Supply voltage  3.3 Vdc 10%; 5.0 Vdc 10%

The first 4 bytes out should be something besides 255 no matter what the sensor is seeing it seems.

Another thing to try is to split this up:

Serial.print(Wire.receive(), DEC);

Read it, then print it:
byte1 = Wire.receive();
Serial.print (byte1);
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Hassler

There are 2 versions of the part, I am using the 3 v  version.  I have pullups to 3.3 v vdd coming off the sensor side.  I think the 255 indicates no activity from the sensor. 

Nick Gammon

Try running an I2C scanner like this to see if it even recognizes the part:

Code: [Select]
// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);
  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
 
  Wire.begin();
  for (byte i = 1; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}


If not, fix that up before you do requestFrom.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Hassler

Alright,

Finally got something.  Nick, at first your code would just hang on the first iteration of the loop.  Another scanner(software based) would return every address.  I replaced the 10kohm resistors in the level shifter with 3300s and now your code works perfectly.  (Actually I tried many, many things, but that was the one that worked).  I'm guessing the larger resistors (10K) caused too much transition time and messed up the signal?

Thank you Nick and Crossroads. 

Nick Gammon

Yes, 10K was probably too high. 4.7K was suggested as a rule of thumb, but lower is probably acceptable. I did some tests on this page:

http://www.gammon.com.au/i2c
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

CrossRoads

Glad you got it working.
4.7K vs 10K, really depends on the signal runs, wire lengths.
My Bobuino uses 10Ks, with an RTC connected via traces & good ground planes, so the signals should be good & solid.
Breadboard & jumpers, lower resistors for faster switching times are probably  better.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Nick Gammon

The datasheet for the device suggested 4K for SCL and 4K for SDA (one device) dropping down progressively to 383 ohms if you have 6 devices.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up