Humidity Sensor HH10D

Hi, I am completely stuck on getting an HH10D http://www.hoperf.com/upload/sensor/hh10d.pdf

I tested the code below with a melexis IR sensor (using the correct addresses) and it works great. Any advise would be greatly be appreciated.

`const SENSITIVITY_EPROM = “\x10”;
const OFFSET_EPROM = “\x12”;
const BASE_ADDRESS = 0x81; //Datasheet says 01. Everybody says 81.

// Imp Pins
// Pin 8 = SCL
// Pin 9 = SDA
// set the i2c clock speed.
hardware.i2c89.configure(CLOCK_SPEED_10_KHZ);

//=========================================================================================
//=========================================================================================
function read_c() {

local bytes =0;

      bytes=hardware.i2c89.read(BASE_ADDRESS, SENSITIVITY_EPROM, 2);
      server.log (bytes);
      bytes=hardware.i2c89.read(BASE_ADDRESS, OFFSET_EPROM, 2);  
      server.log (bytes);

}
//=========================================================================================

function intIR ()
{

server.log(“Humidy Sensor Started”);
imp.sleep(1);
read_c();

}

//=========================================================================================
intIR();`

What do you see logged? If the i2c commands fail, you’ll see a negative number logged (an error code from i2c). That would imply an addressing issue - do you have pullups on SCL and SDA?

If it succeeds, then you’re trying to log binary values which also won’t work too well.

Maybe do:

if (typeof bytes == "string") server.log(format("%02x %02x", bytes[0], bytes[1])); else server.log("i2c error: "+bytes);

…and post what that logs.

Reading the humidity is not over i2c with this part. You would need to connect the FOUT pin to pin1 on the imp and configure this as a pulse counter. Count for a second and then you have the frequency to feed into the algorithms in the datasheet.

Thank you for your reply. I do have pullups on SCL and SDA. I have checked the pinout and even verified that I can read i2C using a melexis IR (and its corresponding addresses)

I modified the code as follows. I have also tried with base address 0x01…

`const SENSITIVITY_EPROM = “\x10”;
const OFFSET_EPROM = “\x12”;
const BASE_ADDRESS = 0x81; //Datasheet says 01. Everybody says 81

fout<-count <- hardware.pin1;
fout.configure(PULSE_COUNTER, 1);
// Imp Pins
// Pin 8 = SCL
// Pin 9 = SDA
// set the i2c clock speed.
hardware.i2c89.configure(CLOCK_SPEED_10_KHZ);
const IMP_INT = 2 //every half second

//=========================================================================================
//=========================================================================================
function read_c() {

local bytes =0;

      bytes=hardware.i2c89.read(BASE_ADDRESS, SENSITIVITY_EPROM, 2);
      if (typeof bytes == "string") server.log(format("%02x %02x", bytes[0], bytes[1]));
          else server.log("i2c error: "+bytes);
      bytes=hardware.i2c89.read(BASE_ADDRESS, OFFSET_EPROM, 2);  
      if (typeof bytes == "string") server.log(format("%02x %02x", bytes[0], bytes[1]));
          else server.log("i2c error: "+bytes);

}
//=========================================================================================
function GetFrequency() {
local numPulses = fout.read();
return numPulses;
}
//=========================================================================================
function intIR ()
{
imp.sleep(1);
server.log (“Humidity Sensor Started”);
read_c();
}
//=========================================================================================
function hum ()
{
local freq = GetFrequency();
server.log (freq);
imp.wakeup(IMP_INT, hum);

}
//=========================================================================================
intIR();
hum();`

The output is as follows. I can also affect the fout readout (using a steamer) correctly. I just can seem to read the store i2c values so I can apply the formula.

2014-05-07 08:16:32 UTC-7: [Status] Downloading new code; 3.34% program storage used
2014-05-07 08:16:33 UTC-7: [Device] Humidity Sensor Started
2014-05-07 08:16:33 UTC-7: [Device] i2c error: (null : 0x0)
2014-05-07 08:16:33 UTC-7: [Device] i2c error: (null : 0x0)
2014-05-07 08:16:34 UTC-7: [Device] 7229
2014-05-07 08:16:37 UTC-7: [Device] 7165
2014-05-07 08:16:40 UTC-7: [Device] 7170
2014-05-07 08:16:43 UTC-7: [Device] 7187
2014-05-07 08:16:46 UTC-7: [Device] 7202
2014-05-07 08:00:41 UTC-7: [Device] 7253

That’s confusing. If you remove the sensor from the system totally and run the code, what do you see?

When the sensor is off I am getting nulls. I think that the pin out is correct. if I drop a different i2c chip and change the base addresse and offsets in the imp code everything works.
So either my base address is wrong (tired 01, 81 and 0x81 for good measure) or the chip is not working. There are some comments about the chip that the coating to make it waterproof must be scraped off prior to soldering. Ordered a new one and I will report back

Can you read the EEPROM’s part number from the module? I’d like to check the I2C address.

Oh, and this would be useful to see the output of:

server.log(hardware.i2c89.write(BASE_ADDRESS, “”));

…to see if the device is being found at all (I suspect it isn’t).

server.log(hardware.i2c89.write(BASE_ADDRESS, “”));
returns error code -2. The same code as when the chip is removed. So the device is not found at all.

The FOUT pin correctly returns a reading that is responding to changes in humidity.

I am not sure of how to read the part number from the module.

Are there any markings on top of the 8 pin device on the module?