HTU21D problem with I2C

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.

I tested this with my SparkFun HTU21D board, and it works fine. I did keep the while() loop though, otherwise it might not work if it can’t establish a connection to the board early in the execution of the program. That gives it an opportunity to “settle”.

Are all of your connections to the board itself soldered? I had it stuck in a breadboard for my initial testing a long time ago, with pins simply passing through the open holes. That provided a very unstable connection. Eventually once I was done testing I soldered some wires to the board and instantly all of my connection issues were gone.

1 Like

Dear Legoguy thank you very much for your reply,

I still can not make it work. Although I can read data from the HDC100x through I2C .

I have checked everything . Is it possible you can send me the code that works for you?
What kind of firmware do you have?
Can you also send me the connection?

Maybe you could really post a good quality image of your setup where we can see the effective wiring and the boards.

OK I sending you my pictures.

OK, thanks for these and I guess you have soldered the header pins to the Battery Shield and the HTU21D breakout board?

Since this we can’t see on these pics.

yes I have everything soldered :slight_smile:

I used the same exact code as the .ino contained in the HTU21D library available in Particle Build:

#include "HTU21D/HTU21D.h"

HTU21D htu = HTU21D();

void setup()
{
	Serial.begin(9600);

	Serial.println("HTU21D test");

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

	Serial.println("HTU21D OK");
}

void loop()
{
	Serial.println("===================");
	Serial.print("Hum:"); Serial.println(htu.readHumidity());
	Serial.print("Temp:"); Serial.println(htu.readTemperature());
	Serial.println();

	delay(1000);
}

As for the wiring, mine is like this:

2 Likes

BTW, has the Battery Shield not also got a fuel gauge connected via I2C?
Did you get any other device reported when you tried the i2c_scanner?

Maybe having two sets of pull-up resistors could be a problem too.
Try connecting the HTU21D directly to the Photon without the Battery Shield.

1 Like

The SparkFun Battery shield also has i2c pull-up resistors on-board. Did you cut the traces of one of the two boards so that only one of them has pull-up resistors?

(PS. the reference material of both of these boards mentions this, but it can be easy to forget!)

1 Like

I have just tried out directly without the battery shield , but still nothing :frowning:

I know it’s much to ask, but would you happen to have an oscilloscope to have a look at the I2C lines during communication?

Or could you try out if the I2C interface on the Photon works correctly by just plugging the Photon back into the battery shield, without the HTU21D and try this sample to read the fuel gauge of the Battery Shield
https://build.particle.io/libs/563a270429cfc5f1c900019e/tab/MAX17043_Simple.cpp

Yes I am reading OK the values from the battery shield . And when I connect also the HDC100x with the battery shield I get values fine.

I really do not understand, probably I am missing something ,

I wonder if your board is defective? But before we go that far, maybe check all your solder connections for a cold joint. That has gotten me in trouble once or twice!

Hi legoguy!

Thanks for your reply. This is what I have now :

The HTU21D works fine with an ARDUINO board.
The Photon worksfine with a HDC100x board

I put together the HTU21D with Photon board but I get a back that the HTU21D not found , meaning that htu.begin can not establish a connection .

Has anyone else tried to connect with the HTU21D?

I made code for this SHT21(HTU21D). It is working fine. You can see in simulation in Proteus 8 or newer. see in image.

Hello,

Still nothing …I can not make it work and get values from this board. Is there anyone out there that can test it with 0.4.9 and tell me if everything is OK?