Skip to content

Instantly share code, notes, and snippets.

@arduinothai
Created May 14, 2018 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arduinothai/56391f8bfe085bba7e6cef00f8ed9d2c to your computer and use it in GitHub Desktop.
Save arduinothai/56391f8bfe085bba7e6cef00f8ed9d2c to your computer and use it in GitHub Desktop.
#include <Wire.h>
#include "Adafruit_HTU21DF.h"
// Connect Vin to 3-5VDC
// Connect GND to ground
// Connect SCL to I2C clock pin (A5 on UNO)
// Connect SDA to I2C data pin (A4 on UNO)
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
void setup() {
Serial.begin(9600);
Serial.println("HTU21D-F test");
if (!htu.begin()) {
Serial.println("Couldn't find sensor!");
while (1);
}
}
void loop() {
Serial.print("Temp: "); Serial.print(htu.readTemperature());
Serial.print("\t\tHum: "); Serial.println(htu.readHumidity());
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment