Created
May 14, 2018 13:37
-
-
Save arduinothai/56391f8bfe085bba7e6cef00f8ed9d2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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