HIH6121 example code compilation error

I am trying to replace some DHT22's with better humidty and temperature sensors the HIH6121 (http://www.mouser.com/ds/2/187/HumidIcon%20HIH6130_6131_HIH6120_6121%20Series%20PS_0090-191303.pdf). I downloaded the library (Arduino Playground - HoneywellHumidIconTMDigitalHumidity-TemperatureSensors) and am trying to run the example code and get a compilation error:

example:6: error: 'HIH61XX' does not name a type
example.ino: In function 'void loop()':
example:19: error: 'hih' was not declared in this scope

The code is the example code for reading humidity and temperature:

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


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


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(1) {
    while(Serial.available()) {
      hih.commandRequest(Serial);
    }
    delay(100);
  }
}

Can anyone please help me out?

did you install the library in the right place?
you should restart all instances of the IDE to get a new lib working. (due to internal administration)

The library was installed correctly and the program was restarted. Still getting that same error.

The example code on the playground :

HIH61XX hih(0x27);

where you have

HIH61XX hih(0x27, 8);

version library mismatch?

Hi moseley

I downloaded the library from the link you gave. When I tried to compile the example program that came with it, it gave a compiler error!

To fix it, I had to go into the library header file HIH61XX.h.

If you look at around lines 40 - 45, there are two copies of the following line:

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

I commented out the second one, changing it to:

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

The example then compiled OK, and your program did too.

Maybe worth a try. I don't have the right hardware to test that it actually works :slight_smile:

All the best

Ray

Ray,

I tried your suggestion without any luck. I commented out the second copy of that code but still got this error message during compiling:

example:6: error: 'HIH61XX' does not name a type
example.ino: In function 'void loop()':
example:19: error: 'hih' was not declared in this scope

Rob,

I see that the code is different on the playground but I assumed that the version I downloaded was upgraded. I am running the example code that was in the library download.

Odd. Just to check, I went to the playground page you linked in your first post, scrolled to the bottom and followed this link:

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

Then I clicked on the Downloads tab and downloaded HIH-0.2.tar.gz. When extracted, this had two library folders: HIH61XX and HIH61XXCommander. Did you get your library from a different place?

Do you have an example program for the library showing up in the Arduino IDE (under File - Examples)? If so, does it compile?

EDIT: Can you confirm the path and folder where you installed the HIH61XX files (.h and .cpp)?

Cheers

Ray

Ray

That is the file I downloaded and tried putting it in both the arduino library folder in my-documents and the arduino library folder in programfiles (not at the same time). Both of those destinations work for other libraries I have installed. The example program I am running is found under File - Examples in the Arduino IDE and gives me the error I have posted:

example:6: error: 'HIH61XX' does not name a type
example.ino: In function 'void loop()':
example:19: error: 'hih' was not declared in this scope

Not sure what to suggest next :frowning:

If it helps, I have attached the two library files from my C:\Arduino\libraries\HIH61XX\ folder. I guess you could compare them with your versions. Or post yours and I'm happy to do a file diff on them.

All the best

Ray

HIH61XX.h (2.06 KB)

HIH61XX.cpp (2.3 KB)

They look the same to me. I even tried replacing my files with yours and got the same error.

Install the HIH61XX folder in your sketchbook/library folder, not the HIH folder.

Moving the HIH61XX folder out of the HIH folder worked and I am getting accurate readings. I do still have the second copy of that code commented out. Thanks for all the help