Sorry I forgot to post my code:
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <HIH61XX.h>
HIH61XX hih(0x27, 8);
File myFile;
// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 4;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
Wire.begin();
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(SS, OUTPUT);
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
}
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(")");
myFile = SD.open("Temp.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
myFile.println(hih.temperature());
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening temp.txt");
}
myFile = SD.open("Humidity.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
myFile.println(hih.humidity());
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening humidity.txt");
}
delay(5000);
}
This is just for logging the humidity and temperature to different files on the sd card.