HTU21D problem with I2C

Hi ,

Thanks for the fast reply, I have triple check the wiring and it is OK. I suppose it must be something with the library.

Have you used it before?

I have not used the library. You could try the Sparkfun sample code for Arduino. Just comment out the #include Wire.h and it compiles on the Particle. I did not test the operation, but it compiles.

And, of course, you need to use the Particle pins for I2C, D0=SDA, D1=SCL, not the Arduino ones in the comment at the top of the file!

1 Like

We'd still like to see it :wink:
There were other people who triple checked and then had Photons just sitting on header pins - not soldered!

Or if the jumper between the two resistors wasn't bridged, you'd need to do that

Hi ,

I have just checked it with an Arduino board and everything works fine. Maybe there is something wrong with the library of particle?

Can anyone check it and tell me?

I am using a photon 0.4.9 firmware.

This doesn't prove a lot since the Arduinos tend to have I2C pull-ups on-board, but Particles haven't.
So if it were about missing pull-ups that test would not make you any wiser.

But there are some threads already about HTU21 and some of them are marked as solved, so you might find something there (even in the ones about Adafruit boards)
Search results for 'htu21 solved' - Particle

You could also check if the I2C address in the library is correct by use of the i2c_scanner sketch in this thread
Photon flashed once, now can't flash again

The thing is that I have tried in the past this sensor with photon and everything worked fine before some months with the same wiring in the same photon with the same firmware.

Also the official PCB schematic from sparkfun says that the pull up resistors are on it in the module.

So I think it must be something internally in particle photon .Can anyone from particle just tell us if the libraries are OK?

Okay? Why should then all out of a sudden the library (which is part of the firmware once it's flashed to the device) have got something wrong with it?
Unless you had used the old version 0.0.1 back then (which would then not be the same firmware).
But this can easily be tested, if you just use that then (hit the info icon (i) next to the library name and select 0.0.1 and try it out).

BTW: This may have been an interesting information for the initial post.

I do know that, hence my comment in a previous post

The big red blob in the schematics marked SJ1 (and framed green on the image I posted) are two cut-open jumpers that are by default closed. And since we don't know what you did or didn't do to your device I just intended to make sure that the resistors (clearly present on the board) are actually active which they wouldn't be if the jumper was open(ed).


BTW: Why are you not trying to use the unchanged sample code, which seems to have a while() in setup for some reason I'd guess?

No they are active , I have checked it with a multi-meter .I now have seen that the library has changed to a new version 0.0.2

I was using the old library 0.0.1

How can I use the old one back?

The only difference between these two versions is in HTU21D::begin()

  // v0.0.1
  Wire.begin();

  // v0.0.2
  if (!Wire.isEnabled())
    Wire.begin();

so if you just add Wire.begin(); before htu.begin() you have the same effect as if you went back to 0.0.1.

But I'd also put back the while() loop in setup().

And if this all doesn't work, try out the i2c_scanner to see if your device is detectable at all and which address it has (expected is 0x40).

I have changed the library to 0.0.1

But still nothing happens . I can find the device in 0x40 because I can read it from an Arduino board.

I dont know what is wrong here. I am confused…

Just give the scanner a try.
The original SparkFun library has a comment next to the #define which states // unshifted address, so if we need the shifted one here, you’d find out with the scanner.

And what about the while()?

OK this is what I get from I2C scanner

Scanning…
I2C device found at address 0x40 !
done

What to do with the While?

The original sample has this in setup()

void setup()
{
	Serial.begin(9600);
	Serial.println("HTU21D test");

        while (!htu.begin())
        {
	    Serial.println("HTU21D not found");
	    delay(1000);
	}

	Serial.println("HTU21D OK");
}

Maybe the sensor is slow in responding and hence the original contributor had this implemented.

I tried this also. Nothing happened …

Maybe someone from particle can guide us through or can give us a hand here?

Scruffr thank you for your help

1 Like

Hi,

I am searching the hole day , but still nothing . I can not explain what it wrong and I can not communicate with the HTU21D.

It is strange. …

I’ve asked my fellow Elites if one of them has a SparkFun HTU21D board, to give you better advice, but haven’t heard anything back yet.

I have one. It’s working fine with https://github.com/sparkfun/SparkFun_Photon_Weather_Shield_Particle_Library/tree/master/firmware

I will see if I can get a basic firmware compiling with 0.0.2 of the HTU21D library you’re trying to use.