I’ve written a small c++ library for the honeywell hih4030 humidity sensor that I figure I’d post for anyone who needs it. I’ve been using it for a bit now and it does the job. Its very simple. There is a constructor that accepts the pin number, the millivoltage of the power provided to the IC (it accepts 4 - 5.8V), and your ADC resolution. The output is ratiometric to the voltage input hence the requirement to tell the library the mV of the power supply and the ADC resolution. There is one public method “getRh(int)” which accepts a temperature value in celsius (you can just input 25 degrees C if you don’t have temperature sensing capability but I recommend it for more accurate readings) and returns the relative humidity as a float.
I instantiate a global var and use it wherever needed in my code but more than one instance can be constructed at a time (there is a copy constructor for convenience):
HIH4030 hih(humPin, maxMVolts, adcResolution);
If anyone has questions please let me know.
hih4030.h (785 Bytes)
hih4030.cpp (1.61 KB)