I've created a small I2C library to access the HYGROSENS HY321 module on the ARDUINO. I bought my sensor from REICHELT for about 12€.
You can find a usage sample here.
The library can be downloaded from here. Copy the library (*.c, *.cpp, *.txt) to your local libraries (taken from arduino.cc):
Open your Arduino sketchbook folder. If there is already a folder there called libraries, place the library folder in there. If not, create a folder called libraries in the sketchbook folder, and drop the library folder in there. Then re-start the Arduino programming environment, and you should see your new library in the Sketch > Import Library menu.
#ifndef _HYT321_H#define _HYT321_H
class HYT321 {
private:
int rawTemp;
int rawHum;
int address;
public:
HYT321(int adr);
uint8_t begin( void );
uint8_t read( void );
int getRawHumidity( void );
int getRawTemperature( void ) ;
double getHumidity( void ) ;
double getTemperature( void );
};
extern HYT321 HYT;
#endif
You can access it via the class HYT321. The code sequence is pretty simple:
#include <Wire.h>
#include <HYT321.h>
HYT321 HYT = HYT321(0x28);
void setup() {
// initialize I2C protocoll
Wire.begin();
// initialize the sensor
HYT.begin();
}
void loop() {
HYT.read();
double h = HYT.getHumidity();
double t = HYT.getTemperature();
for (;;);
}