Feed on
Posts
comments

/*
HTU21D Humidity Sensor

Open serial monitor at 9600 baud to see readings. Errors 998 if not sensor is detected. Error 999 if CRC is bad.

Hardware Connections (Breakoutboard to Arduino):
-VCC = 3.3V
-GND = GND
-SDA = A4
-SCL = A5

*/

#include <Wire.h>
#include “HTU21D.h”

HTU21D myHumidity;

void setup()
{
Serial.begin(9600);
Serial.println(“HTU21D Reading START”);

myHumidity.begin();
}

void loop()
{
float humd = myHumidity.readHumidity();
float temp = myHumidity.readTemperature();

//USE ONE OF THE FOLLOWING LINES TO CALIBRATE THE TEMPERATURE
//temp += __
//temp -= __

Serial.print(“Time: “);
Serial.print(millis());
Serial.print(“\r\nTemperature: \r\n Celsius: “);
Serial.print(temp, 1);
Serial.print(“C”);
float fahrenheit = ((temp * 9)/5 +32);
Serial.print(“\r\n Fahrenheit: “);
Serial.print(fahrenheit, 1);
Serial.print(“F\r\n”);
Serial.print(“Humidity: “);
Serial.print(humd, 1);
Serial.print(“%\r\n”);

Serial.println();
delay(1000);
}