Library for HTU21D sensor, help needed.
This is my first attempt at writing library for temperature/humidity sensor to be integrated with Ports library. I have been using SHT15 sensor for a while, but recently I was having some problems. Sensor started to misbehave when reading humidity. The symptom was as follows. Up to about 55% RH everything appears to be OK. As humidity increased, reading was gradually decreasing all the way to zero. The higher the humidity, the faster the rate of decline. I have tested sensor with 75% RH salt solution and with water in enclosed container (>95%?). I have followed recommendation for bake and re-hydration, but no luck. After obtaining a replacement sensor a started to search for different sensor with similar performance. That’s when I came across HTU21D. This sensor sells for about half the price of SHT15.
Sparkfun Electronics that sells this sensor also published library for it by Nathan Seidle , written to work with hardware I2C bus and Wire library.
My experience in C++ programming is very limited. Luckily I was able to use this library as starting point. Library basically works with one exception. Initialisation in the “Setup” does not stick. I have to use sensor.begin() every time I read temperature or humidity, or as I have done insert “send(), stop(),send()” at the beginning of each function that reads temperature, humidity or accesses register. I believe that this is probably caused by my inexperience with Classes and interaction between Port class and Device class.
I have tested sensor using supplied “Wire” library. Performance seems to be quite good with good response to sudden changes. Returning from >90% RH to 50% RH takes less than 10 seconds.
I would appreciate any help with cleaning the code so that it can be used by others.
I hope my .cpp, .h and example files will attach correctly.