Go Down

Topic: HDC1000 -->Humidity problem  (Read 1 time) previous topic - next topic


May 21, 2016, 02:24 pm Last Edit: May 22, 2016, 12:48 pm by HamingBird

I am using "Arduino UNO" with "HDC1000" and  "7 Segment LED HT16k33  Backpack". everything goes fine.

when I connect  "HDC1000" and  "7 Segment LED HT16k33  Backpack"   with  another microcontroller (i.e.  efm8bb10f8g).

then  the "Temperature and Humidity" both data are 100% correct , I compare it with  "Arduino UNO".

the only difference is, in "Arduino UNO"  Temperature and Humidity   both does not shows same time in the 7-segment display, but one after another if I comment out and upload it to "Arduino UNO". e.g
Code: [Select]

void loop() {
int Temperature= (int)hdc.readTemperature();    //Casting for int
int Humidity = (int)hdc.readHumidity();             //Casting for int Result

  matrix.print(Humidity);           //Reading Temperature sensor

[  comment out code Line]
 //matrix.print(Temperature);      //Reading Humidity sensor

  matrix.writeDisplay(); // Printing Temperature


But the value is 100% same in my  another microcontroller (i.e.  efm8bb10f8g).

So, it means  efm8bb10f8g  prog is also correct.

But the problem is, when Temperature increases  then, Humidity goes to 00. And when Temperature is

stop increasing or stable then Humidity increase from  00  and reach to the correct value.

for example:

[ the output is]
   23  /// Temperature
   58  /// Humidity

[ End output ]

[ but when Temperature increases, the output is ]

  28  /// Temperature
 00   /// humidity

 [end output]

 So Temperature increasing from 23 to 24,  25, 26, 27 and finally 28.
  the moment Tem start increasing from  23 to 28  at that moment Humidity is 00.

  But the moment when Tem reach to 28 and stop increasing then Humidity start increasing
from 00 to 9, 11, 15,25, 28,36.... 58   and then   stop increasing 
  and finally both are stable and  correct value  with 

Temperature 28  and Humidity 58


The interesting thing is "Temperature  and Humidity " both shows correct value according to the
room temperature and humidity compared with "Arduino UNO".

But the moment Temperature start increasing and until Temperature stop increasing(until it get stable), at that moment Humidity goes to 00 and stop working, until  Temperature get a stable value.

 when Temperature get stable value, that moment Humidity start to increasing from 00  to its final  value.

And finally the both value "Temperature and Humidity" are correct.

My i2c bus connection is 100% correct, also other connection.


What I have changed  two Methos.

1. <float Adafruit_HDC1000::readHumidity(void) >

2. < uint32_t Adafruit_HDC1000::read32(uint8_t a, uint8_t d) >



1. Method is :


Code: [Select]

float Adafruit_HDC1000::readHumidity(void) {

  float hum = (read32(HDC1000_TEMP, 20) & 0xFFFF);  ///HDC1000_TEMP  0x00 
  hum /= 65536;
  hum *= 100;

  return hum;



1. Method "readHumidity(void) "   changes are :

-------------------------------    changed Method  -----------------------------------

it was : 
< float hum = (read32(HDC1000_TEMP, 20) & 0xFFFF);   > /// with this I didn't get correct value
changed to : 
 <float hum = (read33(HDC1000_HUMID, 20) >> 16);>   /// its shows correct value

------------------------------- End    changed Method  -----------------------------------

2. Method is :


Code: [Select]

uint32_t Adafruit_HDC1000::read32(uint8_t a, uint8_t d) {
  Wire.beginTransmission(_i2caddr);  ;


  Wire.requestFrom((uint8_t)_i2caddr, (uint8_t)4);///wire.cpp ---> requestFrom 3

  uint32_t r = Wire.read(); 
  r <<= 8;
  r |= Wire.read(); 
  r <<= 8; 
  r |= Wire.read();
  r <<= 8; 
  r |= Wire.read(); 
  return r;



2. Method "read32(uint8_t a, uint8_t d) "   changes are :

I make another method but almost same called        <read33(uint8_t a, uint8_t d)>
because, the same method   <read32(uint8_t a, uint8_t d)> 
I used for "Temperature" and its corret no problem with it.  But problem with "Humidity"
and I used  Method  <read33(uint8_t a, uint8_t d)" for "Humidity>

and the changes for Method  <read32(uint8_t a, uint8_t d)>   To make a  Method 
 <read33(uint8_t a, uint8_t d)>   is :

it was :     
< Wire.write(HDC1000_TEMP);>

changes to :     
<Wire.write(HDC1000_HUMID);>  /// changed for humidity


Thats it.

the full prog can be found in

for header file :


for cpp file : 


I would really appreciate  for the help of information...




May 22, 2016, 02:36 am Last Edit: May 22, 2016, 02:36 am by mrburnette

Please edit your post  and use code tags... that is the far-left insert symbol: </>

No one is going to read your post when it is so messy.



May 22, 2016, 01:52 pm Last Edit: May 22, 2016, 01:52 pm by Paul__B
Thank you for putting in the "code" tags.

If I may point out that it is still rather upsettingly messy and hard to read.  You really need to remove all the double spacing and rather than typing rows of dashes as separators - to the extent that separators are in fact necessary, use the "Horizontal Rule" icon third from the right over the compose window.  Like this:

 And do not put newlines after it!


From reading the datasheet, the part returns 16 bit values for the temperature and humidity readings.
You can read them separately or they can both read during the same i2c connetion and it appears that is what adafruit does when you ask for either temperature or humidity.
They read both 16 bit values and compose a 32 bit value and depending on whether you ask for temperature or humidity they use either the upper (for temp) or lower (for humidity) 16 bits of the 32 bit read value.

Given the rest of their code, is not doing anything smart with the 32 bit read data, I see no reason at all to do it this way since the way they are doing it will create more overhead and be slower then just reading the 16 bit value that is needed from the appropriate TEMP or HUMID register.
Doing the double read can also potentially create some issues - see below:

That part has some slow measurement and recovery periods for humidity and the adafruit code does not check to see if the part was not ready with a reading.
For example, the part will return a NAK during the address phase, if it is not ready with measurement data and you address it to read the measurement.
It isn't clear what happens if you read all 4 measurement bytes in the same i2c connection when the temperature reading is ready but the humidity reading is not.
It is possible that the humidity reading returns zero in that case.
During the address phase of I2c (where the part could return NAK if a reading is not available) there is no way for the part to know if the host is going to ask for just the temperature reading or both temp and humidity. So if temp is ready, then the part will ACK even if the humidity reading was not available.
And since i2c cannot NAK a read request, the part must return something for the two humidity bytes after the host has read the the two temperature bytes.
The data sheet doesn't specify what happens in this case.
i.e. does it return the last valid reading or does it return zero.
It would not surprise me if it returned zero in this case.

If I were doing the code, I'd read each of the 16 bit values (temperature/humidity)  as needed in the readTemperature()/readHumidity() functions. i.e. do a 16 bit read to the appropriate TEMP or HUMID register and never read both at the same time. Not only would it be slightly faster but it would ensure that the code could also check to see if the part failed to respond to the read request, which indicates that there is no reading available. If that were the case, I'd return the previous reading (which would have to be saved internally to handle this condition) or an error, depending on if the API was defined to support returning errors.

This code seems be wrong:
Code: [Select]
void Adafruit_HDC1000::writeConfig(uint16_t config) {

It makes no sense to do another begin to the i2c address which is the numerical value of the config register.
Seem like this code should be:
Code: [Select]
void Adafruit_HDC1000::writeConfig(uint16_t config) {

Go Up