Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

Honeywell HumidIconTM Digital Humidity/Temperature Sensors (HIH6130/6131 and HIH6120/6121 Series)

Introduction

Honeywell HumidIconTM Digital Humidity/Temperature Sensors: HIH6130/6131 and 6120/6121 Series is a digital output-type relative humidity (RH) and temperature sensor combined in the same package. The library uses I2C to connect to the sensor (see the Wire library). SPI can also be used, but is not implemented in this library.

The library consists of 2 classes (actually 2 libraries):

  • HIH61XX: Use this one if you just want to get the humidity/temperature.
  • HIH61XXCommander: Use this one if you want to enter command mode and change (or even just read) some of the EEPROM registers.

If you have multiple devices connected to the I2C bus, remember that this device screws up the bus when it is not powered. One solution is to keep the device powered all the time. Another possible solution is to add an analog switch to physically disconnect the GND line or the SDA line to the device.

This library has been tested, but might still contain bugs, so please be careful.

Bugs, suggestions, comments are always welcome here.

Datasheets

Wiring

  • Simple:

Components:

  • An arduino
  • 2 pullup resistors, optional (I tried it with 1K - 100K: all worked)
  • 0.1µF capacitor
  • 0.22µF capacitor
  • An HIH61xx sensor

  • More complex (if you want to use command mode):

Components:

  • An arduino
  • 2 pullup resistors, optional (I tried it with 1K - 100K: all worked)
  • 0.1µF capacitor
  • 0.22µF capacitor
  • A 3.3V voltage regulator (to get the voltage from the power pin down to 3.3V)
  • An HIH61xx sensor

Of course, you can always connect the alarm outputs (pins 5 and 6 on the HIH61XX chip) to a digital input pin on the Arduino to do some fancy stuff when the humidity goes above (or falls below) a certain point. See HIH61XXCommander.h (and of course the datasheets) for details.

Simple usage (control the sensor from code)

Connect everything like the first image.


#include <Wire.h>
#include <HIH61XX.h>


//  Create an HIH61XX with I2C address 0x27, powered by 3.3V pin
HIH61XX hih(0x27);


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


void loop()
{
  //  start the sensor
  hih.start();

  //  request an update of the humidity and temperature
  hih.update();

  Serial.print("Humidity: ");
  Serial.print(hih.humidity(), 5);
  Serial.print(" RH (");
  Serial.print(hih.humidity_Raw());
  Serial.println(")");

  Serial.print("Temperature: ");
  Serial.print(hih.temperature(), 5);
  Serial.println(" C (");
  Serial.print(hih.temperature_Raw());
  Serial.println(")");

  while(true);
}
 

Simple usage (control the sensor from a stream like Serial, or an Ethernet stream, or even Wire)

Connect everything like the first image.

Available commands:

  • '1': start the sensor
  • '0': stop the sensor
  • 'a': return the I2C address
  • 'p': return the power pin
  • 'u': update humidity / temperature
  • 'h': return humidity (as a float)
  • 't': return temperature (as a float)


#include <Wire.h>
#include <HIH61XX.h>

HIH61XX hih(0x27);

void setup()
{
  Serial.begin(115200);
  Wire.begin();
}

void loop()
{
  while(Serial.available()) {
    hih.commandRequest(Serial);
  }

  delay(100);
}
 

Advanced usage (control from code)

Connect everything like the second image.


#include <Wire.h>
#include <HIH61XX.h>
#include <HIH61XXCommander.h>



//  Create an HIH61XXCommander with I2C address 0x27, powered by digital pin 3
//  If you want to use Command Mode you MUST use the powerPin!
HIH61XXCommander hih(0x27, 3);



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



void loop()
{
  //  start the sensor, eeprom data is automatically read.
  hih.start();

  //  print out the whole EEPROM
  Serial.print("EEPROM:                   ");
  for(int i = 0; i < 8; ++i) {
    if(i) {
      Serial.print(' ');
    }
    Serial.print(hih.eeprom()[i]);
  }
  Serial.println();
  Serial.println();

  //  print out all properties. the changes to EEPROM have been commented out,
  //  so you don't accidentally screw up your chip.

  Serial.print("StartupMode:              ");
  Serial.println(hih.startupMode() ? "FastStartup" : "SlowStartup");
  //  set the fast startup mode (3ms)
  //  hih.setStartupMode(HIH61XXCommander::FastStartup);
  //  set the slow startup mode (10ms)
  //  hih.setStartupMode(HIH61XXCommander::SlowStartup);

  Serial.print("High alarm on (raw):      ");
  Serial.println(hih.highAlarmOn_Raw());
  //  hih.setHighAlarmOn_Raw(12345);

  Serial.print("High alarm off (raw):     ");
  Serial.println(hih.highAlarmOff_Raw());
  //  hih.setHighAlarmOff_Raw(12345);

  Serial.print("High alarm on:            ");
  Serial.println(hih.highAlarmOn());
  //  hih.setHighAlarmOn(0.5);

  Serial.print("High alarm off:           ");
  Serial.println(hih.highAlarmOff());
  //  hih.setHighAlarmOff(0.5);

  Serial.print("High alarm polarity:      ");
  Serial.println(hih.highAlarmPolarity() ? "ActiveLowPolarity" : "ActiveHighPolarity");
  //  hih.setHighAlarmPolarity(HIH61XXCommander::ActiveHighPolarity);
  //  hih.setHighAlarmPolarity(HIH61XXCommander::ActiveLowPolarity);

  Serial.print("High alarm output config: ");
  Serial.println(hih.highAlarmOutputConfig() ? "OpenDrainOuputConfig" : "PushPullOuputConfig");
  //  hih.setHighAlarmOutputConfig(HIH61XXCommander::PushPullOuputConfig);
  //  hih.setHighAlarmOutputConfig(HIH61XXCommander::OpenDrainOuputConfig);

  //  same as above for the low alarm... (not included)

  Serial.print("Customer ID:              ");
  Serial.println(hih.customerId());
  //  hih.setCustomerId(0xABCDEF);

  Serial.println();

  //  To write the changes to the chip use:
  //  hih.writeEEPROM();
  //  But then you still have to cycle the power for the changes to take effect, so it's easier to do:
  hih.restart();
  //  which will automatically commit all changes made.
  //  If you don't want to save your changes, use:
  //  hih.resetEEPROM();


  //  This is how you change the I2C address to 0x28:
  //  hih.setAddress(0x28);
  //  hih.restart();      

  //  Make sure we're not in Command Mode any more:
  hih.leaveCommandMode();

  //  Update the sensor readings, you must call this to have current readings
  hih.update();

  Serial.print("Humidity: ");
  Serial.print(hih.humidity(), 5);
  Serial.println(" RH");

  Serial.print("Temperature: ");
  Serial.print(hih.temperature(), 5);
  Serial.println(" C");

  while(true);
}
 

Advanced usage (control the sensor from a stream)

Connect everything like the second image.

Available commands:

  • all commands from HIH61XX
  • 'H1': return high alarm on (float)
  • 'H0': return high alarm off (float)
  • 'Ho': return high alarm output config
  • 'Hp': return high alarm polarity
  • 'I1': set high alarm on (float)
  • 'I0': set high alarm off (float)
  • 'Io': set high alarm output config
  • 'Ip': set high alarm polarity
  • same for low alarm (using 'L' and 'M' prefixes)
  • 's': return startup mode
  • 'c': return customer id
  • 'e': return the whole EEPROM
  • 'S': set startup mode
  • 'C': set customer id
  • 'E': set the whole EEPROM
  • 'A': set the I2C address
  • 'R': resetEEPROM()


#include <Wire.h>
#include <HIH61XX.h>

HIH61XX hih(0x27);

void setup()
{
  Serial.begin(115200);
  Wire.begin();
}

void loop()
{
  while(Serial.available()) {
    hih.commandRequest(Serial);
  }

  delay(100);
}
 

Download

https://code.google.com/p/arduino-hih61xx