does not name a type error on HIH61xx

Hello,

I tried to communicate with a temp-humid sensor from Honeywell:
But get the error: HIH61XX hih(0x27) does not name a type
I tried several things,
put int before HIH61XX hih(0x27);, but then I get the error: expected initializer before hih.
put HIH61XX hih(0x27); in the setup, same error.
What's wrong

#include <AsyncDelay.h>

#include <HIH61xx.h>

#include <HIH61XXCommander.h>

#include <Wire.h>



HIH61XX hih(0x27);



void setup()

{

  Serial.begin(115200);

  Wire.begin();

}




void loop()

{

  while(Serial.available()) {

    hih.commandRequest(Serial);

  }



  delay(100);

}

Can you post at least links to those libraries? It's hard to tell why you got that error when I can't see how the library code expected you to write it.

The link to the page where this program stands:

https://playground.arduino.cc/Main/HoneywellHumidIconTMDigitalHumidity-TemperatureSensors

The librarie is at the end.

What does the last sentence in the reply mean?:

Please do not PM with technical questions or comments. Keep Arduino stuff out on the boards where it belongs.

I thought that this is a forum about Arduino.....

KR John

That last line is part of my signature and it means that I'll help you on the forum but I don't want you sending me private messages or emails asking for private help.

Please post the actual error messages instead of paraphrasing them. There is probably some important information there.

Actual messages:

Arduino: 1.6.5 (Windows 8.1), Board:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build-opties gewijzigd, alles wordt opnieuw gebuild

Bibliotheek AsyncDelay in map: C:\Users\John\Documents\Arduino\libraries\AsyncDelay wordt gebruikt

Bibliotheek HIH61xx in map: C:\Users\John\Documents\Arduino\libraries\HIH61xx wordt gebruikt

Bibliotheek HIH61XXCommander in map: C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander (legacy) wordt gebruikt

Bibliotheek Wire in map: C:\Program Files\Arduino backup 6.5.1\Arduino\hardware\arduino\avr\libraries\Wire wordt gebruikt

C:\Program Files\Arduino backup 6.5.1\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino backup 6.5.1\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino backup 6.5.1\Arduino\hardware\arduino\avr\variants\mega -IC:\Users\John\Documents\Arduino\libraries\AsyncDelay\src -IC:\Users\John\Documents\Arduino\libraries\HIH61xx\src -IC:\Users\John\Documents\Arduino\libraries\HIH61XXCommander -IC:\Program Files\Arduino backup 6.5.1\Arduino\hardware\arduino\avr\libraries\Wire C:\Users\John\AppData\Local\Temp\build4021539192142448426.tmp\sketch_sep30a.cpp -o C:\Users\John\AppData\Local\Temp\build4021539192142448426.tmp\sketch_sep30a.cpp.o

In file included from sketch_sep30a.ino:7:0:
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h:13:1: error: expected class-name before '{' token
{
^
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h: In member function 'bool HIH61XXCommander::isCommandMode() const':
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h:33:39: error: 'f' was not declared in this scope
bool isCommandMode() const { return f & CommandModeFlag; }
^
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h:33:43: error: 'CommandModeFlag' was not declared in this scope
bool isCommandMode() const { return f & CommandModeFlag; }
^
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h: In member function 'float HIH61XXCommander::highAlarmOn() const':
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h:68:69: error: 'rawToHumidity' was not declared in this scope
float highAlarmOn() const { return rawToHumidity(highAlarmOn_Raw()); }
^
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h: In member function 'float HIH61XXCommander::highAlarmOff() const':
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h:71:71: error: 'rawToHumidity' was not declared in this scope
float highAlarmOff() const { return rawToHumidity(highAlarmOff_Raw()); }
^
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h: In member function 'float HIH61XXCommander::lowAlarmOn() const':
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h:86:67: error: 'rawToHumidity' was not declared in this scope
float lowAlarmOn() const { return rawToHumidity(lowAlarmOn_Raw()); }
^
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h: In member function 'float HIH61XXCommander::lowAlarmOff() const':
C:\Users\John\Documents\Arduino\libraries\HIH61XXCommander/HIH61XXCommander.h:89:69: error: 'rawToHumidity' was not declared in this scope
float lowAlarmOff() const { return rawToHumidity(lowAlarmOff_Raw()); }
^
sketch_sep30a.ino: In function 'void setup()':
sketch_sep30a.ino:15:13: error: expected initializer before 'hih'
sketch_sep30a.ino: In function 'void loop()':
sketch_sep30a.ino:35:5: error: 'hih' was not declared in this scope
Multiple libraries were found for "AsyncDelay.h"

Used: C:\Users\John\Documents\Arduino\libraries\AsyncDelay

Not used: C:\Users\John\Documents\Arduino\libraries\Ethernet

expected initializer before 'hih'

Looks like a lot of unhappiness in the library "HIH61XXCommander.h"

I can't access the library, so only based on the error's posted above.

I also needed to install this library:

After that I got this error:

fatal error: HIH61xx.h: No such file or directory

I see from your error output:

John_Pijnappel:
Bibliotheek HIH61xx in map: C:\Users\John\Documents\Arduino\libraries\HIH61xx wordt gebruikt

That your library is in a folder named HIH61xx. But the folder from the download linked off that Playground page is in a folder named HIH61XX. This makes me think you're doing something weird. Either you found that library somewhere else that you didn't tell us about or else you messed with it. Not good.

So I fixed the filename in the #include directive:

#include <HIH61XX.h>

Then I got this error:

In file included from sketch_oct01a.ino:4:0:
E:\electronics\arduino\libraries\HIH61XX/HIH61XX.h:44:8: error: 'bool HIH61XX::isRunning() const' cannot be overloaded
   bool isRunning() const { return f & RunningFlag; }
        ^
E:\electronics\arduino\libraries\HIH61XX/HIH61XX.h:41:8: error: with 'bool HIH61XX::isRunning() const'
   bool isRunning() const { return f & RunningFlag; }
        ^
Error compiling.

I opened the file HIH61XX.h and found that the author had two identical definitions of isRunning():

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

I don't know whether that was allowed back in the days when the library was written or if the author just never bothered to do the most basic test of their code.

I removed the duplicate definition and the code compiles no problem.

So my advice is to delete C:\Users\John\Documents\Arduino\libraries\HIH61xx, install the one that comes with the download from the Playground link, and then fix the error in the library and the filename in your sketch.