Go Down

Topic: Honeywell HIH-6130 Humidity / Temperature Sensor (Read 5903 times) previous topic - next topic

pha555

I have completed an application note with sample Arduino code for the HIH-6130 at;

http://www.phanderson.com/arduino/hih6130.html

This sensor in an 8-pin SOIC package is relatively inexpensive, provides a standard I2C interface and High and Low RH alarms with hysterisis.

If you use it, please give credit.

Peter Anderson

robtillaart


Thanks for sharing,

some improvement ideas:

replace print_float(RH, 1);   ==> Serial.print(RH, 1);   The print class of the arduino can print floats, it uses a similar algorithm as you wrote


Furthermore I would proprose to wrap the code in a class similar to this lib I wrote - http://arduino.cc/playground/Main/DHTLib - The interfaces can be almost identical.
That would encapsulate all the math for calculating the temp & humidity inside the class, making it easier for users to use. 

FInally one question: is it possible to change the address of the HIH6130? SO I can use more than one on the I2C bus?






Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


maldex

I actually did, and yes, the I2C address is changeable.

cheers
Josh


robtillaart

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

maldex

is that right, we're working on the same time on the very same chip?
And I've, to admit you did the better Job, went the extra mile to implement all features :)

Just skimming through it - how do you enter the command mode exactly (within that 3/10ms)? Reason why i have a function pointer is that we might want the HIH to be field-programmable. E.g. hook up to the output of a PCF8591 or similar to power-cycle the HIH while being installed.

followup readers: please check http://playground.arduino.cc//Main/HoneywellHumidIconTMDigitalHumidity-TemperatureSensors
and http://arduino.cc/forum/index.php/topic,150584.0.html

thanks for your work and cheers


sokopok

Quote
is that right, we're working on the same time on the very same chip?

Apparently so, if I'd have known what you were doing, I wouldn't have started on this....

Quote
And I've, to admit you did the better Job, went the extra mile to implement all features smiley

Thanks a lot!

Quote
how do you enter the command mode exactly (within that 3/10ms)?

I have been wrestling with command mode for a couple of weeks, because I didn't know the voltage on the 3.3V pin on the arduino isn't cut when you reset the arduino (or isn't cut long enough). But then finally it hit me... So I just put a 3.3V voltage regulator on a digital pin to supply the chip (the datasheet says it can handle 5V, but I didn't want to fry the chip, so...).
So: digitalWrite(powerPin, HIGH); enables the chip
And: digitalWrite(powerPin, LOW); disables it
If you want to cycle the power do something like this:
Code: [Select]
digitalWrite(powerPin, HIGH);
//  HIH is enabled now, so let's cycle the power:
digitalWrite(powerPin, LOW);
delay(1); // this is the important part: give the chip the time to notice the power has been cut
digitalWrite(powerPin, HIGH);

I hope this answers your question because I've got no idea what a PCF8591 is or what role an A/D convertor could play here.

If you have any improvements to the code or anything... you're always welcome.

pahi9557

I actually did, and yes, the I2C address is changeable.

cheers
Josh
I wasn't able to make your code work very well, but using it I was able to create a working prototype. I used two separate codes, one for changing the address, and one for displaying the temp/humid.

 You can run a seemingly infinite number of sensors (though I wouldn't use more then 10) using this process. Just set the address of each one individually following the instructions on my program and then choose the new address as the "#define"ed address in the display code.



I don't know how to attach code.. sorry.. so here's a copy/paste
*make sure to include the sensor's library






ADDRESS PROGRAMMING:




/*
 * Set up:
 * Analog 4 ------ SDA (4) ----- I2C Data Line
 * Analog 5 ------ SCL (3) ----- I2C Clock Line
 * GND ----------- Vss (2) ----- Supply Ground
 *
 *
 * CONNECT VDD FROM CHIP TO DIGI 12 ON ARDUINO
 * MAKE SURE ALL GROUNDS ARE CONNECTED
 *
 *
 * How to use:
 * define the address to the new address.
 * manually insert new address l8er in file.
 * default addresses are 0x27
 * Instructional comments can be found in code
 *
 * By Parker Hinton. Free to edit and distribute
 *
 *
 */








#define i2c_address  0x19 // This is the address you're changing to

#include "HIH6130.h"


HIH6130       hih_normal;   // runtime instance, read values
HIH6130_CMDMODE   hih_cmdmode;  // programming mode instance, change i2c address


void reset_i2c()
{         // we connected Vdd to Arduino digital PIN 12
    pinMode(12, OUTPUT);
    digitalWrite(12, LOW);    // switch off power -> reset
    delay(666);         // let power capacitors run empty
    digitalWrite(12, HIGH);   // switch power back on, 10ms remaining to enter cmdmode
}


void fetch(byte address)
{
  hih_normal.begin(address);
  Serial.print("data from address 0x");
  Serial.println(address,HEX);

 
    float humidity, temperature;

    hih_normal.fetch_data(&humidity, &temperature);

    Serial.print("Humidity: ");
    Serial.print(humidity);
    Serial.print("%  Temperature: ");
    Serial.print(temperature);
    Serial.println("C");

    delay(500);
 
}


void reconfigure()  // reconfigure I2C address
{

  hih_cmdmode.begin(0x27, &reset_i2c); // first in put is old address
  hih_cmdmode.write_i2c_address(0x19); // input is new I2c address
  hih_cmdmode.end();

  reset_i2c();              // let the config settle



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

    reset_i2c();

    Wire.begin();       // start i2c
    delay(500);
}

}

void loop(void) {
 
  fetch(i2c_address);
  reconfigure();


  delay(1000);

}


-----------------------------------------END CODE-------------------------------------------------------------------


DATA DISPLAY:

/*
 * Wiring UNO      HID6130       Description
 *
 * Analog 4 ------ SDA (4) ----- I2C Data Line
 * Analog 5 ------ SCL (3) ----- I2C Clock Line
 * GND ----------- Vss (2) ----- Supply Ground
 *
 * **** Connect VDD from sensor to a 5v power supply
 *
 * Copyright (c) 2016 by Parker Hinton
 *
 * Source code belongs to Josh Geisser <josh_dot_geisser_at_hyperwerk_dot_ch>
 *
 * This file is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 */

#define i2c_address1  0x27
#define i2c_address2  0x18
#define i2c_address3  0x26
#define i2c_address4  0x19


#include "HIH6130.h"

HIH6130       hih_normal;   // runtime instance, read values
HIH6130_CMDMODE   hih_cmdmode;  // programming mode instance, change i2c address

void scan_i2c();

void reset_i2c()
{   
}

void fetch(byte address)
{
  hih_normal.begin(address);
  Serial.print("data from 0x");
  Serial.println(address,HEX);

  for (int i = 0; i < 3; i++)
  {
    float humidity, temperature;

    hih_normal.fetch_data(&humidity, &temperature);

    Serial.print("Humidity: ");
    Serial.print(humidity);
    Serial.print("%  Temperature: ");
    Serial.print(temperature);
    Serial.println("C");

    delay(500);
  }
}


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

    reset_i2c();

    Wire.begin();       // start i2c
    delay(500);
}

void loop(void)
{
 
  fetch(i2c_address1);

 
  fetch(i2c_address2);

 
  fetch(i2c_address3);

   
  fetch(i2c_address4);









  delay(1000);
}




VT91

HIH6130       hih_normal;   // runtime instance, read values
HIH6130_CMDMODE   hih_cmdmode;  // programming mode instance, change i2c address

gives me error

What library were you using
This code doesn't seem to work anymore with the

#include "HIH6130.h"
Good image hosting service that works well with Ardunio Forum: http://imgur.com/

VT91

Last error that I got - error compiling for Arduino Micro. (I use Arduino Micro Pro.)
Good image hosting service that works well with Ardunio Forum: http://imgur.com/

VT91

PLEASE HELP!

I downloaded this library.
https://code.google.com/archive/p/arduino-hih61xx/downloads

Following this advice:
http://playground.arduino.cc/Main/HoneywellHumidIconTMDigitalHumidity-TemperatureSensors

Got this error:
Code: [Select]

Arduino: 1.6.8 (Windows 8.1), Board: "Arduino/Genuino Micro"


"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XXCommander" "C:\Users\VTolskiy\AppData\Local\Temp\build2635536b2aed4fd46194f0bc0aa20acb.tmp\sketch\example.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XXCommander" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\Wire.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XXCommander" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XXCommander" "C:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX\HIH61XX.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XXCommander" "C:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XXCommander\HIH61XXCommander.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XXCommander" "C:\Users\VTolskiy\AppData\Local\Temp\build2635536b2aed4fd46194f0bc0aa20acb.tmp\sketch\example.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XXCommander" "C:\Users\VTolskiy\AppData\Local\Temp\build2635536b2aed4fd46194f0bc0aa20acb.tmp\sketch\example.ino.cpp" -o "C:\Users\VTolskiy\AppData\Local\Temp\build2635536b2aed4fd46194f0bc0aa20acb.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\VTolskiy\AppData\Local\Temp\build2635536b2aed4fd46194f0bc0aa20acb.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX" "-IC:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XXCommander" "C:\Users\VTolskiy\AppData\Local\Temp\build2635536b2aed4fd46194f0bc0aa20acb.tmp\sketch\example.ino.cpp" -o "C:\Users\VTolskiy\AppData\Local\Temp\build2635536b2aed4fd46194f0bc0aa20acb.tmp\sketch\example.ino.cpp.o"
In file included from C:\Users\VTolskiy\Downloads\HIH6130_21.02.2017\HIH-0.2\HIH61XXCommander\example\example.ino:2:0:

C:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX/HIH61XX.h:44:8: error: 'bool HIH61XX::isRunning() const' cannot be overloaded

  bool isRunning() const { return f & RunningFlag; }

       ^

C:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX/HIH61XX.h:41:8: error: with 'bool HIH61XX::isRunning() const'

  bool isRunning() const { return f & RunningFlag; }

       ^

Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Using library HIH61XX in folder: C:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XX (legacy)
Using library HIH61XXCommander in folder: C:\Users\VTolskiy\Documents\Arduino\libraries\HIH61XXCommander (legacy)
exit status 1
Error compiling for board Arduino/Genuino Micro.

Good image hosting service that works well with Ardunio Forum: http://imgur.com/

Go Up